:root {
  color-scheme: light;
  --ink: #173229;
  --muted: #68766f;
  --paper: #fffdf8;
  --canvas: #f3efe6;
  --green: #1f5b47;
  --green-dark: #153f32;
  --green-soft: #dce9df;
  --gold: #d5a841;
  --line: #ded8cb;
  --shadow: 0 18px 50px rgba(34, 47, 39, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(213, 168, 65, 0.14), transparent 25rem),
    linear-gradient(180deg, #f8f5ed 0%, var(--canvas) 42%, #ece8de 100%);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  color: #fff;
  background: rgba(21, 63, 50, 0.94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--green-dark);
  background: var(--gold);
  font-family: "Songti SC", serif;
  font-size: 22px;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: 0.04em; }
.brand small { margin-top: 3px; color: rgba(255,255,255,.65); font-size: 11px; }
.quiet-link { color: rgba(255,255,255,.8); font-size: 14px; text-decoration: none; }

.shell {
  width: min(1180px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 36px 0 calc(80px + env(safe-area-inset-bottom));
}

.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.home-primary { display: grid; gap: 20px; }
.home-layout, .home-primary, .hero-card, .history-panel, .job-card, .article-view, .article-header, .reading-paper, .report-paper, .input-row { min-width: 0; }

.hero-card, .history-panel, .job-card, .auth-card, .article-header, .reading-paper, .report-paper, .tip-card {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(222, 216, 203, 0.9);
  box-shadow: var(--shadow);
}

.hero-card { padding: clamp(26px, 5vw, 54px); border-radius: 30px; overflow: hidden; position: relative; }
.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -60px;
  top: -70px;
  border: 28px solid rgba(213,168,65,.16);
  border-radius: 50%;
  pointer-events: none;
}

.eyebrow { margin: 0 0 10px; color: #8b6b24; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
.hero-card h1 { max-width: 760px; margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(34px, 5.5vw, 60px); line-height: 1.08; letter-spacing: -.03em; }
.hero-copy { max-width: 680px; margin: 20px 0 30px; color: var(--muted); font-size: 16px; line-height: 1.75; }

.submit-form, .auth-form { display: grid; gap: 12px; }
.submit-form label, .auth-form label { font-size: 13px; font-weight: 750; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(31,91,71,.12); }

.primary-button, .secondary-button, .quiet-button, .icon-button, .back-button {
  min-height: 48px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  font-weight: 750;
}
.primary-button { padding: 0 22px; color: #fff; background: var(--green); box-shadow: 0 10px 24px rgba(31,91,71,.2); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { padding: 0 18px; color: var(--green); background: var(--green-soft); }
.quiet-button, .icon-button, .back-button { padding: 0 14px; color: var(--muted); background: transparent; }
.submit-button { width: 100%; margin-top: 4px; }

.job-card { padding: 24px; border-radius: 24px; }
.job-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.job-heading h2, .section-heading h2 { margin: 0; font-size: 21px; }
.percent-pill { padding: 7px 11px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-weight: 800; }
.progress-track { height: 9px; margin: 20px 0 12px; overflow: hidden; border-radius: 999px; background: #e7e2d7; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--green)); transition: width .35s ease; }
.muted { color: var(--muted); font-size: 14px; }

.history-panel { position: sticky; top: calc(92px + env(safe-area-inset-top)); padding: 22px; border-radius: 24px; }
.history-list { display: grid; gap: 10px; margin-top: 18px; }
.history-item {
  width: 100%;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: 17px;
  color: inherit;
  background: #f6f2e9;
  text-align: left;
  cursor: pointer;
}
.history-item:hover { border-color: #c9d9cf; background: #eef4ef; }
.history-item strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 15px; line-height: 1.5; }
.history-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.empty-state { padding: 30px 12px; color: var(--muted); text-align: center; line-height: 1.7; }

.auth-card { width: min(560px, 100%); margin: 8vh auto; padding: 34px; border-radius: 28px; }
.auth-card h1 { margin: 0 0 12px; font-family: "Songti SC", serif; font-size: 32px; }
.auth-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.auth-form { margin-top: 24px; }

.article-view { max-width: 900px; margin: 0 auto; }
.back-button { margin-bottom: 14px; }
.article-header { padding: clamp(24px, 5vw, 48px); border-radius: 28px; }
.article-header h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(32px, 5vw, 50px); line-height: 1.22; }
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.stat-chip { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #faf8f2; font-size: 13px; }
.article-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.analysis-placeholder { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 28px; padding: 18px; border-left: 4px solid var(--gold); border-radius: 4px 16px 16px 4px; background: #f7f0dc; }
.analysis-placeholder > div { display: grid; gap: 5px; }
.analysis-placeholder span { display: block; color: #746438; font-size: 14px; line-height: 1.6; }

.article-tabs { position: sticky; top: calc(80px + env(safe-area-inset-top)); z-index: 12; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: min(420px, 100%); margin: 20px auto 0; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.92); backdrop-filter: blur(16px); box-shadow: 0 8px 24px rgba(34,47,39,.08); }
.tab-button { min-height: 44px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 760; cursor: pointer; }
.tab-button.active { color: #fff; background: var(--green); }

.reading-paper { margin-top: 20px; padding: clamp(24px, 6vw, 64px); border-radius: 28px; }
.reading-paper h1, .reading-paper h2, .reading-paper h3, .reading-paper h4 { margin: 2.1em 0 .8em; font-family: "Songti SC", "STSong", serif; line-height: 1.35; }
.reading-paper h1 { font-size: 30px; }
.reading-paper h2 { font-size: 27px; }
.reading-paper h3 { font-size: 24px; }
.reading-paper p, .reading-paper blockquote { margin: 0 0 1.25em; font-family: "Songti SC", "STSong", serif; font-size: clamp(18px, 2.1vw, 21px); line-height: 1.9; letter-spacing: .015em; white-space: pre-wrap; }
.reading-paper blockquote { padding: 18px 20px; border-left: 4px solid var(--gold); background: #faf4e3; }
.reading-paper img { display: block; max-width: 100%; height: auto; margin: 28px auto; border-radius: 18px; background: #eee9df; }
.image-placeholder { margin: 22px 0; padding: 20px; border: 1px dashed #c8c0af; border-radius: 16px; color: var(--muted); text-align: center; }

.report-paper { margin-top: 20px; padding: clamp(24px, 5vw, 54px); border-radius: 28px; }
.report-paper h1, .report-paper h2, .report-paper h3 { margin: 1.9em 0 .75em; font-family: "Songti SC", "STSong", serif; line-height: 1.35; }
.report-paper h1:first-child, .report-paper h2:first-child { margin-top: 0; }
.report-paper h1 { font-size: 31px; }
.report-paper h2 { padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 27px; }
.report-paper h3 { font-size: 22px; }
.report-paper p, .report-paper li, .report-paper blockquote { font-size: 17px; line-height: 1.8; }
.report-paper li { margin: 8px 0; }
.report-paper blockquote { margin: 18px 0; padding: 15px 18px; border-left: 4px solid var(--gold); background: #faf4e3; }
.report-table-wrap { margin: 20px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.report-paper table { width: 100%; border-collapse: collapse; min-width: 620px; }
.report-paper th, .report-paper td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.65; }
.report-paper th { background: #edf3ee; font-size: 13px; }
.report-paper td { font-size: 15px; }
.score-badge { color: #7b5a0f; font-weight: 800; }
.report-image-section { margin-top: 54px; }
.report-image-intro { color: var(--muted); }
.report-image-gallery { display: grid; gap: 28px; margin-top: 24px; }
.report-image-card { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: #faf8f2; }
.report-image-card img { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; border-radius: 14px; background: #eee9df; }
.report-image-card .image-placeholder { margin: 0; }
.report-image-card figcaption { margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.65; }

.guide-shell { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 56px 0 100px; }
.guide-shell h1 { margin: 0; font-family: "Songti SC", serif; font-size: clamp(36px, 7vw, 56px); line-height: 1.12; }
.guide-intro { color: var(--muted); font-size: 18px; line-height: 1.8; }
.guide-steps { display: grid; gap: 12px; padding: 0; margin: 34px 0; list-style: none; counter-reset: steps; }
.guide-steps li { position: relative; display: grid; gap: 6px; min-height: 92px; padding: 20px 20px 20px 72px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); counter-increment: steps; }
.guide-steps li::before { content: counter(steps); position: absolute; left: 20px; top: 20px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-weight: 800; }
.guide-steps span { color: var(--muted); line-height: 1.7; }
.tip-card { padding: 22px; border-radius: 20px; }
.tip-card p { margin-bottom: 0; color: var(--muted); line-height: 1.7; }
.inline-button { display: inline-grid; place-items: center; margin-top: 24px; text-decoration: none; }
code { padding: 2px 6px; border-radius: 6px; background: #eae5db; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 40; max-width: calc(100% - 32px); transform: translateX(-50%); padding: 13px 18px; border-radius: 999px; color: #fff; background: rgba(21,63,50,.95); box-shadow: var(--shadow); font-size: 14px; }

@media (max-width: 880px) {
  .shell { padding-top: 22px; }
  .home-layout { grid-template-columns: 1fr; }
  .history-panel { position: static; }
  .hero-card { border-radius: 24px; }
}

@media (display-mode: standalone) {
  html, body { min-height: 100dvh; }
}

@media (max-width: 560px) {
  .topbar-inner, .shell, .guide-shell { width: min(100% - 22px, 1180px); }
  .quiet-link { font-size: 12px; }
  .brand small { display: none; }
  .hero-card h1 { font-size: 38px; }
  .input-row { grid-template-columns: 1fr; }
  .secondary-button { width: 100%; }
  .article-actions > * { flex: 1 1 auto; }
  .analysis-placeholder { align-items: stretch; flex-direction: column; }
  .reading-paper { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
