:root {
  --bg: #f6f3ee;
  --bg-soft: #fbf8f4;
  --card: #ffffff;
  --ink: #221f1b;
  --muted: #6f665c;
  --accent: #b45309;
  --accent-strong: #92400e;
  --accent-soft: #f5ede4;
  --danger: #b42318;
  --danger-soft: #fbeae8;
  --line: #e5ddd2;
  --shadow: 0 16px 40px rgba(34, 31, 27, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(245, 237, 228, 0.9), transparent 36%),
    linear-gradient(180deg, #f7f3ed 0%, #f3efe8 100%);
  color: var(--ink);
  font-family: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: 17px;
  line-height: 1.7;
}

a {
  color: inherit;
}

code,
pre,
input,
textarea,
select,
button {
  font-family: inherit;
}

.app-shell {
  min-height: 100vh;
}

.container {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 0 16px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(246, 243, 238, 0.88);
  border-bottom: 1px solid rgba(229, 221, 210, 0.85);
}

.header-inner {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand-block {
  display: grid;
  gap: 6px;
}

.brand-mark {
  color: var(--ink);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.app-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.app-nav.open {
  max-height: 300px;
}

.nav-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
}

.nav-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-shell {
  padding-top: 20px;
  padding-bottom: 36px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  font-weight: 700;
}

.flash-success {
  color: #1f7a3d;
  background: #eaf6ee;
  border-color: rgba(31, 122, 61, 0.15);
}

.flash-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.15);
}

.page-header {
  display: grid;
  gap: 8px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 1.15;
}

.page-desc {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.stack {
  display: grid;
  gap: 16px;
}

.stack-lg {
  display: grid;
  gap: 22px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-3 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card-wide {
  grid-column: 1 / -1;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-card {
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(180, 83, 9, 0.08);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.danger-tag {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-card {
  display: grid;
  gap: 12px;
}

.metric-value {
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  font-weight: 800;
  line-height: 1;
}

.metric-value-sm {
  font-size: clamp(1.3rem, 6vw, 1.8rem);
}

.metric-label {
  margin: 0;
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2,
.section-head h3,
.card h2,
.card h3 {
  margin: 0;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #8f1b13;
  border-color: #8f1b13;
}

.btn-block {
  width: 100%;
}

.row {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.field-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 56px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.password-toggle-eye {
  position: relative;
  width: 20px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50% / 60%;
}

.password-toggle-eye::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-toggle-eye::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%) rotate(-25deg);
  transform-origin: center;
}

.password-toggle.is-visible .password-toggle-eye::before {
  opacity: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.saved-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(31, 122, 61, 0.25);
  border-radius: var(--radius-sm);
  background: #eaf6ee;
}

.saved-key-text {
  margin: 0;
  color: #1f7a3d;
  font-weight: 700;
}

.saved-key-text code {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(31, 122, 61, 0.2);
  background: #fff;
}

.replace-key-panel {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
}

.replace-key-panel summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--accent);
}

.replace-key-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 8px;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-inline {
  width: fit-content;
  margin-top: 10px;
}

.time-slot-list {
  display: grid;
  gap: 10px;
}

.table-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(251, 248, 244, 0.95));
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  background: rgba(245, 237, 228, 0.55);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.inline-actions {
  display: grid;
  gap: 10px;
  min-width: 240px;
}

.inline-form {
  display: grid;
  gap: 8px;
}

.inline-form .btn,
.inline-actions .btn {
  width: 100%;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: rgba(251, 248, 244, 0.8);
}

.filter-bar {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-search {
  grid-column: 1 / -1;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-summary {
  margin-bottom: 14px;
}

.mobile-feed {
  display: grid;
  gap: 14px;
}

.mobile-job-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 248, 244, 0.92));
}

.mobile-job-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.job-kicker {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.job-title {
  margin: 4px 0 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(245, 237, 228, 0.9);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.job-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.job-meta-grid strong,
.job-snippet strong,
.job-alert strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.job-meta-grid span {
  display: block;
  font-size: 0.95rem;
  word-break: break-word;
}

.job-snippet,
.job-alert {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(245, 237, 228, 0.45);
}

.job-snippet p,
.job-alert p {
  margin: 0;
  font-size: 0.95rem;
}

.job-alert {
  background: rgba(251, 234, 232, 0.7);
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.75);
}

.detail-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 800;
}

.detail-panel summary::-webkit-details-marker {
  display: none;
}

.detail-grid {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
}

.detail-grid strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-grid span {
  display: block;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.status-ok {
  background: #eaf6ee;
  color: #1f7a3d;
}

.status-warn {
  background: #fff2dd;
  color: #9a5b00;
}

.status-danger {
  background: #fbeae8;
  color: #b42318;
}

.review-actions {
  display: grid;
  gap: 12px;
}

.desktop-table {
  display: none;
}

.kv-list {
  display: grid;
  gap: 10px;
}

.kv-item strong {
  display: block;
  margin-bottom: 4px;
}

.senior-tip {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(180, 83, 9, 0.18);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(245, 237, 228, 0.95), rgba(255, 255, 255, 0.92));
}

.senior-tip h2 {
  margin: 0;
  font-size: 1.12rem;
}

.step-list {
  display: grid;
  gap: 14px;
}

.step-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid rgba(180, 83, 9, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
}

.step-body {
  display: grid;
  gap: 6px;
}

.step-title {
  margin: 0;
  font-size: 1.08rem;
}

.step-desc {
  margin: 0;
  color: var(--muted);
}

.action-grid {
  display: grid;
  gap: 12px;
}

.btn-step {
  width: 100%;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 520px);
}

.login-card h1 {
  margin-top: 0;
  margin-bottom: 6px;
}

.helper-links {
  display: grid;
  gap: 12px;
}

.helper-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

pre {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
}

ul {
  padding-left: 20px;
}

.template-grid {
  display: grid;
  gap: 16px;
}

.template-editor {
  align-items: start;
}

.template-editor .field {
  align-content: start;
}

.template-editor .form-actions {
  justify-content: flex-start;
}

.select-native-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.style-picker {
  position: relative;
}

.style-picker-trigger {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.style-picker-trigger::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.88rem;
}

.style-picker.open .style-picker-trigger::after {
  content: "▴";
}

.style-picker-menu {
  display: none;
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow: auto;
  padding: 6px;
}

.style-picker.open .style-picker-menu {
  display: block;
}

.style-picker-option {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 7px 9px;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-size: 0.98rem;
  cursor: pointer;
}

.style-picker-option:hover {
  background: var(--accent-soft);
}

.style-picker-option.is-selected {
  background: rgba(180, 83, 9, 0.14);
}

.style-picker-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.style-chip {
  width: 18px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--chip-border, #d8e6f2);
  background: var(--chip-bg, #eef6ff);
  position: relative;
  flex-shrink: 0;
}

.style-chip::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: var(--chip-accent, #4a8ecb);
  border-radius: 999px;
}

.template-card {
  display: grid;
  gap: 14px;
}

.template-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.preview-article {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #ead7b8;
  background: linear-gradient(180deg, #fffaf3, #fffefb);
}

.preview-style-tag {
  display: inline-block;
  margin: 0 0 10px 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #7a4d22;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid #f0e4cf;
}

.preview-title {
  margin: 0 0 8px 0;
  color: #8a4b08;
  font-size: 1.2rem;
  line-height: 1.4;
}

.preview-summary {
  margin: 0 0 12px 0;
  padding: 8px 10px;
  border-left: 4px solid #d18b47;
  background: #fff3dd;
  color: #6b4a2b;
  font-size: 0.96rem;
}

.preview-body {
  display: grid;
  gap: 10px;
}

.preview-body p {
  margin: 0;
  color: #2b241d;
  line-height: 1.8;
}

.preview-theme-clean {
  border-color: #d8e6f2;
  background: linear-gradient(180deg, #f9fcff, #ffffff);
}

.preview-theme-clean .preview-style-tag {
  color: #1d4f79;
  border-color: #d8e6f2;
}

.preview-theme-clean .preview-title {
  text-align: center;
  color: #174b78;
}

.preview-theme-clean .preview-summary {
  background: #eef6ff;
  border-left: 4px solid #6ca2d1;
  color: #2f4f6b;
}

.preview-theme-clean .preview-body p {
  color: #1e2f3f;
}

.preview-theme-blossom {
  border-color: #f0d6e3;
  background: linear-gradient(180deg, #fff7fa, #fffefe);
}

.preview-theme-blossom .preview-style-tag {
  color: #8a2f56;
  border-color: #f0d6e3;
}

.preview-theme-blossom .preview-title {
  color: #8a2f56;
}

.preview-theme-blossom .preview-summary {
  background: #ffeef5;
  border-left: 4px solid #d86a96;
  color: #6a2f4a;
}

.preview-theme-blossom .preview-body p {
  color: #3a2430;
}

@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }

  body {
    font-size: 18px;
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .nav-toggle {
    display: none;
  }

  .app-nav {
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(5, auto);
    justify-content: end;
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .filter-actions {
    justify-content: flex-end;
  }

  .job-meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }

  .action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.template-details {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
}

.template-details summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--accent);
}

.template-details[open] summary {
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}

.template-details > .stack {
  padding: 0 12px 12px;
}

@media (max-width: 374px) {
  .container {
    padding: 0 12px;
  }

  body {
    font-size: 16px;
  }

  .card {
    padding: 14px;
  }

  .btn {
    min-height: 48px;
    font-size: 0.95rem;
  }
}

@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .mobile-feed {
    display: none;
  }

  .desktop-table {
    display: block;
  }

  #create-template .template-editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 16px;
    row-gap: 14px;
  }
}
