/* ============================================================
   Vibe Lab · 样式
   设计语言：Claude 风格（暖米底 / 珊瑚橘 / 衬线标题）
   适配：MacBook 13"–16"、Retina、Safari，含深色模式
   ============================================================ */

/* ---------- 1. 令牌 ---------- */
:root {
  /* 亮色 */
  --paper: #FAF9F5;
  --paper-2: #F4F2EC;
  --card: #FFFFFF;
  --ink: #141413;
  --ink-2: #3C3B37;
  --muted: #83817A;
  --faint: #A9A79F;
  --line: rgba(20, 20, 19, .09);
  --line-2: rgba(20, 20, 19, .055);
  --coral: #D97757;
  --coral-ink: #B4573A;
  --coral-soft: rgba(217, 119, 87, .11);
  --blue: #6A9BCC;
  --green: #788C5D;
  --shadow-s: 0 1px 2px rgba(20, 20, 19, .04), 0 1px 1px rgba(20, 20, 19, .03);
  --shadow-m: 0 2px 6px rgba(20, 20, 19, .05), 0 12px 28px -12px rgba(20, 20, 19, .10);
  --shadow-l: 0 24px 60px -24px rgba(20, 20, 19, .22);

  /* 字体：优先 macOS 原生 */
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC',
          'Helvetica Neue', 'Microsoft YaHei', system-ui, sans-serif;
  --serif: 'Tiempos Text', 'Source Serif 4', Georgia, 'Songti SC',
           'Noto Serif SC', 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, 'JetBrains Mono', monospace;

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --r-xl: 22px;

  --maxw: 1240px;
  --rail: 344px;
  --gap: 26px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B1A18;
    --paper-2: #232220;
    --card: #262523;
    --ink: #F2F0EA;
    --ink-2: #D8D5CD;
    --muted: #9C9A93;
    --faint: #75736D;
    --line: rgba(255, 255, 255, .11);
    --line-2: rgba(255, 255, 255, .06);
    --coral: #E08A6A;
    --coral-ink: #F0A184;
    --coral-soft: rgba(224, 138, 106, .15);
    --blue: #86B0DA;
    --green: #94A877;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-m: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 28px -12px rgba(0, 0, 0, .5);
    --shadow-l: 0 24px 60px -24px rgba(0, 0, 0, .7);
  }
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -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.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
  overflow-x: hidden;
}

/* 顶部一层极淡的暖光，Retina 下更有质感 */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background:
    radial-gradient(900px 320px at 18% -12%, rgba(217, 119, 87, .10), transparent 70%),
    radial-gradient(700px 300px at 84% -18%, rgba(106, 155, 204, .09), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }

button, input { font-family: inherit; font-size: inherit; color: inherit; }

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

:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; border-radius: 4px; }

::selection { background: var(--coral-soft); }

/* 细滚动条，符合 macOS 观感 */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

.wrap { width: min(100% - 48px, var(--maxw)); margin-inline: auto; position: relative; z-index: 1; }

/* ---------- 3. 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  border-bottom: 1px solid var(--line-2);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar {
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 500; letter-spacing: .01em; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-soft);
}
.brand .sep { color: var(--faint); font-weight: 400; }
.brand .zh { color: var(--muted); font-weight: 400; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.only-narrow { display: none !important; }

/* ---------- 4. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform .12s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
  box-shadow: var(--shadow-s);
}
.btn:hover { background: var(--paper-2); border-color: var(--faint); }
.btn:active { transform: scale(.975); }

.btn-primary {
  background: var(--coral);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(180, 87, 58, .3), 0 6px 18px -8px rgba(217, 119, 87, .6);
}
.btn-primary:hover { background: var(--coral-ink); border-color: transparent; }

.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- 5. Hero ---------- */
.hero { padding: 72px 0 44px; max-width: 760px; }
.eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--coral);
  font-weight: 500;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.16;
  letter-spacing: -.02em;
  font-weight: 400;
}
.hero h1 em { font-style: italic; color: var(--coral); }
.hero .sub {
  margin: 20px 0 0;
  font-size: 16px;
  line-height: 1.75;
  color: var(--muted);
  max-width: 560px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

.kbd {
  align-self: center;
  flex: none;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--card);
  white-space: nowrap;
}

/* ---------- 6. 主布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  gap: var(--gap);
  align-items: start;
  padding-bottom: 60px;
}

.dims { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- 7. 维度卡片 ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-s);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: var(--shadow-m); border-color: var(--faint); }
.card.locked { border-color: color-mix(in srgb, var(--coral) 45%, var(--line)); }
.card.editing { border-style: dashed; }

.card-head { display: flex; gap: 11px; align-items: flex-start; }
.card-icon {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--coral-soft);
  color: var(--coral-ink);
  font-size: 13px;
  margin-top: 1px;
}
.card-titles { flex: 1; min-width: 0; }
.card-titles h3 {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  cursor: text;
  display: inline-block;
}
.card-titles h3:hover { color: var(--coral-ink); }
.card-titles p { margin: 2px 0 0; font-size: 12px; color: var(--faint); line-height: 1.5; }

.rename {
  width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--coral);
  border-radius: 6px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
}

.card-tools { display: flex; gap: 2px; flex: none; opacity: 0; transition: opacity .16s ease; }
.card:hover .card-tools, .card.locked .card-tools, .card.editing .card-tools { opacity: 1; }
@media (hover: none) { .card-tools { opacity: 1; } }
.tool {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1;
}
.tool:hover { background: var(--paper-2); color: var(--ink); }
.tool.active { background: var(--coral-soft); color: var(--coral-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .1s ease;
}
.chip:hover { background: var(--paper-2); border-color: var(--faint); }
.chip:active { transform: scale(.96); }
.chip.on {
  background: var(--coral-soft);
  border-color: color-mix(in srgb, var(--coral) 55%, transparent);
  color: var(--coral-ink);
  font-weight: 500;
}
.custom-chip { padding-right: 22px; }
.chip-x {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11px;
  color: var(--faint);
  line-height: 1;
}
.chip-x:hover { background: rgba(217, 119, 87, .22); color: var(--coral-ink); }
.chip .chip-x { position: static; transform: none; margin-right: 5px; }
.chip .chip-x:hover { background: rgba(217, 119, 87, .22); }

.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line-2); }
.mini {
  font-size: 12px;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px dashed var(--line);
}
.mini:hover { color: var(--coral-ink); border-color: var(--coral); background: var(--coral-soft); }

.custom-box { flex: 1; }
.custom-box input, .add-box input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--coral);
  border-radius: 8px;
  background: var(--paper);
  font-size: 16px; /* macOS Safari 不触发缩放 */
}
.add-box { flex: 1; }
.add-box input { border-color: var(--line); border-style: dashed; }
.add-box input:focus { border-color: var(--coral); border-style: solid; outline: none; }

.picked { margin-left: auto; font-size: 11.5px; color: var(--faint); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 8. 右侧配方栏 ---------- */
.rail { position: sticky; top: calc(var(--topbar-h) + 20px); }
.rail-inner {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-m);
}
.rail-inner h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -.01em;
  margin-bottom: 3px;
}
.rail-sub { margin: 0 0 15px; font-size: 12px; color: var(--faint); }

#recipe { display: flex; flex-direction: column; }
.rrow {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}
.rrow:last-child { border-bottom: 0; }
.ricon { color: var(--faint); font-size: 11px; text-align: center; }
.rname { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rval { color: var(--faint); font-weight: 500; max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rrow.filled .rname { color: var(--ink-2); }
.rrow.filled .rval { color: var(--coral-ink); }
.rlock { font-size: 10px; }

.meter { margin: 16px 0 14px; }
.meter-bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 0; background: var(--coral); border-radius: 4px; transition: width .3s cubic-bezier(.4, 0, .2, 1); }
.meter-text { display: block; margin-top: 7px; font-size: 11.5px; color: var(--faint); }

.rail-hint { margin: 12px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--faint); }

/* ---------- 9. 结果区 ---------- */
.result { padding: 12px 0 90px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}
.result-head h2 {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.result-head .slogan { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); font-style: italic; }

.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 10px; }
.tabs button {
  height: 30px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--muted);
  transition: background .16s ease, color .16s ease;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-s); font-weight: 500; }

.pane { max-width: 860px; }

.doc-lead {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 18px;
  padding-left: 18px;
  border-left: 2px solid var(--coral);
}
.doc-text { font-size: 15px; line-height: 1.85; color: var(--ink-2); margin: 0 0 30px; }
.doc-sec { margin-bottom: 32px; }
.doc-sec h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--coral);
  font-weight: 600;
  margin-bottom: 12px;
}
.sic { font-size: 13px; }
.doc-note { margin: -6px 0 12px; font-size: 12.5px; color: var(--faint); }

.doc-list { margin: 0; padding: 0; list-style: none; }
.doc-list li {
  position: relative;
  padding: 8px 0 8px 20px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
}
.doc-list li:last-child { border-bottom: 0; }
.doc-list li::before { content: ''; position: absolute; left: 4px; top: 17px; width: 5px; height: 5px; border-radius: 50%; background: var(--coral); opacity: .55; }

.doc-defs { margin: 0; display: grid; gap: 10px; }
.doc-defs > div { display: grid; grid-template-columns: 128px 1fr; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.doc-defs > div:last-child { border-bottom: 0; }
.doc-defs dt { font-family: var(--mono); font-size: 12px; color: var(--coral-ink); padding-top: 2px; }
.doc-defs dd { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ink-2); }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.swatch {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--card);
  font-size: 12.5px;
  line-height: 1.35;
}
.swatch .chipdot {
  grid-row: 1 / span 2;
  width: 18px; height: 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.swatch b { grid-column: 2; font-weight: 500; }
.swatch code {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  overflow-wrap: anywhere;
}

.doc-tree {
  margin: 0;
  padding: 16px 18px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-m);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--ink-2);
  overflow-x: auto;
  white-space: pre;
}

.doc-phases { margin: 0; padding: 0; list-style: none; counter-reset: ph; }
.doc-phases li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
}
.doc-phases li:last-child { border-bottom: 0; }
.doc-phases .when { font-family: var(--mono); font-size: 11.5px; color: var(--coral-ink); padding-top: 3px; }

/* 生成中 */
.gen { padding: 70px 0; text-align: center; }
.gen-dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 18px; }
.gen-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line);
  transition: background .3s ease, transform .3s ease;
}
.gen-dots span.on { background: var(--coral); transform: scale(1.25); }
#genStatus { margin: 0; font-size: 13.5px; color: var(--muted); font-family: var(--mono); }

.reveal { opacity: 0; animation: rise .5s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; }
  html { scroll-behavior: auto; }
}

/* Prompt 面板 */
#panePrompt pre {
  margin: 0;
  padding: 22px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-l);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow: auto;
}

.result-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

/* ---------- 10. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 14px);
  z-index: 100;
  padding: 10px 18px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  box-shadow: var(--shadow-l);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s cubic-bezier(.2, .8, .3, 1);
  max-width: min(90vw, 460px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 11. 页脚 ---------- */
.foot {
  border-top: 1px solid var(--line-2);
  padding: 26px 0 40px;
  font-size: 12px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* ============================================================
   12. MacBook 适配
   13" Air 1440×900 / 14" Pro 1512×982 / 16" Pro 1728×1117
   浏览器可视高度通常只有 700–950px，因此上方内容保持紧凑
   ============================================================ */

/* 13" MacBook Air：视口偏矮，压缩 hero */
@media (max-height: 800px) and (min-width: 1024px) {
  .hero { padding: 46px 0 32px; }
  .hero h1 { font-size: clamp(30px, 3.6vw, 42px); }
  .hero .sub { margin-top: 15px; font-size: 15px; }
  .hero-actions { margin-top: 20px; }
}

/* 14" 及以下（<=1512 逻辑像素）：栏宽收紧 */
@media (max-width: 1512px) {
  :root { --maxw: 1180px; --rail: 320px; --gap: 22px; }
}

/* 窄窗口 / 分屏（<=1180）：单列 + 顶栏常驻生成按钮 */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; gap: 20px; }
  .rail { position: static; order: -1; }
  .rail-inner { padding: 16px; }
  #recipe { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 20px; }
  .rrow { grid-template-columns: 16px 1fr auto; }
  .meter { margin: 14px 0 10px; }
  .only-narrow { display: inline-flex !important; }
}

@media (max-width: 900px) {
  .wrap { width: min(100% - 32px, var(--maxw)); }
  .dims { grid-template-columns: 1fr; }
  .hero { padding: 44px 0 30px; }
  .hero h1 { font-size: clamp(28px, 7vw, 38px); }
  .doc-defs > div { grid-template-columns: 1fr; gap: 3px; }
  .doc-phases li { grid-template-columns: 1fr; gap: 3px; }
  #recipe { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  #recipe { grid-template-columns: 1fr; }
  .brand .zh, .brand .sep { display: none; }
  .result-head { align-items: flex-start; }
  .pane { max-width: 100%; }
}

/* Retina：更细的描边更清晰 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card, .rail-inner, .btn { box-shadow: var(--shadow-s); }
  .doc-tree { border-color: var(--line); }
}

/* 打印 / 导出 PDF：macOS 上 ⌘P 直接得到干净文档 */
@media print {
  body::before, .topbar, .hero-actions, .rail, .dims, .tabs, .result-foot, .toast, .foot { display: none !important; }
  .result { padding: 0; }
  .result-head { border: 0; }
  .reveal { animation: none; opacity: 1; }
  body { background: #fff; }
  .pane { max-width: 100%; }
  .doc-sec { break-inside: avoid; }
}
