:root {
  --bg:        #000000;
  --ink:       #ffffff;
  --ink-dim:   #7d7d7d;
  --ink-faint: #1a1a1a;
  --accent:    #fbbf24;
  --accent-hi: #fde68a;
  --accent-lo: rgba(251, 191, 36, 0.18);
  --rust:      #fb7185;

  --pad-l:  148px;
  --pad-r:  44px;
  --pad-t:  40px;
  --pad-b:  36px;
}

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

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "SF Pro Display", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
  font-weight: 500;
  font-size: 16px;
}
button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: inherit;
}

/* fine scan-line overlay (subtle, for HUD feel) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent 0px, transparent 2px,
    rgba(0,0,0,0.16) 3px, rgba(0,0,0,0.16) 4px
  );
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: multiply;
}

#app {
  position: relative;
  width: 600px;
  height: 600px;
  overflow: hidden;
}

/* ─────────── Screen base ─────────── */
.screen {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  display: flex;
  flex-direction: column;
  animation: screenIn 240ms ease-out;
  background: var(--bg);
}
.screen.hidden, .overlay.hidden, .hidden { display: none !important; }

@keyframes screenIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─────────── Buttons (the only borders in the app) ─────────── */
.btn {
  font-family: "SF Mono", "JetBrains Mono", "Menlo", ui-monospace, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.22em;
  padding: 18px 22px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease;
  text-transform: uppercase;
  flex: 1;
  white-space: nowrap;
}
.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.btn:hover:not(:disabled),
.btn.dpad-focus:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.wide { flex: none; width: 100%; }

/* ─────────── Page header (title + meta) ─────────── */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink);
  line-height: 1;
}
.page-meta {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─────────── Page actions row (bottom of screens) ─────────── */
.page-actions {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  gap: 10px;
}
.page-actions .btn { flex: 1; }
.page-actions.three .btn { flex: 1; padding-left: 8px; padding-right: 8px; font-size: 14px; }

/* ─────────── HOME ─────────── */
#home {
  justify-content: flex-start;
}
#home .page-head { margin-bottom: 6px; }
.brand-mark {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
  line-height: 1;
}
.brand-tag {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.36em;
  color: var(--accent);
  margin-top: 12px;
}
#home .brand-tag { display: none; }
#home .page-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
#home .page-head .brand-tag { display: block; }

.home-meta {
  font-family: "SF Mono", monospace;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  margin-bottom: auto;
  margin-top: 12px;
}
.home-meta .dot-sep {
  margin: 0 8px;
  color: var(--accent);
}
#home-count, #home-last {
  color: var(--ink);
  font-weight: 600;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
}

.bigbtn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 22px 24px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
  width: 100%;
}
.bigbtn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.bigbtn:hover, .bigbtn.dpad-focus {
  background: var(--accent) !important;
  color: var(--bg) !important;
  border-color: var(--accent) !important;
}
.bigbtn:active { transform: scale(0.985); }
.bb-label {
  font-family: "SF Mono", monospace;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
}
.bb-sub {
  font-family: "SF Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  opacity: 0.7;
}

.ghost-link {
  align-self: flex-start;
  font-family: "SF Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
  text-transform: uppercase;
}
.ghost-link:hover, .ghost-link.dpad-focus {
  color: var(--accent);
}

/* ─────────── RECORD ─────────── */
#record {
  padding-left: 40px;
  padding-right: 40px;
}

.rec-dot {
  width: 9px;
  height: 9px;
  background: var(--ink-dim);
  border-radius: 50%;
}
#record.recording .rec-dot {
  background: var(--rust);
  box-shadow: 0 0 10px var(--rust);
  animation: pulseDot 1.2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.rec-state {
  font-family: "SF Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.36em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.rec-transcript {
  flex: 1;
  font-size: 22px;
  line-height: 1.45;
  color: var(--ink);
  letter-spacing: 0.005em;
  font-weight: 500;
  overflow-y: auto;
  padding: 4px 6px 4px 0;
  font-family: "SF Pro Display", "Inter", system-ui, sans-serif;
  min-height: 0;
}
.rec-transcript::-webkit-scrollbar { width: 4px; }
.rec-transcript::-webkit-scrollbar-thumb { background: var(--ink-faint); }
.rec-placeholder {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 22px;
}
.interim {
  color: var(--accent);
  opacity: 0.85;
}

.rec-mic-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin: 18px 0 6px;
}

.viz-bars {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 60px;
  width: 130px;
  justify-content: center;
}
.viz-bars .bar {
  width: 5px;
  background: var(--ink-dim);
  height: 6px;
  transition: height 80ms ease, background 200ms ease;
  border-radius: 1px;
}
#record.recording .viz-bars .bar { background: var(--accent); }

.mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: transparent;
  position: relative;
  transition: all 200ms ease;
  flex-shrink: 0;
}
.mic-btn:hover, .mic-btn.dpad-focus {
  background: var(--accent);
  border-color: var(--accent);
}
.mic-btn:hover .mic-icon,
.mic-btn.dpad-focus .mic-icon {
  border-color: var(--bg);
  background: rgba(0,0,0,0.2);
}
.mic-btn:active { transform: scale(0.96); }

.mic-btn.recording {
  background: var(--rust);
  border-color: var(--rust);
}
.mic-btn.recording .mic-icon {
  background: var(--bg);
  border-radius: 4px;
  width: 22px; height: 22px;
  border: none;
}
.mic-btn.recording .mic-icon::after { display: none; }

.mic-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--rust);
  opacity: 0;
}
.mic-btn.recording .mic-pulse { animation: micRing 1.6s ease-out infinite; }
.mic-btn.recording .mic-pulse.pulse-2 { animation-delay: 0.8s; }
@keyframes micRing {
  0%   { transform: scale(0.9); opacity: 0.85; }
  100% { transform: scale(1.55); opacity: 0; }
}

.mic-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  width: 22px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: transparent;
  transition: all 160ms ease;
}
.mic-icon::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 9px;
  border: 2px solid var(--ink);
  border-top: none;
  border-radius: 0 0 11px 11px;
}
.mic-btn:hover .mic-icon::after,
.mic-btn.dpad-focus .mic-icon::after { border-color: var(--bg); }

/* ─────────── LIST ─────────── */
.riff-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  margin: 8px 0 12px;
  padding-right: 4px;
  min-height: 0;
}
.riff-list::-webkit-scrollbar { width: 4px; }
.riff-list::-webkit-scrollbar-thumb { background: var(--ink-faint); }

.riff-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 16px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-faint);
  cursor: pointer;
  transition: all 160ms ease;
  text-align: left;
  width: 100%;
  color: var(--ink);
}
.riff-item:last-child { border-bottom: none; }
.riff-item:hover, .riff-item.dpad-focus {
  background: var(--accent);
  color: var(--bg);
  padding-left: 14px;
  padding-right: 14px;
  border-bottom-color: transparent;
}
.ri-meta {
  display: flex;
  justify-content: space-between;
  font-family: "SF Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}
.riff-item:hover .ri-meta,
.riff-item.dpad-focus .ri-meta {
  color: rgba(0,0,0,0.7);
}
.ri-title {
  font-size: 19px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: 0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─────────── Empty state ─────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  text-align: left;
  padding: 20px 0;
}
.es-glyph {
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink-dim);
  position: relative;
  margin-bottom: 6px;
}
.es-glyph::after {
  content: '';
  position: absolute;
  inset: 18px;
  background: var(--ink-dim);
}
.es-title {
  font-family: "SF Mono", monospace;
  font-size: 22px;
  letter-spacing: 0.18em;
  color: var(--ink);
  font-weight: 800;
}
.es-body {
  font-size: 16px;
  color: var(--ink-dim);
  line-height: 1.55;
}

/* ─────────── DETAIL ─────────── */
.dm-eyebrow {
  font-family: "SF Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--accent);
  margin-bottom: 6px;
}
.dm-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: 0.005em;
  margin-bottom: 14px;
}
.detail-body {
  flex: 1;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  overflow-y: auto;
  padding: 4px 6px 4px 0;
  letter-spacing: 0.005em;
  white-space: pre-wrap;
  min-height: 0;
}
.detail-body::-webkit-scrollbar { width: 4px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--ink-faint); }

/* ─────────── WALKTHROUGH ─────────── */
#walkthrough {
  padding: 56px 56px 40px 56px;
  align-items: center;
  text-align: center;
}
.wt-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
}
.wt-corner.tl { top: 28px;    left: 28px;   border-right: none; border-bottom: none; }
.wt-corner.tr { top: 28px;    right: 28px;  border-left:  none; border-bottom: none; }
.wt-corner.bl { bottom: 28px; left: 28px;   border-right: none; border-top:    none; }
.wt-corner.br { bottom: 28px; right: 28px;  border-left:  none; border-top:    none; }

.wt-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  animation: stepIn 320ms ease-out;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wt-eyebrow {
  font-family: "SF Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.4em;
  color: var(--accent);
  margin-bottom: 4px;
}

.wt-glyph {
  width: 110px;
  height: 110px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wt-glyph::before {
  content: '';
  position: absolute;
  inset: -12px;
  border: 1px dashed var(--accent);
  border-radius: 50%;
  opacity: 0.5;
  animation: spin 22s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.g-pulse {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px var(--accent);
  animation: blinkMark 1.4s ease-in-out infinite;
}
@keyframes blinkMark {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
.g-ring {
  position: absolute;
  inset: 26px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.4;
}
.g-mic {
  display: block;
  width: 28px;
  height: 40px;
  border: 2px solid var(--accent);
  border-radius: 14px;
  position: relative;
}
.g-mic::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 10px;
  border: 2px solid var(--accent);
  border-top: none;
  border-radius: 0 0 14px 14px;
}
.g-save {
  width: 44px; height: 44px;
  border: 2px solid var(--accent);
  position: relative;
}
.g-save::before {
  content: '';
  position: absolute;
  top: -2px; left: 8px; right: 8px; height: 14px;
  background: var(--accent);
  opacity: 0.3;
  border-bottom: 2px solid var(--accent);
}
.g-save::after {
  content: '';
  position: absolute;
  bottom: 6px; left: 8px; right: 8px; height: 16px;
  border: 2px solid var(--accent);
}
.g-list {
  width: 44px; height: 44px;
  position: relative;
}
.g-list::before {
  content: '';
  position: absolute;
  top: 4px; left: 0; right: 0;
  height: 3px; background: var(--accent);
  box-shadow:
    0 11px 0 var(--accent),
    0 22px 0 var(--accent),
    0 33px 0 var(--accent);
}

.wt-title {
  font-family: "SF Mono", monospace;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ink);
  line-height: 1;
}
.wt-body {
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink);
  max-width: 360px;
  letter-spacing: 0.005em;
}
.wt-body em {
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}

.wt-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.wt-progress {
  display: flex;
  gap: 10px;
}
.wt-dot {
  width: 32px;
  height: 3px;
  background: var(--ink-faint);
  transition: all 220ms ease;
}
.wt-dot.active {
  background: var(--accent);
}
.wt-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

/* ─────────── Toast ─────────── */
.toast {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  font-family: "SF Mono", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.28em;
  padding: 14px 26px;
  z-index: 200;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─────────── Confirm overlay (no border on the card) ─────────── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 56px;
}
.confirm-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
  text-align: center;
}
.cc-eyebrow {
  font-family: "SF Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.4em;
  color: var(--accent);
}
.cc-msg {
  font-size: 22px;
  color: var(--ink);
  line-height: 1.5;
  font-weight: 600;
}
.cc-actions {
  display: flex;
  gap: 12px;
}

/* ─────────── Focusable focus state ─────────── */
.focusable:focus { outline: none; }
