/* ============================================================
   录音豆 · 网页版
   一个豆子，两种颜色，一个快捷键，一个录音按钮。
   ============================================================ */

:root {
  /* 底色：极暗海军蓝，保留层次但不抢戏 */
  --bg: #070a14;
  --bg-lift: #0b1020;

  /* 文字 */
  --ink: #eff2fb;
  --ink-soft: rgba(239, 242, 251, 0.68);
  --ink-faint: rgba(239, 242, 251, 0.42);
  --line: rgba(255, 255, 255, 0.09);

  /* 两种识别色（取自豆子原图） */
  --cool: #2437f0;
  --cool-bright: #4c6dff;
  --warm: #f0203c;
  --warm-bright: #ff4d63;

  /* 豆子尺寸：桌面端足够成为视觉中心，小屏自动收 */
  --bean: clamp(248px, 37vh, 404px);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
}

/* ---------- 背景 ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.ambient__pool {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

.ambient__pool--cool {
  width: 78vmax;
  height: 78vmax;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%,
    rgba(46, 74, 255, 0.17) 0%,
    rgba(36, 55, 240, 0.07) 38%,
    transparent 68%);
}

.ambient__pool--deep {
  width: 62vmax;
  height: 62vmax;
  right: -14vmax;
  bottom: -22vmax;
  background: radial-gradient(circle at 50% 50%,
    rgba(96, 52, 190, 0.13) 0%,
    transparent 66%);
}

/* 录音时整场的环境光跟着豆子一起转暖，但不抢豆子 */
.ambient__pool--warm {
  width: 88vmax;
  height: 88vmax;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%,
    rgba(240, 32, 60, 0.13) 0%,
    rgba(160, 22, 44, 0.05) 40%,
    transparent 68%);
  opacity: 0;
  transition: opacity 0.85s var(--ease);
}

html[data-state="recording"] .ambient__pool--warm { opacity: 1; }

.ambient__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 68% 62% at 50% 42%,
    transparent 30%,
    rgba(3, 5, 11, 0.55) 78%,
    rgba(3, 5, 11, 0.82) 100%);
}

.ambient__grain {
  position: absolute;
  inset: -50%;
  opacity: 0.038;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  mix-blend-mode: overlay;
}

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

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 2.6vh, 26px) clamp(18px, 3vw, 40px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  opacity: 0.92;
}

.brand__mark {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(43, 64, 255, 0.45));
}

.brand__name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink-soft);
  font: 500 12.5px/1 inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.22s var(--ease), color 0.22s var(--ease),
    border-color 0.22s var(--ease), transform 0.22s var(--ease);
}

.chip-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--ink);
}

.chip-btn:active { transform: scale(0.97); }

.chip-btn__icon {
  width: 15px;
  height: 15px;
  opacity: 0.85;
}

/* ---------- 舞台 ---------- */

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 clamp(18px, 4vw, 40px);
  padding-bottom: clamp(6px, 1vh, 14px);
}

/* ---------- 豆子 ---------- */

.bean-area {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--bean) * 1.8);
  max-width: 100%;
  height: calc(var(--bean) * 1.25);
}

.bean-halo {
  position: absolute;
  width: calc(var(--bean) * 1.62);
  height: calc(var(--bean) * 1.62);
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0;
  transition: opacity 0.5s var(--ease), transform 0.35s var(--ease-out);
  will-change: transform, opacity;
}

.bean-halo--cool {
  background: radial-gradient(circle,
    rgba(58, 96, 255, 0.34) 0%,
    rgba(36, 55, 240, 0.16) 42%,
    transparent 70%);
  opacity: 1;
}

.bean-halo--warm {
  background: radial-gradient(circle,
    rgba(255, 70, 92, 0.36) 0%,
    rgba(240, 32, 60, 0.17) 42%,
    transparent 70%);
}

html[data-state="recording"] .bean-halo--cool { opacity: 0; }
html[data-state="recording"] .bean-halo--warm { opacity: 1; }

/* 接触阴影：只在豆子下方留一层极软的暗，不能看出“椭圆” */
.bean-contact {
  position: absolute;
  bottom: calc(var(--bean) * 0.03);
  width: calc(var(--bean) * 0.82);
  height: calc(var(--bean) * 0.1);
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(2, 4, 10, 0.5) 0%,
    rgba(2, 4, 10, 0.22) 34%,
    rgba(2, 4, 10, 0.06) 58%,
    transparent 76%);
  filter: blur(22px);
  opacity: 0.72;
  transition: opacity 0.4s var(--ease);
  will-change: transform, opacity;
}

.bean {
  position: relative;
  width: var(--bean);
  aspect-ratio: 714 / 617;
  will-change: transform;
  transform: translateZ(0);
}

.bean__layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.34s var(--ease);
  will-change: opacity;
}

.bean__layer--warm { opacity: 0; }

html[data-state="recording"] .bean__layer--cool { opacity: 0; }
html[data-state="recording"] .bean__layer--warm { opacity: 1; }

/* 一层极淡的高光扫过，让表面看起来是“上过釉”的 */
.bean__sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(104deg,
    transparent 32%,
    rgba(255, 255, 255, 0.26) 47%,
    rgba(255, 255, 255, 0.06) 54%,
    transparent 64%);
  -webkit-mask-image: url("assets/bean-blue.webp");
  mask-image: url("assets/bean-blue.webp");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: 0.5;
  animation: sheen 9s ease-in-out infinite;
}

@keyframes sheen {
  0%, 100% { transform: translateX(-6%) rotate(0.001deg); opacity: 0.34; }
  50% { transform: translateX(6%) rotate(0.001deg); opacity: 0.62; }
}

/* ---------- 「随音量灵动」--------- */

.vibe {
  margin: clamp(2px, 0.8vh, 12px) 0 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(12.5px, 1.65vh, 13.5px);
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  transition: color 0.5s var(--ease);
}

html[data-state="recording"] .vibe { color: rgba(255, 255, 255, 0.86); }

/* 四根小音量条：纯装饰，耍的是「它跟着声音起伏」这件事 */
.vibe__bars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.vibe__bars i {
  display: block;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--cool-bright);
  transform-origin: center;
  animation: bar 1.15s ease-in-out infinite;
  transition: background 0.5s var(--ease);
}

.vibe__bars i:nth-child(1) { animation-duration: 1.25s; animation-delay: -0.15s; }
.vibe__bars i:nth-child(2) { animation-duration: 0.95s; animation-delay: -0.55s; }
.vibe__bars i:nth-child(3) { animation-duration: 1.45s; animation-delay: -0.35s; }
.vibe__bars i:nth-child(4) { animation-duration: 1.05s; animation-delay: -0.75s; }

@keyframes bar {
  0%, 100% { transform: scaleY(0.34); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

html[data-state="recording"] .vibe__bars i { background: var(--warm-bright); }

/* ---------- 主按钮 ---------- */

.actions {
  margin-top: clamp(18px, 2.8vh, 30px);
}

.download-btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 232px;
  height: 58px;
  padding: 0 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, #4e6eff 0%, #2437f0 100%);
  color: #fff;
  font: 600 16px/1 inherit;
  letter-spacing: 0.06em;
  cursor: pointer;
  overflow: hidden;
  box-shadow:
    0 16px 36px -14px rgba(36, 55, 240, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.2s var(--ease-out), box-shadow 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

/* 红色态不是叠一层半透明（那样中途会变成紫色），
   而是从中间向两侧「扫开」，颜色始终是纯红，不会有发紫的过渡帧。 */
.download-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, #ff4d63 0%, #d81127 100%);
  clip-path: inset(0 50% 0 50%);
  transition: clip-path 0.46s var(--ease-out);
}

html[data-state="recording"] .download-btn {
  box-shadow:
    0 16px 38px -14px rgba(240, 32, 60, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.2);
}

html[data-state="recording"] .download-btn::before {
  clip-path: inset(0 0 0 0);
}

.download-btn:hover { transform: translateY(-1.5px); }

.download-btn:active { transform: translateY(0) scale(0.988); }

.download-btn:focus-visible {
  outline: 2px solid rgba(122, 152, 255, 0.85);
  outline-offset: 4px;
}

.download-btn__icon {
  width: 17px;
  height: 17px;
  opacity: 0.94;
  flex: none;
}

/* ---------- 快捷键提示 ---------- */

.keyhint {
  margin: clamp(12px, 2.2vh, 22px) 0 0;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: clamp(12px, 1.6vh, 12.5px);
  color: rgba(239, 242, 251, 0.52);
  letter-spacing: 0.03em;
}

.keyhint__keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.keyhint kbd,
.capture kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.085),
    rgba(255, 255, 255, 0.028));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.05);
  font: 500 11.5px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

.keyhint__plus {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.28);
}

/* ---------- 页脚 ---------- */

.footnote {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0 20px clamp(14px, 2.2vh, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: rgba(239, 242, 251, 0.34);
}

.footnote__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(76, 109, 255, 0.75);
  transition: background 0.5s var(--ease);
}

html[data-state="recording"] .footnote__dot { background: rgba(255, 77, 99, 0.85); }

/* ---------- 快捷键设置 ---------- */

.sheet {
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* 小屏上内容比视口高时要能滚，不能顶出去 */
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  border-radius: 18px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  color: var(--ink);
  background: linear-gradient(180deg, rgba(18, 23, 40, 0.96), rgba(11, 15, 27, 0.97));
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
}

.sheet::backdrop {
  background: rgba(4, 6, 12, 0.62);
  backdrop-filter: blur(3px);
}

.sheet[open] { animation: sheetIn 0.28s var(--ease-out); }

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.sheet__inner { padding: 20px 22px 16px; }

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--ink); }

.icon-btn:focus-visible {
  outline: 2px solid rgba(122, 152, 255, 0.8);
  outline-offset: 2px;
}
.icon-btn svg { width: 16px; height: 16px; }

.sheet__desc {
  margin: 14px 0 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.capture {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.22s, background 0.22s, box-shadow 0.22s;
}

.capture:hover { border-color: rgba(122, 152, 255, 0.4); }

.capture.is-armed {
  border-color: rgba(122, 152, 255, 0.7);
  border-style: solid;
  background: rgba(76, 109, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(76, 109, 255, 0.12);
}

.capture:focus-visible {
  outline: none;
  border-color: rgba(122, 152, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(76, 109, 255, 0.16);
}

.capture__keys {
  display: none;
  align-items: center;
  gap: 6px;
}

.capture.has-keys .capture__keys { display: inline-flex; }
.capture.has-keys .capture__placeholder { display: none; }

.capture__placeholder {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.capture__hint {
  font-size: 11px;
  color: rgba(239, 242, 251, 0.3);
}

.sheet__note {
  margin: 10px 0 0;
  min-height: 16px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #ff8391;
  letter-spacing: 0.02em;
}

.sheet__note.is-quiet { color: rgba(239, 242, 251, 0.36); }

.sheet__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 8px 2px;
  color: var(--ink-soft);
  font: 500 12.5px/1 inherit;
  cursor: pointer;
  transition: color 0.2s;
}

.text-btn:hover { color: var(--ink); }

.primary-btn {
  height: 36px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
  color: var(--ink);
  font: 600 13px/1 inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s;
}

.primary-btn:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.09)); }
.primary-btn:active { transform: scale(0.98); }

/* ---------- Agent 提示与兜底文本 ---------- */

.agent-note {
  margin: clamp(12px, 2vh, 18px) 0 0;
  padding: 0 12px;
  /* flex 子项默认按 max-content 撑宽，窄屏会顶出视口被裁掉，必须限死 */
  max-width: min(560px, 100%);
  font-size: clamp(11.5px, 1.5vh, 12.5px);
  /* 窄屏断行断在词中间很难看，交给浏览器均分两行 */
  text-wrap: balance;
  letter-spacing: 0.04em;
  color: rgba(239, 242, 251, 0.56);
  text-align: center;
  transition: color 0.3s var(--ease);
}

.agent-note.is-done { color: rgba(146, 180, 255, 0.92); }

.agent-fallback {
  display: none;
  width: min(620px, 100%);
  height: 168px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.45);
  color: rgba(239, 242, 251, 0.66);
  font: 400 10.5px/1.55 ui-monospace, Menlo, Consolas, monospace;
  resize: none;
}

.agent-fallback.is-shown { display: block; }

/* ---------- 异常状态 ---------- */

html[data-state="error"] .bean { filter: saturate(0.55) brightness(0.82); transition: filter 0.4s var(--ease); }
/* 下载按钮跟麦克风无关：异常态不去动它，别把主行动点弄成“禁用”的样子 */
html[data-state="error"] .download-btn {
  border-color: rgba(255, 255, 255, 0.12);
}

/* ---------- 自适应 ---------- */

/* 触屏设备：没有物理键盘，快捷键相关的界面元素整体退场。
   判断写在 JS 一处（html[data-pointer]），布局和文案不会各说各话。 */
html[data-pointer="coarse"] .keyhint { display: none; }
html[data-pointer="coarse"] .chip-btn { display: none; }
html[data-pointer="coarse"] .topbar { justify-content: flex-start; }

@media (max-width: 620px) {
  /* 手机上按屏宽收，别让豆子把左右留白吃干净 */
  :root { --bean: clamp(150px, 52vw, 224px); }
  .bean-area { width: calc(var(--bean) * 1.7); height: calc(var(--bean) * 1.2); }
  .download-btn { min-width: 210px; height: 54px; font-size: 15px; }
  .chip-btn__text { display: none; }
  .chip-btn { padding: 0 10px; }
}

@media (max-height: 620px) {
  :root { --bean: clamp(168px, 27vh, 246px); }
  .vibe { margin-top: 12px; }
  .actions { margin-top: 14px; }
  .keyhint { margin-top: 12px; }
}

@media (max-height: 480px) {
  body { overflow: auto; }
}

/* ---------- 设计评审 / 无过渡呈现 ---------- */

html.is-instant *,
html.is-instant *::before,
html.is-instant *::after {
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  animation-duration: 0s !important;
  animation-delay: 0s !important;
}

/* ---------- 尊重系统“减少动态效果” ---------- */

@media (prefers-reduced-motion: reduce) {
  .bean__sheen { animation: none; opacity: 0.4; }
  .vibe__bars i { animation: none; transform: scaleY(0.7); }
  .vibe__bars i:nth-child(2) { transform: scaleY(1); }
  .vibe__bars i:nth-child(4) { transform: scaleY(0.45); }
  .sheet[open] { animation: none; }
  *,
  *::before,
  *::after {
    transition-duration: 0.12s !important;
    animation-duration: 0.12s !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- 付费版新增 ---------- */

.footnote__link {
  color: rgba(146, 180, 255, 0.92);
  text-decoration: none;
  border-bottom: 1px solid rgba(146, 180, 255, 0.35);
  padding-bottom: 1px;
}
.footnote__link:hover { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.6); }

.download-btn:disabled { opacity: 0.72; cursor: progress; }

/* 未解锁时按钮是「买」，解锁后才是「复制」：图标跟着换，避免锁头配复制图标 */
.download-btn__icon--buy { display: none; }
.download-btn[data-mode="buy"] .download-btn__icon--copy { display: none; }
.download-btn[data-mode="buy"] .download-btn__icon--buy { display: inline; }
