/* ============================================================
   VibeRecs 设计系统
   原则：界面消失，内容出彩。画面里唯一的颜色来自电影海报。
   零渐变 · 零彩色块 · 阴影几乎不用 · 动效只有淡入与 8px 位移
   ============================================================ */

:root {
  /* 色 —— 只有纸白与四级墨色 */
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #111111;
  --ink-2: #6b6b6b;
  --ink-3: #9a9a9a;
  --line: #eaeaea;

  /* 字 */
  --serif: 'Noto Serif SC', 'Songti SC', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Inter, Arial, sans-serif;

  /* 字号阶梯 */
  --fs-micro: 11px;
  --fs-small: 12px;
  --fs-body: 14px;
  --fs-base: 16px;
  --fs-card: 18px;
  --fs-display: 28px;

  /* 间距阶梯 8 的倍数 */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-6: 48px;
  --sp-8: 64px;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --ease: cubic-bezier(0.16, 0.84, 0.44, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

/* ---------- 容器与屏切换 ---------- */

.app {
  position: relative;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-3) 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; }
body.state-ask .screen[data-screen='ask'],
body.state-rewriting .screen[data-screen='rewriting'],
body.state-result .screen[data-screen='result'] { display: flex; }

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
}

.brand {
  font-size: var(--fs-micro);
  letter-spacing: 0.2em;
  color: var(--ink-3);
  font-weight: 500;
}

.gear {
  position: relative;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: color 0.24s var(--ease);
}
.gear:active { color: var(--ink); }
.gear svg { width: 17px; height: 17px; }

.gear-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
  display: none;
}
.gear-dot.on { display: block; }

/* ---------- 屏 1 · 提问 ---------- */

.ask-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: var(--sp-8); }

.ask-title {
  font-family: var(--serif);
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.ask-hint {
  margin-top: var(--sp-1);
  font-size: var(--fs-small);
  color: var(--ink-3);
}

.field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  border-bottom: 1px solid var(--line);
  transition: border-color 0.24s var(--ease);
}
.field:focus-within { border-bottom-color: var(--ink); }

#mood-input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  padding: 12px 0;
  font-size: var(--fs-base);
}
#mood-input::placeholder { color: var(--ink-3); }

.submit {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: color 0.24s var(--ease), transform 0.24s var(--ease);
}
.submit.ready { color: var(--ink); }
.submit svg { width: 18px; height: 18px; }

.emoji-row {
  display: flex;
  gap: 10px;
  margin-top: var(--sp-3);
}

.emoji {
  flex: 1;
  aspect-ratio: 1;
  max-width: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 19px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: border-color 0.24s var(--ease);
}
.emoji:active { border-color: var(--ink-3); }

/* ---------- 屏 2 · 改写 ---------- */

.rewriting-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: var(--sp-8); }

.echo {
  font-size: var(--fs-small);
  color: var(--ink-3);
  min-height: 20px;
}

.axes { margin-top: var(--sp-3); border-top: 1px solid var(--line); }

.axis {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: var(--sp-2);
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.axis-label { font-size: var(--fs-small); color: var(--ink-3); }
.axis-value { font-size: var(--fs-base); min-height: 1.6em; }

.caret {
  display: inline-block;
  width: 1px;
  height: 1em;
  background: var(--ink-3);
  vertical-align: -0.15em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.rewriting-note { margin-top: var(--sp-3); font-size: var(--fs-small); color: var(--ink-3); }

/* ---------- 屏 3 · 片单 ---------- */

.result-head { padding: var(--sp-2) 0 var(--sp-3); }

.summary {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}

.summary-toggle {
  margin-top: 6px;
  font-size: var(--fs-small);
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}

.summary-detail {
  display: none;
  margin-top: var(--sp-2);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.summary-detail.on { display: block; }
.summary-detail pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-micro);
  color: var(--ink-2);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 双列网格：单元格约 165px 宽，2:3 海报高 247px，
   图与文字能同屏，一屏看两行 */
.cards {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4) 12px;
  align-content: start;
}

.card { display: flex; flex-direction: column; min-width: 0; }

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--line);
}

.card-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  margin-top: 10px;
  line-height: 1.4;
}
.card-sub {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: var(--fs-micro); color: var(--ink-3); margin-top: 5px; font-variant-numeric: tabular-nums; }
.card-reason {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 8px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.douban {
  display: inline-block;
  align-self: flex-start;
  margin-top: 10px;
  font-size: var(--fs-micro);
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
.douban:active { color: var(--ink); border-bottom-color: var(--ink-3); }

/* 微调条 */
.tune-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--sp-1);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.tune {
  flex: 1;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-2);
  transition: border-color 0.24s var(--ease), color 0.24s var(--ease);
}
.tune:active { border-color: var(--ink-3); color: var(--ink); }
.tune[disabled] { opacity: 0.4; }

.back-row { text-align: center; padding-bottom: var(--sp-1); }

.back {
  font-size: var(--fs-small);
  color: var(--ink-3);
  padding: 4px 0;
}

/* ---------- 通用：错误条 / 加载 / 弹层 ---------- */

.error-bar {
  display: none;
  margin: var(--sp-2) 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.7;
}
.error-bar.on { display: block; }

/* 「已放宽条件」是中性告知，不是错误，不该用左侧粗线这种警示强度 */
.error-bar.note {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 10px 0 0;
  font-size: var(--fs-small);
  color: var(--ink-3);
}

.loading {
  display: none;
  align-items: center;
  gap: 10px;
  padding: var(--sp-2) 0;
  font-size: var(--fs-small);
  color: var(--ink-3);
}
.loading.on { display: flex; }
.loading i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: pulse 1.2s var(--ease) infinite;
}
.loading i:nth-child(2) { animation-delay: 0.15s; }
.loading i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(250, 250, 250, 0.94);
  padding: var(--sp-3);
  overflow-y: auto;
}
.modal.on { display: block; }

.sheet {
  max-width: 430px;
  margin: 0 auto;
  padding-top: var(--sp-2);
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: var(--sp-3);
}
.sheet-title { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.sheet-close { font-size: var(--fs-small); color: var(--ink-3); }

.form-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.form-row label { display: block; font-size: var(--fs-small); color: var(--ink-3); }
.form-row input[type='text'],
.form-row input[type='password'] {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  padding: 6px 0 0;
  font-size: var(--fs-body);
}
.form-row .tip { font-size: var(--fs-micro); color: var(--ink-3); margin-top: 4px; }

.form-row.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.form-row.switch .copy label { margin-bottom: 2px; }

.save {
  width: 100%;
  height: 44px;
  margin-top: var(--sp-3);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  font-size: var(--fs-body);
}
.save:active { opacity: 0.85; }

.foot {
  padding: var(--sp-3) 0 var(--sp-2);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  text-align: center;
}

/* ---------- 动效：只有淡入 + 8px 位移 ---------- */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.fade-up { animation: fade-up 0.28s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  .fade-up, .loading i, .caret { animation: none; }
}

/* ---------- 桌面：极简手机框，便于汇报 ---------- */

@media (min-width: 768px) {
  body { padding: var(--sp-6) 0; }
  .app {
    max-width: 390px;
    min-height: 844px;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: var(--sp-3) var(--sp-3) 0;
  }
  .modal { position: absolute; border-radius: 24px; }
  .app { position: relative; }
}
