:root {
  --bg: #f6f6fb;
  --card: #ffffff;
  --text: #17172b;
  --muted: #6b6b85;
  --line: #e4e4ef;
  --accent: #6d5dfc;
  --accent-soft: #ecebff;
  --rec: #ef4444;
  --rec-soft: rgba(239, 68, 68, .18);
  --shadow: 0 1px 2px rgba(20, 20, 50, .05), 0 8px 24px rgba(20, 20, 50, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e18;
    --card: #171726;
    --text: #ececf6;
    --muted: #9a9ab5;
    --line: #2a2a40;
    --accent: #8b7dff;
    --accent-soft: #24223f;
    --rec: #f87171;
    --rec-soft: rgba(248, 113, 113, .2);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, "Noto Sans Bengali", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; fill: #fff; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

.recorder {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 16px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.mic {
  position: relative; width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .15s ease, background .2s ease;
}
.mic:hover { transform: scale(1.04); }
.mic:active { transform: scale(.97); }
.mic:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 4px; }
.mic svg { width: 38px; height: 38px; fill: currentColor; position: relative; z-index: 1; }
.mic .icon-stop, .mic .spinner { display: none; }
.ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }

.mic.recording { background: var(--rec); box-shadow: 0 10px 30px var(--rec-soft); }
.mic.recording .icon-mic { display: none; }
.mic.recording .icon-stop { display: block; }
.mic.recording .ring { box-shadow: 0 0 0 calc(6px + var(--lvl, 0) * 26px) var(--rec-soft); transition: box-shadow .08s linear; }

.mic.busy { background: var(--accent-soft); cursor: progress; box-shadow: none; }
.mic.busy:hover { transform: none; }
.mic.busy .icon-mic { display: none; }
.mic.busy .spinner {
  display: block; width: 40px; height: 40px; border-radius: 50%;
  border: 3.5px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: .5px; margin-top: 6px; }
.wave { width: min(100%, 600px); height: 56px; }
.status { margin: 0; color: var(--muted); text-align: center; min-height: 1.55em; }
.sub-actions { font-size: 13px; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .panels { grid-template-columns: 1fr; } }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.tools { display: flex; gap: 6px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.out {
  flex: 1; min-height: 300px; width: 100%; resize: vertical; border: 0; outline: none; background: transparent;
  color: var(--text); padding: 14px 18px; font: inherit; font-size: 15.5px; line-height: 1.7; white-space: pre-wrap;
}
.out::placeholder { color: var(--muted); opacity: .8; }
.out.loading { background: linear-gradient(90deg, transparent, var(--accent-soft), transparent) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px 12px 18px; border-top: 1px solid var(--line); min-height: 50px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin-left: 6px;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--rec); color: #fff; }
