/* Neiro app — Wonder design system (matches docs/index.html landing page).
   Mobile-first: layout is designed at 375px and relaxes upward. */

:root {
  --tab-bar-clearance: calc(64px + env(safe-area-inset-bottom, 0px));
  --bg: #09090B;
  --card: #121006;           /* dark-brown card base per Wonder spec */
  --card-hover: #131108;
  --surface: #111113;
  --border: #27272A;
  --border-soft: #1C1C1F;
  --amber: #F59E0B;
  --amber-bright: #FBBF24;
  --amber-dim: rgba(245, 158, 11, 0.08);
  --amber-line: rgba(245, 158, 11, 0.18);
  --text: #FAFAFA;
  --muted: #71717A;
  --faint: #3F3F46;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --tap: 44px;               /* minimum touch target */
}

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

/* The hidden attribute must always win — several panels use display:flex,
   which would otherwise override the UA's [hidden] rule and show every
   recorder state at once. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: rgba(245, 158, 11, 0.25); color: var(--text); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}
@keyframes breathe-glow {
  0%, 100% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.07), 0 10px 36px rgba(245, 158, 11, 0.18); }
  50% { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0.12), 0 14px 52px rgba(245, 158, 11, 0.3); }
}
@keyframes bar-dance {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Nav ── */

.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9, 9, 11, 0.9);
  border-bottom: 1px solid #18181B;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.nav-inner {
  max-width: 720px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 8px; height: 56px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--amber-dim); border: 1px solid rgba(245, 158, 11, 0.22);
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); font-family: var(--mono); }
.brand-sub { font-size: 11px; color: #52525B; font-family: var(--mono); }
.nav-spacer { flex: 1; }
.nav-links-wrap { display: flex; align-items: center; gap: 2px; }
.nav-link { font-size: 13px; color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.nav-link:hover { color: var(--text); background: var(--surface); }

/* ── Layout ── */

.main { max-width: 720px; margin: 0 auto; padding: 20px 16px calc(24px + var(--tab-bar-clearance)); }

/* ── Buttons ── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  border-radius: 10px; padding: 11px 18px; min-height: var(--tap);
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.2s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-amber { background: var(--amber); color: #0C0900; box-shadow: 0 4px 18px rgba(245, 158, 11, 0.18); }
.btn-amber:hover { background: var(--amber-bright); box-shadow: 0 6px 24px rgba(245, 158, 11, 0.3); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }
.btn-lang {
  background: transparent; color: var(--muted); border-color: var(--border);
  font-size: 12px; padding: 7px 12px; min-height: 36px; font-family: var(--mono);
}
.btn-lang:hover { color: var(--amber); border-color: var(--amber-line); }
.btn-install { font-size: 12px; padding: 8px 14px; min-height: 36px; }

/* ── Recorder card ── */

.recorder-card {
  background: var(--card);
  border: 1px solid var(--amber-line);
  border-radius: 20px;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
  margin-bottom: 36px;
  animation: fade-up 0.5s ease both;
  transition: border-color 0.3s;
  scroll-margin-top: 72px;
}
.recorder-card::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 65% at 50% -12%, rgba(245, 158, 11, 0.09) 0%, transparent 65%);
  transition: opacity 0.3s;
}
.recorder-card.is-recording { border-color: rgba(245, 158, 11, 0.4); }
.rec-panel { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }

.record-btn {
  position: relative;
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--amber); color: #0C0900; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  animation: breathe-glow 3.2s ease-in-out infinite;
  transition: background 0.15s, transform 0.12s;
  touch-action: manipulation;
}
.record-btn:hover { background: var(--amber-bright); transform: scale(1.05); }
.record-btn:active { transform: scale(0.94); }
.record-btn:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 4px; }
.rec-hint { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; text-align: center; }
.rec-subhint { font-size: 13px; color: var(--muted); text-align: center; }

/* recording state */
.wave-canvas { width: 100%; max-width: 420px; height: 76px; display: block; }
.countdown-row { display: flex; align-items: baseline; gap: 8px; }
.rec-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--amber);
  align-self: center; animation: pulse-dot 1.1s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.8);
}
.countdown { font-size: 44px; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; color: var(--amber); font-variant-numeric: tabular-nums; }
.countdown-unit { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.progress-track { width: 100%; max-width: 420px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--amber), var(--amber-bright));
  border-radius: 2px; transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}
.btn-stop { min-width: 160px; }

/* layer banner */
.layer-banner {
  position: relative;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(245, 158, 11, 0.06); border: 1px solid var(--amber-line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 20px;
  font-size: 13px; font-weight: 600;
  animation: fade-up 0.3s ease both;
}
.layer-banner-hint { font-size: 11px; color: var(--muted); font-weight: 400; width: 100%; }
.layer-cancel {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1; border-radius: 8px;
}
.layer-cancel:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

/* preview state */
.preview-label { font-size: 14px; color: var(--muted); text-align: center; }
.preview-play { min-width: 190px; }

.pitch-row { display: flex; align-items: center; gap: 10px; }
.pitch-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.btn-pitch {
  width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  font-size: 20px; font-weight: 500; border-radius: 50%;
}
.pitch-value {
  min-width: 44px; text-align: center;
  font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.pitch-unit { font-size: 11px; color: var(--faint); font-family: var(--mono); }

.title-input {
  width: 100%; max-width: 340px; min-height: var(--tap);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 15px; padding: 10px 14px;
  text-align: center; transition: border-color 0.15s, box-shadow 0.15s;
}
.title-input:focus { outline: none; border-color: var(--amber-line); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08); }
.title-input::placeholder { color: var(--faint); }
.preview-actions { display: flex; gap: 10px; width: 100%; max-width: 340px; }
.preview-actions .btn { flex: 1; }

/* mic denied */
.mic-denied { text-align: center; }
.mic-denied-title { font-size: 16px; font-weight: 700; }
.mic-denied-body { font-size: 13px; color: var(--muted); line-height: 1.8; max-width: 380px; }

/* ── Feed ── */

.feed-section { position: relative; scroll-margin-top: 72px; }
.feed-head {
  display: flex; align-items: baseline; gap: 12px;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid #18181B;
}
.feed-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.feed-sub { font-size: 12px; color: #52525B; font-family: var(--mono); }
.feed-empty { text-align: center; padding: 48px 0; color: var(--muted); font-size: 14px; line-height: 2; }
.feed-head-spacer { flex: 1; }
.feed-head .btn-lang { text-decoration: none; }

.btn-fav-filter {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-size: 12px; padding: 6px 12px; min-height: 32px; border-radius: 100px;
  font-family: var(--mono); cursor: pointer; touch-action: manipulation;
}
.btn-fav-filter:hover { color: var(--amber); border-color: var(--amber-line); }
.btn-fav-filter.is-active {
  color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line);
}

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

.post-card {
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 16px; padding: 16px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.25s;
  animation: fade-up 0.35s ease both;
}
.post-card:hover { border-color: rgba(245, 158, 11, 0.25); background: var(--card-hover); }
.post-card.is-playing {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.12), 0 8px 32px rgba(245, 158, 11, 0.07);
}

.post-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.post-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.post-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.post-title-row { display: flex; align-items: center; gap: 4px; }
.btn-edit-title {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; padding: 0;
  background: none; border: none; border-radius: 6px; color: var(--faint);
  cursor: pointer; touch-action: manipulation;
}
.btn-edit-title:hover { color: var(--amber); background: var(--amber-dim); }
.btn-favorite {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; padding: 0;
  background: none; border: none; border-radius: 6px; color: var(--faint);
  cursor: pointer; touch-action: manipulation;
}
.btn-favorite:hover { color: var(--amber); background: var(--amber-dim); }
.btn-favorite.is-active { color: var(--amber); }
.post-title-input {
  font-family: inherit; font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  width: 100%; min-width: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--amber-line); border-radius: 6px; padding: 2px 6px;
}
.post-title-input:focus { outline: none; border-color: var(--amber); }
.post-meta { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.post-lineage {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--amber); margin-top: 3px;
}
.post-playing-badge {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  background: var(--amber-dim); border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 100px; padding: 3px 9px;
  font-size: 9px; color: var(--amber); font-weight: 600; font-family: var(--mono);
}
.post-playing-badge .dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--amber);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.post-bars {
  display: flex; align-items: center; gap: 3px; height: 36px; margin-bottom: 14px;
  padding: 0 2px;
}
.post-bars .bar {
  flex: 1; background: rgba(245, 158, 11, 0.4); border-radius: 2px; min-height: 4px;
  transform-origin: center; transition: background 0.3s;
}
.post-card.is-playing .post-bars .bar {
  background: rgba(245, 158, 11, 0.85);
  animation: bar-dance 0.9s ease-in-out infinite;
}

.post-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-actions-spacer { flex: 1; }

.btn-play { background: var(--amber); color: #0C0900; padding: 10px 16px; }
.btn-play:hover { background: var(--amber-bright); }
.btn-play.is-active { background: var(--amber-bright); box-shadow: 0 0 16px rgba(245, 158, 11, 0.35); }

.btn-loop, .btn-layer {
  background: transparent; color: var(--muted); border-color: var(--border);
  padding: 10px 14px;
}
.btn-loop:hover, .btn-layer:hover { color: var(--amber); border-color: var(--amber-line); }
.btn-loop.is-active {
  color: var(--amber); background: var(--amber-dim); border-color: var(--amber-line);
  box-shadow: inset 0 0 12px rgba(245, 158, 11, 0.08);
}

.btn-delete {
  background: none; border: none; color: var(--faint); font-size: 12px; font-weight: 500;
  padding: 10px 8px; min-height: var(--tap);
}
.btn-delete:hover { color: var(--muted); }
.btn-delete.is-confirming { color: #EF4444; font-weight: 600; }

/* ── Footer ── */

.footer {
  border-top: 1px solid #18181B; padding: 28px 16px calc(28px + var(--tab-bar-clearance));
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.footer-link { font-size: 13px; color: var(--muted); text-decoration: none; padding: 8px 0; }
.footer-link:hover { color: var(--amber); }
.footer-note { font-size: 11px; color: var(--faint); font-family: var(--mono); }

/* ── Bottom tab bar ── */

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  display: flex;
  background: rgba(9, 9, 11, 0.92);
  border-top: 1px solid #18181B;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
  flex: 1; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tab-item.is-active { color: var(--amber); }
.tab-item:active { opacity: 0.7; }

/* ── Mobile (Wonder standard pattern) ── */

@media (max-width: 640px) {
  .nav-links-wrap { display: none !important; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  body { overflow-x: hidden; }
  .brand-sub { display: none; }
  .post-actions { gap: 6px; }
  .btn-play, .btn-loop, .btn-layer { padding: 10px 12px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .record-btn { animation: none; }
  .post-card.is-playing .post-bars .bar { animation: none; }
}
