:root {
  --bg: #0f1115;
  --panel: #171a22;
  --panel-2: #1f2330;
  --line: #2a3040;
  --text: #e8ebf2;
  --text-2: #a3abbd;
  --text-3: #6b7387;
  --accent: #7c8cff;
  --accent-2: #a5b1ff;
  --rec: #ff4d5e;
  --ok: #4fd1a0;
  --warn: #f6ad55;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); min-height: 100%; }
body { font-size: 16px; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { opacity: 0.4; cursor: default; }
.hidden { display: none !important; }
svg { fill: currentColor; }

.view {
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--safe-b) + 28px);
}

/* ---- Top bar ---- */
.bar { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.sync-btn {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--panel-2); color: var(--text-2); font-size: 14px; font-weight: 600;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.sync-btn[data-state="ok"] .sync-dot { background: var(--ok); }
.sync-btn[data-state="syncing"] .sync-dot { background: var(--accent); animation: blink 0.9s infinite alternate; }
.sync-btn[data-state="error"] .sync-dot, .sync-btn[data-state="offline"] .sync-dot { background: var(--warn); }
.back-btn { display: flex; align-items: center; gap: 2px; color: var(--accent-2); font-size: 17px; font-weight: 500; height: 44px; margin-left: -6px; }
.back-btn svg { width: 26px; height: 26px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--text-3); margin-right: -10px; }
.icon-btn svg { width: 22px; height: 22px; }

/* ---- Home ---- */
.hero { display: flex; flex-direction: column; align-items: center; padding: 34px 0 30px; }
.hum-btn {
  width: 176px; height: 176px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 50% 35%, #ff6b79, var(--rec) 60%, #d63345);
  color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 0 0 10px rgba(255, 77, 94, 0.12), 0 0 0 22px rgba(255, 77, 94, 0.06), 0 14px 40px rgba(255, 77, 94, 0.35);
  transition: transform 0.12s;
}
.hum-btn:active { transform: scale(0.96); }
.hum-btn svg { width: 54px; height: 54px; }
.hint { color: var(--text-2); font-size: 15px; text-align: center; margin: 24px 0 0; }

.ideas h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 8px 4px 10px; }
#ideaList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.idea-row {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 14px; background: var(--panel);
}
.idea-row:active { background: var(--panel-2); }
.row-play {
  flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); position: relative;
}
.row-play::after {
  content: ""; position: absolute; left: 15px; top: 12px;
  border-left: 12px solid var(--accent-2); border-top: 7px solid transparent; border-bottom: 7px solid transparent;
}
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-cloud { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.row-cloud.done { background: var(--ok); opacity: 0.6; }
.empty { color: var(--text-3); text-align: center; font-size: 15px; margin-top: 8px; }

/* ---- Idea ---- */
.idea-name {
  width: 100%; margin: 4px 0 0; padding: 4px 0; border: 0; border-bottom: 1px solid transparent; background: none;
  font-size: 24px; font-weight: 700; letter-spacing: -0.01em; outline: none;
}
.idea-name:focus { border-bottom-color: var(--accent); }
.idea-meta { margin: 2px 0 14px; color: var(--text-2); font-size: 15px; }

.roll-wrap { height: 230px; border-radius: 14px; background: var(--panel); overflow: hidden; }
.roll-scroll { position: relative; height: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.roll-scroll::-webkit-scrollbar { display: none; }
#roll { display: block; }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.6); pointer-events: none; }

.play-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 8px; }
.play-btn {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #0f1115; box-shadow: 0 8px 24px rgba(124, 140, 255, 0.35);
}
.play-btn svg { width: 34px; height: 34px; }
.play-btn .i-stop, .play-btn.playing .i-play { display: none; }
.play-btn.playing .i-stop { display: block; }
.play-btn.loading { animation: pulse 0.8s infinite alternate; }
.pill-btn {
  height: 44px; padding: 0 20px; border-radius: 22px; background: var(--panel-2); color: var(--text);
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 10px;
}
.pill-btn.on { background: var(--text); color: var(--bg); }
.pill-btn.rec .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); }

.panel { margin-top: 22px; }
.panel h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 0 4px 10px; }
.small { color: var(--text-2); font-size: 14px; margin: 10px 4px 0; min-height: 1.2em; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--panel); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fact-label { color: var(--text-3); font-size: 12px; font-weight: 600; }
.fact-value { font-size: 17px; font-weight: 700; }
.fact-note { color: var(--text-2); font-size: 12px; line-height: 1.35; }
.bars { list-style: none; margin: 8px 0 0; padding: 4px 14px; background: var(--panel); border-radius: 12px; }
.bars li { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.bars li:last-child { border-bottom: 0; }
.bar-n { flex: none; width: 46px; color: var(--text-3); font-size: 13px; font-weight: 600; padding-top: 2px; }
.bar-notes { font-size: 16px; font-weight: 600; word-spacing: 0.15em; font-variant-numeric: tabular-nums; }

.sounds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sounds button {
  height: 48px; border-radius: 12px; background: var(--panel); font-size: 14px; font-weight: 600; color: var(--text-2);
  padding: 0 4px; line-height: 1.1;
}
.sounds button.on { background: var(--accent); color: #0f1115; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 40px; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.foot-row { display: flex; justify-content: center; margin-top: 30px; }

/* ---- Recording ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 20px) 16px calc(var(--safe-b) + 30px);
}
.close-btn { position: absolute; top: calc(var(--safe-t) + 10px); right: 12px; width: 44px; height: 44px; font-size: 32px; color: var(--text-3); }
.rec-label { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 17px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
.rec-blink { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); animation: blink 0.8s infinite alternate; }
.live-note { font-size: 84px; font-weight: 800; letter-spacing: -0.02em; margin: 24px 0 8px; min-height: 100px; }
.live-wrap { width: 100%; max-width: 520px; height: 150px; }
.done-btn {
  margin-top: 30px; width: 176px; height: 176px; border-radius: 50%; background: var(--panel-2);
  color: var(--text); font-size: 24px; font-weight: 700; box-shadow: inset 0 0 0 3px var(--rec);
}
.done-btn:active { transform: scale(0.96); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--panel-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
#busy p { color: var(--text-2); font-size: 17px; margin-top: 18px; }

/* ---- Sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%; max-width: 560px; background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(var(--safe-b) + 20px);
}
.sheet-card h2 { margin: 0 0 8px; font-size: 20px; }
.sheet-card p { color: var(--text-2); font-size: 15px; line-height: 1.45; margin: 0 0 14px; }
.sheet-card .warn { color: var(--warn); }
.sheet-card input {
  width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  padding: 0 14px; font-size: 17px; outline: none;
}
.sheet-card input:focus { border-color: var(--accent); }
.code-input { letter-spacing: 0.3em; font-size: 22px !important; text-align: center; font-variant-numeric: tabular-nums; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.google-btn {
  width: 100%; height: 52px; border-radius: 12px; background: #fff; color: #1f1f1f; font-size: 17px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.google-btn .g { font-weight: 800; font-size: 20px; color: #4285f4; }
.primary-btn { height: 46px; padding: 0 20px; border-radius: 12px; background: var(--accent); color: #0f1115; font-weight: 700; }
.ghost-btn { height: 46px; padding: 0 16px; border-radius: 12px; color: var(--text-2); font-weight: 600; }

/* ---- Toast ---- */
.toast {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 20px); width: calc(100% - 32px); max-width: 528px;
  background: #2b3142; color: var(--text); border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast span { flex: 1; }
.toast button { color: var(--accent-2); font-weight: 700; padding: 6px 4px; }

@keyframes blink { from { opacity: 1; } to { opacity: 0.3; } }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.6; } }
@keyframes spin { to { transform: rotate(360deg); } }
