/*
 * 沿用「手写笔迹」官网的设计语言：暖白纸面 + 墨黑 + 柠檬绿点缀。
 * 墨黑只给「去做」的按钮；柠檬绿只做点缀。
 */
:root {
  --ink: #111111;
  --ink-press: #2a2a28;
  --graphite: #75756f;
  --pencil: #a9a9a2;
  --line: #e7e7e1;
  --canvas: #f4f4ef;
  --paper: #ffffff;
  --marker: #d4f53c;
  --lilac: #e4deff;
  --peach: #ffe3d3;
  --red: #e5484d;
  --wrap: 1200px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(var(--wrap), 100% - 64px); margin: 0 auto; }
.kicker { color: var(--graphite); font-size: 13px; font-weight: 600; letter-spacing: .04em; margin-bottom: 16px; }
mark {
  background: linear-gradient(transparent 62%, var(--marker) 62%, var(--marker) 92%, transparent 92%);
  color: inherit;
  padding: 0 .04em;
}

/* ---------- 按钮 ---------- */
.btn {
  align-items: center;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  font-size: 16px;
  font-weight: 700;
  gap: 10px;
  height: 52px;
  justify-content: center;
  padding: 0 28px;
  transition: transform .15s var(--ease), background-color .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink::before { background: var(--marker); border-radius: 50%; content: ""; height: 8px; width: 8px; }
.btn-ink:hover { background: var(--ink-press); }
.btn-line { border: 1px solid var(--line); background: var(--paper); }
.btn-line:hover { border-color: var(--pencil); }
.btn-sm { font-size: 14px; height: 40px; padding: 0 18px; }
.icon-btn { letter-spacing: .1em; padding: 0 14px; }
.link-btn { background: none; border: 0; color: var(--graphite); font-size: 14px; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--red); }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 244, 239, .86);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  padding-top: env(safe-area-inset-top);
}
.top-in { align-items: center; display: flex; gap: 16px; height: 68px; justify-content: space-between; }
.brand { align-items: center; display: flex; font-size: 17px; font-weight: 800; gap: 10px; letter-spacing: -.01em; }
.brand-mark {
  background: var(--ink);
  border-radius: 10px;
  color: var(--marker);
  display: grid;
  font-size: 15px;
  height: 30px;
  place-items: center;
  width: 30px;
}
.top-actions { display: flex; gap: 8px; }

/* ---------- 登录 ---------- */
.login { max-width: 520px; padding: 72px 0 112px; }
.login h1 { font-size: clamp(40px, 6vw, 64px); font-weight: 800; letter-spacing: -.04em; line-height: 1.08; }
.login-form { display: grid; gap: 16px; margin-top: 48px; }

.field { display: grid; gap: 8px; }
.field > span { color: var(--graphite); font-size: 14px; font-weight: 600; }
.field em { font-style: normal; font-weight: 400; color: var(--pencil); }
.field input, .field select, .field textarea, .side select {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px; /* 16px 以上 iOS 不会自动放大 */
  min-height: 52px;
  padding: 12px 16px;
  width: 100%;
  transition: border-color .15s ease;
}
.field textarea { line-height: 1.7; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; }
.form-msg { color: var(--red); font-size: 14px; min-height: 1.4em; }

/* ---------- 录音主界面 ---------- */
.app { align-items: start; display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 360px; padding: 24px 0 64px; }

.progress { margin-bottom: 20px; }
.progress-text { color: var(--graphite); font-size: 14px; margin-bottom: 10px; }
.progress-text b { color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.bar { background: var(--line); border-radius: 99px; height: 6px; overflow: hidden; }
.bar i { background: var(--ink); border-radius: 99px; display: block; height: 100%; transition: width .3s var(--ease); width: 0; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px;
  box-shadow: 0 1px 0 rgba(17, 17, 17, .04), 0 30px 60px -40px rgba(17, 17, 17, .25);
}
.card-head { align-items: center; display: flex; gap: 8px; }
.chip { background: var(--ink); border-radius: 999px; color: #fff; font-size: 12px; font-weight: 700; padding: 4px 12px; }
.chip.reply { background: var(--lilac); color: var(--ink); }
.chip-soft { background: var(--canvas); color: var(--graphite); }
.card-no { color: var(--pencil); font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 700; margin-left: auto; }
.hint { color: var(--graphite); font-size: 14px; margin-top: 28px; }
.zh { font-size: clamp(32px, 4.4vw, 52px); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-top: 8px; min-height: 2.4em; text-wrap: balance; }

.recorder { align-items: center; display: flex; flex-direction: column; gap: 14px; margin: 28px 0 8px; }
.meter { background: var(--canvas); border-radius: 99px; height: 6px; max-width: 280px; overflow: hidden; width: 100%; }
.meter i { background: var(--marker); display: block; height: 100%; transition: width .06s linear; width: 0; }
.meter i.hot { background: var(--red); }
.rec-btn {
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 8px var(--canvas), 0 18px 40px -16px rgba(17, 17, 17, .5);
  display: grid;
  height: 112px;
  place-items: center;
  touch-action: manipulation;
  transition: transform .15s var(--ease), background-color .2s ease;
  width: 112px;
}
.rec-btn:active { transform: scale(.95); }
.rec-btn span { background: var(--red); border-radius: 50%; height: 40px; transition: border-radius .2s var(--ease), width .2s var(--ease), height .2s var(--ease); width: 40px; }
.rec-btn.recording { animation: pulse 1.4s ease-in-out infinite; }
.rec-btn.recording span { border-radius: 8px; height: 34px; width: 34px; }
.rec-btn:disabled { opacity: .4; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 8px var(--canvas), 0 0 0 10px rgba(229, 72, 77, .0); }
  50% { box-shadow: 0 0 0 8px var(--canvas), 0 0 0 18px rgba(229, 72, 77, .25); }
}
.rec-state { color: var(--graphite); font-size: 15px; font-variant-numeric: tabular-nums; min-height: 1.6em; text-align: center; }
.rec-state.on { color: var(--red); font-weight: 700; }

.take { align-items: center; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px 16px; margin-top: 20px; padding-top: 20px; }
.take .btn { height: 44px; padding: 0 20px; }
.take-info { color: var(--graphite); flex: 1; font-size: 14px; }
.warn { background: var(--peach); border-radius: 12px; font-size: 14px; margin-top: 12px; padding: 10px 14px; }

.field-buyi { margin-top: 24px; }
.nav-row { display: flex; gap: 12px; margin-top: 28px; }
.nav-row .btn { flex: 1; }
.tips { color: var(--pencil); font-size: 13px; margin-top: 16px; text-align: center; }

/* ---------- 句子列表 ---------- */
.side {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100dvh - 100px);
  padding: 20px;
  position: sticky;
  top: 84px;
}
.side-head { align-items: center; display: flex; justify-content: space-between; }
.side-head h3 { font-size: 18px; font-weight: 800; }
.filters { background: var(--canvas); border-radius: 999px; display: flex; padding: 4px; }
.filters button { background: none; border: 0; border-radius: 999px; color: var(--graphite); flex: 1; font-size: 14px; font-weight: 600; height: 36px; }
.filters button.on { background: var(--paper); box-shadow: 0 2px 8px -4px rgba(17, 17, 17, .3); color: var(--ink); }
.side select { min-height: 44px; padding: 8px 12px; font-size: 15px; }
.list { margin: 0 -8px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.list li { align-items: center; border-radius: 12px; cursor: pointer; display: flex; gap: 12px; padding: 10px 8px; }
.list li:hover { background: var(--canvas); }
.list li.cur { background: var(--canvas); box-shadow: inset 3px 0 0 var(--ink); }
.list .no { color: var(--pencil); flex: none; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 700; width: 34px; }
.list .tx { flex: 1; font-size: 15px; line-height: 1.4; min-width: 0; }
.list .tx small { color: var(--pencil); display: block; font-size: 12px; }
.list .st { border: 1.5px solid var(--line); border-radius: 50%; flex: none; height: 18px; width: 18px; }
.list li.done .st { background: var(--marker); border-color: var(--marker); box-shadow: inset 0 0 0 3px var(--paper); }
.list .del { background: none; border: 0; color: var(--pencil); flex: none; font-size: 18px; line-height: 1; padding: 4px; }
.list .del:hover { color: var(--red); }
.list .empty { color: var(--pencil); cursor: default; font-size: 14px; justify-content: center; padding: 32px 0; }
.list .empty:hover { background: none; }

/* ---------- 弹层 ---------- */
.sheet {
  background: var(--paper);
  border: 0;
  border-radius: 28px;
  box-shadow: 0 30px 80px -20px rgba(17, 17, 17, .4);
  color: var(--ink);
  max-width: 440px;
  padding: 28px;
  width: calc(100% - 32px);
}
.sheet::backdrop { background: rgba(17, 17, 17, .35); }
.sheet h3 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.sheet form { display: grid; gap: 16px; }
.sheet form h3 { margin-bottom: 0; }
.sheet > .btn { margin-top: 16px; width: 100%; }
.menu-item {
  align-items: center;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  font-size: 16px;
  font-weight: 600;
  gap: 4px 10px;
  padding: 16px 0;
  text-align: left;
  width: 100%;
}
.menu-item small { color: var(--graphite); flex-basis: 100%; font-size: 13px; font-weight: 400; }
.menu-check input { accent-color: var(--ink); height: 20px; width: 20px; }

.scrim { background: rgba(17, 17, 17, .35); inset: 0; position: fixed; z-index: 20; }

.toast {
  background: var(--ink);
  border-radius: 999px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 12px 20px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 40;
}

.only-narrow { display: none; }

/* ---------- 窄屏（手机） ---------- */
@media (max-width: 960px) {
  .wrap { width: min(var(--wrap), 100% - 32px); }
  .only-narrow { display: inline-flex; }
  .only-wide { display: none; }
  .top-in { height: 60px; }
  .login { padding: 40px 0 72px; }
  .login-form { margin-top: 36px; }
  .app { display: block; padding: 12px 0 calc(32px + env(safe-area-inset-bottom)); }
  .card { border-radius: 24px; padding: 24px 20px; }
  .hint { margin-top: 20px; }
  .zh { font-size: clamp(28px, 8vw, 40px); min-height: 2.5em; }
  .recorder { margin-top: 20px; }
  .rec-btn { height: 100px; width: 100px; }
  .nav-row { margin-top: 24px; }

  .side {
    border-radius: 24px 24px 0 0;
    bottom: 0;
    left: 0;
    max-height: 82dvh;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    top: auto;
    transform: translateY(105%);
    transition: transform .3s var(--ease);
    z-index: 30;
  }
  .side.open { transform: none; }
  .list li { padding: 12px 8px; }
  .sheet { margin: auto auto calc(12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .card { padding: 20px 16px; }
  .btn { padding: 0 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
