/* ============================================================
   目标行动指南 · 纸张
   浅色、单列、衬线、无圆角、无阴影
   ============================================================ */

:root {
  --paper: #faf7f0;
  --panel: #f4f0e6;
  --panel-hi: #efe9db;
  --line: #e3ddd0;
  --line-soft: #ece7db;
  --ink: #2e2a24;
  --sub: #6f685c;
  --faint: #a8a193;
  --ochre: #b5654a;
  --ochre-deep: #a04b2e;
  --link: #8a5a3b;

  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --kb: 0px;
  --wrap: 640px;
  --pad: 20px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.is-fixed {
  overflow: hidden;
}

::selection {
  background: #e8dbc9;
  color: var(--ink);
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  outline: none;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}

input:focus-visible,
textarea:focus-visible {
  outline: none;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 100px var(--paper) inset;
  transition: background-color 9999s ease-out;
}

:focus-visible {
  outline: 1px solid var(--ochre);
  outline-offset: 3px;
}

hr.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

/* ---------------- 通用小件 ---------------- */

.ghost-btn {
  font-size: 12px;
  color: var(--sub);
  letter-spacing: 0.02em;
  padding: 8px 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ghost-btn:hover { color: var(--ink); }
.ghost-btn:disabled { color: var(--faint); cursor: default; }

.head-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.plain-btn {
  font-size: 13px;
  color: var(--link);
  min-height: 44px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
}
.plain-btn:hover { text-decoration: underline; }
.plain-btn:disabled { color: var(--faint); text-decoration: none; cursor: default; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--pad);
}

#view { display: contents; }

.goalview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

/* ============================================================
   登录
   ============================================================ */

#app[data-view="login"] {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--pad) 12vh;
}

.login-box {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.login-box h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  margin: 0 0 30px;
  letter-spacing: 0.02em;
}

.login-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  transition: border-color 0.15s;
}
.login-field:focus-within { border-color: var(--ink); }

.login-box input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 8px 0;
  letter-spacing: 0.1em;
}

.login-box button {
  font-size: 13px;
  color: var(--link);
  min-height: 44px;
  padding: 0 4px 0 12px;
}

.login-note {
  font-size: 12px;
  color: var(--faint);
  margin-top: 22px;
}

.login-error {
  font-size: 12px;
  color: var(--ochre-deep);
  margin-top: 14px;
  min-height: 18px;
}

/* ---- 登录 / 注册 切换 ---- */

.login-tabs {
  display: flex;
  gap: 20px;
  margin: 0 0 26px;
}

.login-tab {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--faint);
  padding: 0 0 6px;
  border-bottom: 1px solid transparent;
  transition: color 0.14s, border-color 0.14s;
}
.login-tab.is-on {
  color: var(--ink);
  border-bottom-color: var(--ochre);
}

.login-form .login-field + .login-field {
  margin-top: 4px;
}

.login-field input::placeholder {
  color: var(--faint);
  letter-spacing: 0;
}

/* 验证码那行：输入框 + 右侧「获取验证码」 */
.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  transition: border-color 0.15s;
}
.code-row:focus-within { border-color: var(--ink); }

.code-row input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 8px 0;
  letter-spacing: 0.24em;
}

.code-row input::placeholder {
  letter-spacing: 0;
}

.code-btn {
  flex: none;
  font-size: 12.5px;
  color: var(--link);
  min-height: 40px;
  padding: 0 2px 0 10px;
  white-space: nowrap;
}
.code-btn:disabled { color: var(--faint); cursor: default; }

.login-submit {
  width: 100%;
  margin-top: 26px;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid var(--line-strong, #d2c9b6);
  padding: 13px 0;
  min-height: 46px;
  border-radius: 2px;
  transition: background 0.14s, border-color 0.14s;
}
.login-submit:hover { background: var(--panel); }
.login-submit:disabled { color: var(--faint); background: none; cursor: default; }

.login-alt {
  display: flex;
  gap: 18px;
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--faint);
}
.login-alt button { color: var(--sub); min-height: 32px; }
.login-alt button:hover { color: var(--ink); }

/* ============================================================
   首页 · 目标列表
   ============================================================ */

#app[data-view="list"] {
  min-height: 100dvh;
  padding-bottom: 80px;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 34px 0 0;
  margin-bottom: 30px;
}

.list-head .brand {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--sub);
  letter-spacing: 0.04em;
}

.new-goal {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 2px 0 10px;
  margin-bottom: 34px;
  transition: border-color 0.15s;
}
.new-goal:focus-within { border-color: var(--ink); }

.new-goal input {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 18px;
  padding: 6px 0;
}
.new-goal input::placeholder { color: var(--faint); }

.new-goal button {
  font-size: 12px;
  color: var(--link);
  min-height: 44px;
  padding: 0 4px;
}
.new-goal button:disabled { color: var(--faint); }

.empty-note {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--sub);
  line-height: 1.9;
  margin-bottom: 20px;
}

.goal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.goal-item {
  border-bottom: 1px solid var(--line-soft);
}

.goal-item > a {
  display: block;
  padding: 17px 0 16px;
  color: inherit;
}
.goal-item > a:hover { text-decoration: none; }
.goal-item > a:hover .goal-title { color: var(--ochre-deep); }

.goal-title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  transition: color 0.12s;
  word-break: break-word;
}

.goal-meta {
  font-size: 12px;
  color: var(--faint);
  margin-top: 5px;
  letter-spacing: 0.01em;
}

.goal-warn {
  font-size: 12px;
  color: var(--sub);
  margin-top: 3px;
  opacity: 0.85;
}

.archived-toggle {
  margin-top: 34px;
  font-size: 12px;
  color: var(--faint);
  min-height: 44px;
  text-align: left;
}

.list-foot {
  margin-top: 46px;
  font-size: 12px;
  color: var(--faint);
  display: flex;
  gap: 18px;
}

/* ============================================================
   目标页
   ============================================================ */

#app[data-view="goal"] {
  height: calc(100dvh - var(--kb));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--line);
  transition: height 0.18s ease;
  background: var(--paper);
  z-index: 5;
}
.topbar.compact { height: 46px; }

.topbar .inner {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  flex: none;
  margin-left: -10px;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn:last-child { margin: 0 -10px 0 0; }

.goal-name {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
  padding: 6px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.goal-name-input {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 17px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.timeline-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.timeline {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 18px var(--pad) 28px;
}

.load-earlier {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  padding: 18px 0 8px;
  min-height: 44px;
}
.load-earlier:hover { color: var(--sub); }

/* ---------------- 记录 ---------------- */

.rec {
  padding: 15px 0 14px;
}

.rec-time {
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.rec-time .day { color: var(--faint); }

.rec-body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}
.rec-body p { margin: 0 0 0.9em; }
.rec-body p:last-child { margin-bottom: 0; }

.rec.deleted .rec-body {
  color: var(--faint);
  font-size: 14px;
  font-style: normal;
  font-family: var(--sans);
}

.rec.enter {
  animation: rise 0.16s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 讨论卡片 ---------------- */

.card {
  margin: 16px 0 18px;
  border-left: 2px solid var(--ochre);
  background: var(--panel);
  padding: 11px 16px 12px;
  cursor: pointer;
}

.card.is-open {
  cursor: default;
  padding-bottom: 16px;
}

.card[data-streaming="1"] {
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .card[data-streaming="1"] { animation: none; }
  .rec.enter { animation: none; }
}

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

.card-label {
  font-size: 11px;
  color: var(--ochre);
  letter-spacing: 0.08em;
}

.card-meta {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-summary {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.is-open .card-summary { display: none; }

.card-tag {
  font-size: 11px;
  color: var(--faint);
  margin-left: 6px;
}

.card-body { display: none; }
.card.is-open .card-body { display: block; }

.msg {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
}
.msg:last-child { margin-bottom: 0; }

.msg-user {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--sub);
  border-top: 1px solid var(--line);
  padding-top: 13px;
  margin-top: 16px;
}
.msg-user::before {
  content: "你：";
  color: var(--faint);
}

.card-error {
  font-size: 13px;
  color: var(--ochre-deep);
  line-height: 1.6;
}

.card-loading {
  font-size: 13px;
  color: var(--faint);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.card-actions button {
  font-size: 12px;
  color: var(--sub);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.card-actions button:hover { color: var(--ink); }
.card-actions button:disabled { color: var(--faint); cursor: default; }
.card-actions .danger:hover { color: var(--ochre-deep); }

.followup {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.followup textarea {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  padding: 6px 0;
  resize: none;
  max-height: 120px;
  color: var(--ink);
}
.followup textarea::placeholder { color: var(--faint); }

.followup button {
  font-size: 13px;
  color: var(--link);
  min-height: 44px;
  padding: 0 4px;
  flex: none;
}
.followup button:disabled { color: var(--faint); }

.thread-full {
  font-size: 12px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

/* ---------------- 输入区 ---------------- */

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
}

.composer .inner {
  max-width: var(--wrap);
  margin: 0 auto;
}

.chips-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.chip {
  font-size: 12px;
  color: var(--sub);
  padding: 7px 10px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 2px;
  line-height: 1;
  transition: border-color 0.12s, color 0.12s, background-color 0.12s;
}
.chip:hover { border-color: #d2c9b6; color: var(--ink); }
.chip:active { background: var(--panel); }

.ask-btn {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ochre-deep);
  min-height: 34px;
  padding: 7px 0 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.12s;
}
.ask-btn:hover { border-bottom-color: #d9c3b4; text-decoration: none; }
.ask-btn:disabled { color: var(--faint); border-bottom-color: transparent; cursor: default; }
.ask-btn .hint { font-size: 11px; color: var(--faint); }

.field {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 9px 12px;
  transition: border-color 0.14s;
}
.field:focus-within { border-color: #d5c9b2; }

.field textarea {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.75;
  padding: 2px 0;
  resize: none;
  max-height: 40vh;
  color: var(--ink);
}
.field textarea::placeholder { color: #9c9487; }

.field .send {
  font-size: 13px;
  color: var(--link);
  min-height: 32px;
  padding: 0 0 2px 8px;
  flex: none;
  align-self: flex-end;
}
.field .send:disabled { color: var(--faint); cursor: default; }

.offline-bar {
  font-size: 12px;
  color: var(--ochre-deep);
  background: #f6ebdd;
  text-align: center;
  padding: 6px 12px;
  flex: none;
}

.update-bar {
  font-size: 12px;
  color: var(--sub);
  background: var(--panel-hi);
  text-align: center;
  padding: 7px 12px;
  flex: none;
}
.update-bar button {
  color: var(--link);
  text-decoration: underline;
  margin-left: 8px;
  min-height: 24px;
}

/* ---------------- 目标页空态 ---------------- */

.goal-empty {
  margin-top: 26vh;
  text-align: left;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.95;
  color: var(--sub);
}
.goal-empty .q {
  color: var(--faint);
  font-size: 13px;
  margin-top: 14px;
  font-family: var(--sans);
}

/* ============================================================
   导出页
   ============================================================ */

#app[data-view="export"] {
  min-height: 100dvh;
  padding: 34px 0 80px;
}

.page-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  margin: 0 0 28px;
}

.export-item {
  border-bottom: 1px solid var(--line-soft);
  padding: 16px 0;
}
.export-item a {
  font-family: var(--serif);
  font-size: 16px;
}
.export-desc {
  font-size: 12px;
  color: var(--faint);
  margin-top: 4px;
}

.usage {
  margin-top: 40px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.9;
}

/* ============================================================
   菜单 / 弹层
   ============================================================ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 42, 36, 0.18);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  animation: sheet-in 0.16s ease-out;
}

@keyframes sheet-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 15px 22px;
  font-size: 15px;
  min-height: 50px;
}
.sheet button:hover { background: var(--panel); }
.sheet button.danger { color: var(--ochre-deep); }
.sheet .cancel {
  border-top: 1px solid var(--line);
  color: var(--sub);
  text-align: center;
  margin-top: 6px;
}

@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet {
    border: 1px solid var(--line);
    border-radius: 2px;
    padding-bottom: 8px;
  }
}

.confirm-box {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 22px;
}
.confirm-box p {
  font-size: 14px;
  color: var(--sub);
  margin: 0 0 14px;
  line-height: 1.7;
}
.confirm-box input {
  width: 100%;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  padding: 8px 0;
  margin-bottom: 18px;
}
.confirm-box .row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.confirm-box .row button {
  font-size: 13px;
  padding: 10px 14px;
  min-height: 44px;
  color: var(--sub);
}
.confirm-box .row .primary { color: var(--ochre-deep); }

.snack {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #3a352c;
  color: #f6f2e8;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 2px;
  z-index: 80;
  animation: rise 0.16s ease-out;
  max-width: calc(100vw - 40px);
  text-align: center;
}

body.is-fixed .snack {
  bottom: calc(104px + env(safe-area-inset-bottom));
}

/* ============================================================
   响应式
   ============================================================ */

@media (min-width: 600px) {
  :root { --pad: 32px; }
}

@media (min-width: 900px) {
  :root { --pad: 24px; }
  #app[data-view="goal"] {
    height: 100dvh;
  }
  .timeline { padding-top: 14px; }
}

@media (max-width: 480px) {
  .chip { padding: 7px 9px; font-size: 11.5px; }
  .ask-btn .hint { display: none; }
  .ask-btn { padding-left: 8px; }
}
