:root {
  --bg-void: #0a0912;
  --bg-panel: #15121f;
  --bg-panel-alt: #1c1830;
  --bg-panel-raised: #221d38;
  --line-soft: #2c2745;
  --pudding-dark: #3d2717;
  --pudding-mid: #6b4a30;
  --pudding-cream: #ecd9b8;
  --accent-lav: #a99bef;
  --accent-lav-dim: #6f63a8;
  --accent-caramel: #e0a55c;
  --text-hi: #f2eefc;
  --text-mid: #b8b0d4;
  --text-dim: #746c96;
  --danger: #e0685c;
  --success: #7fd9a0;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-void);
  color: var(--text-hi);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
}

button, input {
  font-family: inherit;
}

svg.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
svg.icon-lg { width: 30px; height: 30px; }

.stars-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1.5px 1.5px at 20px 30px, rgba(255,255,255,.5), transparent),
    radial-gradient(1.5px 1.5px at 300px 90px, rgba(255,255,255,.35), transparent),
    radial-gradient(1px 1px at 130px 200px, rgba(255,255,255,.4), transparent),
    radial-gradient(1.5px 1.5px at 420px 260px, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 550px 60px, rgba(255,255,255,.45), transparent),
    radial-gradient(1.5px 1.5px at 700px 320px, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 850px 150px, rgba(255,255,255,.4), transparent),
    radial-gradient(1.5px 1.5px at 950px 400px, rgba(255,255,255,.3), transparent),
    linear-gradient(180deg, #0a0912 0%, #120f1d 60%, #0a0912 100%);
  background-repeat: repeat;
  background-size: 1000px 500px;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(21, 18, 31, .7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  fill: var(--accent-lav-dim);
}
.brand-text h1 {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text-hi);
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.mode-tabs {
  display: flex;
  gap: 4px;
  margin-left: 12px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 4px;
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.mode-tab:hover { color: var(--text-hi); }
.mode-tab.is-active {
  background: var(--accent-lav);
  color: #1a1730;
}

.icon-btn {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: var(--bg-panel-alt);
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .2s, transform .4s;
}
.icon-btn:hover { color: var(--accent-lav); }
.icon-btn:active { transform: rotate(35deg); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  padding: 22px 28px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.mascot-panel {
  background: linear-gradient(180deg, var(--bg-panel-raised), var(--bg-panel));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mascot-stage {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mascot-glow {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(169,155,239,.35), transparent 70%);
  filter: blur(6px);
  transition: opacity .4s;
  opacity: .4;
}
.mascot-svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  transition: transform .3s;
}
.mascot-drip { transform-origin: center; }
.drop { animation: none; opacity: .9; }
.eye-glint { opacity: .9; }
.mouth { }

.wave-ring {
  position: absolute;
  inset: -14px;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}

.mascot-status {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-mid);
  text-align: center;
}

.app.is-recording .mascot-glow,
.mascot-panel.is-recording .mascot-glow { opacity: 1; }

.mascot-stage.state-recording .mascot-svg { animation: bob 1.8s ease-in-out infinite; }
.mascot-stage.state-recording .mascot-glow { opacity: 1; }
.mascot-stage.state-recording .wave-ring { opacity: 1; }
.mascot-stage.state-recording .eye { animation: blink 4.5s infinite; }

.mascot-stage.state-processing .mascot-svg { animation: sway 1.2s ease-in-out infinite; }
.mascot-stage.state-processing .mascot-glow { opacity: .8; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-1.5deg); }
}
@keyframes sway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 14px;
}
.hud-item:last-child { grid-column: 1 / -1; }
.hud-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud-label {
  font-size: 11px;
  color: var(--text-dim);
}
.hud-value {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-caramel);
  font-variant-numeric: tabular-nums;
}
.hud-value--small { font-size: 13px; color: var(--accent-lav); }

.history {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-head h2 {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  color: var(--text-mid);
}
.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 4px;
}
.text-btn:hover { color: var(--danger); }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.history-empty {
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 0;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-alt);
  cursor: pointer;
  border: 1px solid transparent;
}
.history-item:hover { border-color: var(--accent-lav-dim); }
.history-item-main {
  flex: 1;
  min-width: 0;
}
.history-item-title {
  font-size: 12.5px;
  color: var(--text-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 10.5px;
  color: var(--text-dim);
}
.history-item-del {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.history-item-del:hover { color: var(--danger); }

.workspace {
  display: flex;
  min-width: 0;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 640px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--text-dim);
}
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-hi);
  font-size: 13px;
}
.search-count {
  font-size: 11px;
  color: var(--text-dim);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}
.toolbar-actions--file { justify-content: flex-end; }

.ghost-btn {
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
  color: var(--text-mid);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.ghost-btn:hover { border-color: var(--accent-lav-dim); color: var(--text-hi); }

.transcript {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  line-height: 1.9;
  font-size: 15.5px;
  color: var(--text-hi);
  max-width: 78ch;
  width: 100%;
  margin: 0 auto;
}
.transcript--file { max-width: none; }
.transcript-placeholder {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.8;
}
.transcript mark {
  background: var(--accent-caramel);
  color: #241703;
  border-radius: 3px;
  padding: 0 2px;
}
.transcript .seg-time {
  color: var(--accent-lav);
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 4px;
  position: relative;
}

.record-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: var(--accent-lav);
  color: #1a1730;
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 13px 22px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(169,155,239,.25);
  transition: transform .15s, box-shadow .15s, background .2s;
  white-space: nowrap;
}
.record-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(169,155,239,.35); }
.record-btn:active { transform: translateY(0); }
.record-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.record-btn--wide { align-self: flex-start; }

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a1730;
}

.record-btn.is-recording {
  background: var(--danger);
  color: #2a0e0b;
  box-shadow: 0 6px 20px rgba(224,104,92,.35);
}
.record-btn.is-recording .record-dot {
  background: #2a0e0b;
  animation: pulse-dot 1.1s infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .6; }
}

.timer {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
}

.waveform {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
}

.reconnect-badge {
  display: none;
  font-size: 11px;
  color: var(--accent-caramel);
  background: rgba(224,165,92,.12);
  border: 1px solid rgba(224,165,92,.4);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.reconnect-badge.is-visible { display: inline-block; }

.file-intro h2 {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 17px;
  margin: 0 0 8px;
}
.file-intro p {
  font-size: 13.5px;
  color: var(--text-mid);
  line-height: 1.8;
  max-width: 70ch;
  margin: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px dashed var(--line-soft);
  border-radius: var(--radius-md);
  padding: 32px;
  color: var(--text-mid);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg-panel-alt);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent-lav);
  background: rgba(169,155,239,.06);
}
.dropzone-title { font-size: 14px; color: var(--text-hi); }
.dropzone-sub { font-size: 12px; color: var(--text-dim); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 12, .7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  width: 380px;
  max-width: 90vw;
  background: var(--bg-panel-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.modal h2 {
  font-family: "Zen Maru Gothic", sans-serif;
  margin: 0 0 16px;
  font-size: 17px;
}
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.text-input {
  width: 100%;
  background: var(--bg-panel-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-hi);
  font-size: 14px;
  outline: none;
}
.text-input:focus { border-color: var(--accent-lav-dim); }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-mid);
  margin-top: 12px;
}
.modal-note {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-top: 14px;
}
.modal-note a { color: var(--accent-lav); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line-soft);
  color: var(--text-hi);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: 90vw;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.is-error { border-color: var(--danger); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

.site-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0 18px;
  letter-spacing: .04em;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .brand-text p { display: none; }
  .mode-tabs { order: 3; width: 100%; justify-content: center; }
  .control-bar { flex-wrap: wrap; }
  .waveform { order: 4; width: 100%; flex: none; }
}
