:root {
  --bg: #f3f3f5;
  --paper: #ffffff;
  --ink: #19191b;
  --muted: #77777f;
  --soft: #b7b7bd;
  --line: #dedee3;
  --red: #d70b30;
  --red-dark: #b90828;
  --gold: #c58f3b;
  --green: #19724b;
  --danger-bg: #fff1f3;
  --shadow: 0 14px 38px rgba(35, 25, 28, 0.07);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
:focus-visible { outline: 3px solid rgba(215, 11, 48, 0.24); outline-offset: 2px; }

.shell { min-height: 100vh; }
.topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; border-bottom: 1px solid rgba(25,25,27,.08); background: rgba(243,243,245,.94);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; background: var(--red); color: white; font-weight: 800; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.identity { color: var(--muted); font-size: 14px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hero { min-height: calc(100vh - 68px); padding: 116px 24px 100px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.eyebrow { border: 1px solid var(--gold); color: var(--gold); padding: 10px 22px; font-size: 14px; font-weight: 700; letter-spacing: 6px; }
.hero h1 { font-size: 72px; line-height: 1.08; margin: 46px 0 28px; letter-spacing: 0; }
.accent { color: var(--red); }
.hero-copy { color: var(--muted); font-size: 19px; line-height: 1.85; margin: 0; max-width: 780px; }
.motto { margin-top: 26px; color: var(--soft); font-size: 14px; letter-spacing: 7px; }
.primary, .secondary, .ghost, .danger {
  min-height: 44px; border: 0; padding: 0 20px; font-weight: 700; transition: background .18s, transform .18s, border-color .18s;
}
.primary { background: var(--red); color: white; box-shadow: 0 12px 28px rgba(215,11,48,.17); }
.primary:hover { background: var(--red-dark); transform: translateY(-1px); }
.hero .primary { margin-top: 58px; min-width: 218px; min-height: 58px; font-size: 18px; }
.secondary { background: var(--ink); color: white; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.ghost:hover { background: white; border-color: #c5c5ca; }
.danger { background: var(--danger-bg); color: var(--red-dark); }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 9px; }
.subtle { margin-top: 22px; color: var(--soft); font-size: 14px; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 42%) 1fr; }
.auth-aside { background: var(--ink); color: white; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside .brand { color: white; }
.auth-quote { max-width: 480px; }
.auth-quote strong { color: var(--gold); font-size: 14px; letter-spacing: 5px; }
.auth-quote h1 { font-size: 48px; line-height: 1.22; margin: 28px 0 20px; }
.auth-quote p { color: #bdbdc2; line-height: 1.8; }
.auth-main { padding: 48px; display: grid; place-items: center; }
.auth-panel { width: min(440px, 100%); }
.auth-panel h2 { font-size: 32px; margin: 0 0 12px; }
.auth-panel > p { color: var(--muted); line-height: 1.7; margin-bottom: 34px; }
.field { display: grid; gap: 9px; margin-bottom: 20px; }
.field label { font-size: 14px; font-weight: 700; }
.field input, .field select, .search-input {
  min-height: 48px; width: 100%; border: 1px solid var(--line); background: white; color: var(--ink); padding: 0 14px;
}
.field input:focus, .field select:focus, .search-input:focus, textarea:focus { border-color: var(--red); outline: 3px solid rgba(215,11,48,.1); }
.form-error { min-height: 22px; margin: -4px 0 12px; color: var(--red-dark); font-size: 14px; }
.auth-panel .primary { width: 100%; }
.person-chip { border-left: 3px solid var(--red); padding-left: 14px; margin-bottom: 28px; }
.person-chip b, .person-chip span { display: block; }
.person-chip span { color: var(--muted); margin-top: 5px; font-size: 14px; }

.survey-layout { display: grid; grid-template-columns: 280px minmax(0, 920px); gap: 48px; max-width: 1280px; margin: 0 auto; padding: 44px 32px 120px; }
.survey-nav { position: sticky; top: 102px; align-self: start; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.progress-track { width: 100%; height: 4px; display: block; border: 0; background: #d9d9dd; appearance: none; }
.progress-track::-webkit-progress-bar { background: #d9d9dd; }
.progress-track::-webkit-progress-value { background: var(--red); transition: width .24s; }
.progress-track::-moz-progress-bar { background: var(--red); }
.chapter-list { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 3px; }
.chapter-button { width: 100%; border: 0; background: transparent; color: var(--muted); display: grid; grid-template-columns: 34px 1fr auto; gap: 9px; align-items: center; padding: 12px 8px; text-align: left; }
.chapter-button.active { color: var(--ink); background: white; box-shadow: var(--shadow); }
.chapter-number { color: var(--red); font-weight: 800; font-size: 12px; }
.chapter-count { font-size: 12px; color: var(--soft); }
.survey-main { min-width: 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin: 4px 0 26px; }
.section-kicker { color: var(--red); font-size: 13px; font-weight: 800; }
.section-head h1 { font-size: 34px; margin: 8px 0 5px; }
.section-head p { color: var(--muted); margin: 0; }
.save-status { color: var(--muted); font-size: 13px; min-width: 76px; text-align: right; }
.save-status.error { color: var(--red-dark); }
.save-status.saved { color: var(--green); }
.questions { display: grid; gap: 14px; }
.question-card { background: var(--paper); border: 1px solid var(--line); padding: 26px; box-shadow: 0 2px 0 rgba(0,0,0,.01); }
.question-heading { display: grid; grid-template-columns: 32px 1fr; gap: 12px; font-size: 16px; line-height: 1.75; margin-bottom: 16px; }
.question-index { color: var(--soft); font-weight: 700; }
.question-card textarea { width: 100%; min-height: 130px; resize: vertical; border: 1px solid var(--line); background: #fafafd; color: var(--ink); padding: 15px; line-height: 1.65; }
.question-card textarea::placeholder { color: #b2b2b8; }
.question-meta { display: flex; justify-content: flex-end; margin-top: 8px; color: var(--soft); font-size: 12px; }
.survey-actions { display: flex; justify-content: space-between; gap: 14px; margin-top: 28px; }
.survey-actions .right { display: flex; gap: 10px; }
.mobile-question-nav { display: none; }

.result-page, .admin-page { max-width: 1280px; margin: 0 auto; padding: 54px 32px 100px; }
.result-hero { border-bottom: 1px solid var(--line); padding-bottom: 34px; margin-bottom: 38px; }
.result-hero h1 { font-size: 42px; margin: 10px 0 15px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); }
.result-section { margin: 42px 0; }
.result-section h2 { font-size: 24px; margin-bottom: 20px; }
.result-answer { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 21px 0; border-top: 1px solid var(--line); }
.result-answer b { color: var(--red); }
.result-answer h3 { font-size: 15px; line-height: 1.65; margin: 0 0 10px; }
.result-answer p { white-space: pre-wrap; color: #525259; line-height: 1.7; margin: 0; }
.unanswered { color: var(--soft) !important; }

.admin-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 32px; }
.admin-head h1 { font-size: 36px; margin: 4px 0 0; }
.admin-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: white; margin-bottom: 28px; }
.metric { padding: 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) 180px; gap: 10px; margin-bottom: 14px; }
.response-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); }
.response-table th, .response-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.response-table th { color: var(--muted); font-size: 12px; background: #fafafd; }
.response-table tbody tr { cursor: pointer; }
.response-table tbody tr:hover { background: #fafafd; }
.status { display: inline-block; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.status.submitted { color: var(--green); background: #e9f6ef; }
.status.draft { color: #8a5b14; background: #fff6df; }
.status.invited { color: var(--muted); background: #eeeef1; }
.status.deleted { color: var(--red-dark); background: var(--danger-bg); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 260px; }
.compact { min-height: 34px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.one-time-note { color: var(--red-dark) !important; font-size: 13px; }
.credential-missing { display: block; margin-top: 6px; color: #8a5b14; font-size: 12px; font-weight: 700; }
.empty { padding: 64px 24px; border: 1px solid var(--line); text-align: center; color: var(--muted); background: white; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(18,18,20,.48); z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal { width: min(520px, 100%); max-height: min(720px, 90vh); overflow: auto; background: white; padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.modal.wide { width: min(880px, 100%); }
.modal h2 { margin: 0 0 10px; }
.modal > p { color: var(--muted); line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.invite-link { display: flex; gap: 8px; margin-top: 18px; }
.invite-link input { flex: 1; min-width: 0; border: 1px solid var(--line); padding: 0 12px; }
.share-fields { display: grid; gap: 10px; margin-top: 18px; }
.share-fields label { color: var(--muted); font-size: 13px; font-weight: 800; }
.share-fields .invite-link { margin-top: 0; }
.share-message { width: 100%; min-height: 108px; border: 1px solid var(--line); background: #fafafd; padding: 12px; line-height: 1.7; resize: vertical; }
.detail-list { margin-top: 24px; }
.detail-answer { border-top: 1px solid var(--line); padding: 18px 0; }
.detail-answer h3 { font-size: 14px; line-height: 1.6; margin: 0 0 8px; }
.detail-answer p { white-space: pre-wrap; color: var(--muted); margin: 0; line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: white; padding: 12px 18px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { min-height: 70vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 900px) {
  .topbar { padding: 0 18px; }
  .hero { padding-top: 82px; }
  .hero h1 { font-size: 52px; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { min-height: 260px; padding: 30px; }
  .auth-quote h1 { font-size: 34px; }
  .auth-main { padding: 40px 24px; }
  .survey-layout { grid-template-columns: 1fr; padding: 30px 20px 110px; }
  .survey-nav { position: static; }
  .chapter-list { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .chapter-list::-webkit-scrollbar { display: none; }
  .chapter-button { min-width: 164px; }
  .metrics { grid-template-columns: 1fr 1fr 1fr; }
  .response-table th:nth-child(3), .response-table td:nth-child(3), .response-table th:nth-child(5), .response-table td:nth-child(5) { display: none; }
}

@media (max-width: 600px) {
  .topbar { height: 60px; }
  .brand-text { display: none; }
  .identity { max-width: 150px; font-size: 12px; }
  .hero { min-height: calc(100vh - 60px); padding: 58px 20px 72px; justify-content: flex-start; }
  .eyebrow { font-size: 12px; letter-spacing: 4px; }
  .hero h1 { font-size: 42px; margin: 36px 0 23px; }
  .hero-copy { font-size: 16px; line-height: 1.75; }
  .motto { font-size: 12px; letter-spacing: 4px; }
  .hero .primary { margin-top: 44px; width: 100%; }
  .auth-aside { min-height: 210px; padding: 24px 20px; }
  .auth-quote strong { font-size: 11px; letter-spacing: 3px; }
  .auth-quote h1 { font-size: 29px; margin: 18px 0 8px; }
  .auth-quote p { display: none; }
  .auth-main { padding: 34px 20px 48px; place-items: start center; }
  .auth-panel h2 { font-size: 27px; }
  .survey-layout { display: block; padding: 22px 16px 104px; }
  .survey-nav { margin-bottom: 22px; }
  .chapter-list { display: none; }
  .section-head { align-items: start; }
  .section-head h1 { font-size: 26px; }
  .section-head p { font-size: 13px; }
  .questions { display: block; }
  .question-card { display: none; border: 0; padding: 23px 18px; box-shadow: var(--shadow); }
  .question-card.mobile-active { display: block; }
  .question-heading { grid-template-columns: 28px 1fr; font-size: 16px; }
  .question-card textarea { min-height: 260px; resize: none; }
  .survey-actions { display: none; }
  .mobile-question-nav { display: grid; grid-template-columns: 46px 1fr 46px; gap: 9px; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); backdrop-filter: blur(12px); }
  .mobile-question-nav button { min-height: 46px; padding: 0; }
  .mobile-question-nav .primary { padding: 0 10px; }
  .result-page, .admin-page { padding: 34px 16px 80px; }
  .result-hero h1 { font-size: 32px; }
  .result-answer { grid-template-columns: 30px 1fr; }
  .admin-head { align-items: start; flex-direction: column; }
  .admin-head h1 { font-size: 30px; }
  .metrics { grid-template-columns: 1fr 1fr 1fr; }
  .metric { padding: 15px 10px; }
  .metric strong { font-size: 24px; }
  .filters { grid-template-columns: 1fr; }
  .response-table, .response-table tbody, .response-table tr, .response-table td { display: block; }
  .response-table thead { display: none; }
  .response-table tr { padding: 14px; border-bottom: 1px solid var(--line); }
  .response-table td { border: 0; padding: 5px 0; }
  .response-table td:nth-child(3), .response-table td:nth-child(5) { display: block; }
  .row-actions { min-width: 0; margin-top: 8px; }
  .compact { flex: 1 1 auto; }
  .modal { padding: 22px 18px; }
  .invite-link { flex-direction: column; }
  .invite-link input { min-height: 46px; }
}
