:root {
  color-scheme: light;
  --ink: #15213f;
  --ink-soft: #52607d;
  --shell: #24345f;
  --shell-deep: #192749;
  --mist: #eef2fb;
  --paper: #ffffff;
  --line: #cdd5e7;
  --accent: #f1ce5a;
  --accent-hover: #e4bc35;
  --record: #d84b4f;
  --record-deep: #aa3038;
  --success: #24745b;
  --warning: #9a5c14;
  --danger-bg: #fff0ef;
  --focus: #7567d8;
  --shadow: 0 12px 30px rgba(27, 43, 82, .13), 0 3px 8px rgba(27, 43, 82, .08);
  --radius: 14px;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  background: var(--mist);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--mist); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--mist); }
button, input { font: inherit; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
::selection { color: #fff; background: var(--focus); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #8995b2; border: 3px solid var(--mist); border-radius: 999px; }
::-webkit-scrollbar-track { background: var(--mist); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: linear-gradient(155deg, var(--shell) 0 48%, var(--mist) 48.2% 100%);
}
.login-panel {
  width: min(100%, 430px);
  padding: 34px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.brand-mark { display: flex; align-items: center; gap: 5px; height: 34px; margin-bottom: 30px; }
.brand-mark span { display: block; width: 6px; border-radius: 6px; background: var(--shell); }
.brand-mark span:nth-child(1), .brand-mark span:nth-child(5) { height: 10px; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(4) { height: 24px; }
.brand-mark span:nth-child(3) { height: 34px; background: var(--accent); }
.login-panel h1 { margin: 0 0 14px; max-width: 13ch; font-size: clamp(2.2rem, 9vw, 3.5rem); line-height: .96; letter-spacing: -.035em; color: var(--shell-deep); }
.login-panel > p { margin: 0 0 30px; max-width: 35ch; color: var(--ink-soft); line-height: 1.55; }
.login-panel form { display: grid; gap: 10px; }
.login-panel label, .title-field span { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; background: #fbfcff; color: var(--ink); caret-color: var(--focus); }
input:hover { border-color: #9faac3; }
input:focus { border-color: var(--focus); outline: 3px solid rgba(117, 103, 216, .18); }
.form-error { margin: 2px 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: #8c252c; line-height: 1.35; }
.button { min-height: 46px; border: 0; border-radius: 10px; padding: 0 18px; font-weight: 750; cursor: pointer; transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-wide { width: 100%; margin-top: 12px; }
.button-primary { background: var(--shell); color: #fff; box-shadow: 0 5px 13px rgba(36, 52, 95, .25); }
.button-primary:hover { background: var(--shell-deep); }
.button-secondary { background: var(--accent); color: var(--shell-deep); }
.button-secondary:hover { background: var(--accent-hover); }

.app-shell { min-height: 100vh; min-height: 100dvh; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 5vw; background: var(--shell); color: #fff; }
.wordmark { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: -.015em; }
.mini-signal { display: flex; align-items: center; gap: 3px; height: 24px; }
.mini-signal i { display: block; width: 4px; background: var(--accent); border-radius: 4px; }
.mini-signal i:nth-child(1), .mini-signal i:nth-child(3) { height: 10px; }
.mini-signal i:nth-child(2) { height: 22px; }
.account-actions { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: #dbe2f5; }
.icon-button { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.1); }
.icon-button svg, .secondary-control svg, .search-field svg, .detail-back svg, .danger-button svg, .mobile-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.workspace { width: min(1440px, 100%); margin: 0 auto; display: grid; grid-template-columns: minmax(390px, .85fr) minmax(520px, 1.35fr); min-height: calc(100vh - 68px); }
.record-pane, .library-pane { padding: clamp(26px, 4vw, 58px); }
.record-pane { background: #e5eaf7; border-right: 1px solid var(--line); }
.library-pane { background: var(--mist); }
.section-heading, .library-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-heading h1, .library-header h1 { margin: 0 0 5px; font-size: clamp(1.7rem, 3vw, 2.45rem); letter-spacing: -.03em; line-height: 1.05; }
.section-heading p, .library-header p { margin: 0; color: var(--ink-soft); }
.state-badge { flex: 0 0 auto; border-radius: 999px; padding: 7px 11px; font-size: .75rem; font-weight: 800; }
.state-ready { color: var(--shell); background: #d7def1; }
.state-recording { color: #fff; background: var(--record-deep); }
.state-paused { color: #70430f; background: #ffe6a5; }
.state-sending { color: #fff; background: var(--shell); }

.recorder-stage { min-height: 560px; display: flex; flex-direction: column; padding: 26px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.title-field { display: grid; gap: 7px; }
.timer-block { flex: 1; display: grid; align-content: center; text-align: center; padding: 42px 0 30px; }
.timer-block time { font-variant-numeric: tabular-nums; font-size: clamp(4.4rem, 10vw, 7.6rem); font-weight: 300; line-height: 1; letter-spacing: -.04em; color: var(--shell-deep); }
.signal-rail { width: min(100%, 410px); height: 14px; margin: 34px auto 13px; overflow: hidden; border-radius: 8px; background: #dce2f0; box-shadow: inset 0 2px 4px rgba(21, 33, 63, .12); }
.signal-rail span { display: block; width: 3%; height: 100%; border-radius: inherit; background: var(--accent); transition: width 90ms linear, background-color .2s ease; }
.is-recording .signal-rail span { background: var(--record); }
.timer-block p { min-height: 1.4em; margin: 0; color: var(--ink-soft); font-size: .9rem; }
.consent-check { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: start; padding: 15px; border-radius: 12px; background: #f2f5fb; color: var(--ink-soft); line-height: 1.4; cursor: pointer; }
.consent-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 23px; height: 23px; display: grid; place-items: center; border: 2px solid #8794b1; border-radius: 6px; background: #fff; }
.check-box svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; opacity: 0; }
.consent-check input:checked + .check-box { border-color: var(--success); background: var(--success); }
.consent-check input:checked + .check-box svg { opacity: 1; }
.consent-check input:focus-visible + .check-box { outline: 3px solid var(--focus); outline-offset: 3px; }
.record-controls { display: grid; grid-template-columns: 1fr 104px 1fr; align-items: center; gap: 15px; margin-top: 25px; }
.record-button { width: 94px; height: 94px; justify-self: center; display: grid; place-items: center; border: 9px solid #f2c8ca; border-radius: 50%; background: var(--record); cursor: pointer; box-shadow: 0 8px 19px rgba(170, 48, 56, .28); transition: transform .18s ease, background-color .18s ease; }
.record-button:hover { transform: scale(1.035); background: var(--record-deep); }
.record-button:active { transform: scale(.98); }
.record-button span { width: 30px; height: 30px; border-radius: 50%; background: #fff; }
.is-recording .record-button span { border-radius: 5px; }
.secondary-control { min-height: 62px; display: grid; justify-items: center; align-content: center; gap: 5px; border: 0; border-radius: 12px; background: #edf1f9; color: var(--shell); cursor: pointer; font-size: .78rem; font-weight: 700; }
.secondary-control:hover:not(:disabled) { background: #dfe5f3; }
.secondary-control:disabled { opacity: .42; cursor: not-allowed; }
.transfer-panel { margin-top: 20px; padding: 22px; border-radius: var(--radius); background: var(--shell); color: #fff; box-shadow: var(--shadow); }
.transfer-panel h2 { margin: 0 0 5px; font-size: 1.1rem; }
.transfer-panel p { margin: 0; color: #dbe2f5; }
.progress-track { height: 10px; margin-top: 18px; border-radius: 6px; overflow: hidden; background: rgba(255,255,255,.18); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease-out; }
.transfer-panel .button { margin-top: 16px; }

.library-header { align-items: flex-end; }
.search-field { width: min(360px, 46%); position: relative; }
.search-field svg { position: absolute; z-index: 1; left: 13px; top: 13px; color: var(--ink-soft); }
.search-field input { padding-left: 43px; background: var(--paper); }
.library-content { position: relative; min-height: 540px; }
.recording-list { display: grid; gap: 10px; }
.recording-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 88px; padding: 16px 18px; border: 1px solid transparent; border-radius: 12px; text-align: left; background: var(--paper); box-shadow: 0 4px 14px rgba(27, 43, 82, .07); cursor: pointer; transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.recording-row:hover { transform: translateY(-1px); border-color: #aeb8d0; box-shadow: 0 8px 20px rgba(27, 43, 82, .11); }
.recording-row h2 { margin: 0 0 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.recording-row p { margin: 0; color: var(--ink-soft); font-size: .84rem; font-variant-numeric: tabular-nums; }
.row-status { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: .78rem; font-weight: 750; }
.row-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #8c98b2; }
.row-status.status-completed::before { background: var(--success); }
.row-status.status-failed::before { background: var(--record); }
.row-status.status-queued::before, .row-status.status-transcribing::before { background: var(--accent-hover); animation: breathe 1.5s ease-in-out infinite; }
.empty-state { min-height: 430px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--ink-soft); }
.empty-state svg { width: 74px; height: 74px; fill: none; stroke: #8e9ab6; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h2 { margin: 18px 0 6px; color: var(--ink); }
.empty-state p { max-width: 36ch; margin: 0; line-height: 1.5; }
.detail-panel { padding: 26px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.detail-back { display: inline-flex; align-items: center; gap: 6px; margin: -6px 0 22px -8px; border: 0; background: transparent; color: var(--shell); font-weight: 750; cursor: pointer; }
.detail-title-row { display: grid; grid-template-columns: 1fr 46px; gap: 8px; align-items: center; }
.detail-title-input { min-height: 52px; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -.03em; }
.detail-title-input:focus { padding: 0 10px; border: 1px solid var(--focus); border-radius: 10px; }
.detail-title-row .icon-button { color: var(--shell); }
.detail-title-row .icon-button:hover { background: var(--mist); }
.detail-meta { margin: 5px 0 28px; color: var(--ink-soft); font-size: .88rem; font-variant-numeric: tabular-nums; }
.detail-error { margin-bottom: 24px; padding: 18px; border-radius: 12px; background: var(--danger-bg); color: #7e282e; }
.detail-error p { margin: 0 0 12px; }
.pending-state { margin: 20px 0; color: var(--ink-soft); }
.pending-line { display: block; width: 100%; height: 7px; border-radius: 5px; background: linear-gradient(90deg, var(--accent) 0 35%, #e1e6f2 35% 100%); background-size: 180% 100%; animation: processing 1.8s ease-in-out infinite alternate; }
.pending-state p { line-height: 1.5; }
.transcript-content { color: #283451; line-height: 1.75; max-width: 74ch; }
.transcript-content p { margin: 0 0 1.15em; }
.segment-time { display: inline-block; min-width: 48px; margin-right: 9px; color: var(--shell); font-size: .75rem; font-weight: 800; font-variant-numeric: tabular-nums; vertical-align: .08em; }
.danger-button { display: inline-flex; align-items: center; gap: 8px; margin-top: 30px; min-height: 44px; padding: 0 14px; border: 1px solid #e4b7b9; border-radius: 10px; background: transparent; color: #9c3036; font-weight: 750; cursor: pointer; }
.danger-button:hover { background: var(--danger-bg); }
.toast-region { position: fixed; z-index: 20; right: 18px; top: 18px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 15px; border-radius: 10px; background: var(--shell-deep); color: #fff; box-shadow: var(--shadow); line-height: 1.4; animation: toast-in .25s ease-out; }
.toast.error { background: #8c2930; }
.mobile-nav { display: none; }

@keyframes breathe { 50% { transform: scale(1.55); opacity: .55; } }
@keyframes processing { to { background-position: -80% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 900px) {
  .topbar { height: 60px; padding: 0 18px; }
  .account-actions > span { display: none; }
  .workspace { display: block; min-height: calc(100dvh - 60px); padding-bottom: 78px; }
  .record-pane, .library-pane { display: none; min-height: calc(100dvh - 138px); padding: 25px 18px 34px; border: 0; }
  .record-pane.pane-active, .library-pane.pane-active { display: block; }
  .recorder-stage { min-height: calc(100dvh - 250px); padding: 20px; }
  .timer-block { padding: 34px 0 22px; }
  .timer-block time { font-size: clamp(4.2rem, 21vw, 6.4rem); }
  .record-controls { grid-template-columns: 1fr 92px 1fr; gap: 10px; }
  .record-button { width: 84px; height: 84px; border-width: 8px; }
  .secondary-control { min-height: 58px; }
  .library-header { display: grid; gap: 18px; }
  .search-field { width: 100%; }
  .detail-panel { margin: 0 -4px; padding: 20px; }
  .mobile-nav { position: fixed; z-index: 10; inset: auto 0 0; display: grid; grid-template-columns: 1fr 1fr; height: calc(72px + env(safe-area-inset-bottom)); padding: 7px 18px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); box-shadow: 0 -8px 24px rgba(27, 43, 82, .09); }
  .mobile-nav-item { display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-soft); font-size: .72rem; font-weight: 750; }
  .mobile-nav-item.active { color: var(--shell); background: #e9edf7; }
}

@media (min-width: 901px) and (max-height: 800px) {
  .topbar { height: 60px; }
  .workspace { min-height: calc(100vh - 60px); }
  .record-pane, .library-pane { padding-top: 24px; padding-bottom: 24px; }
  .section-heading, .library-header { margin-bottom: 18px; }
  .section-heading h1, .library-header h1 { font-size: 1.8rem; }
  .recorder-stage { min-height: 0; height: calc(100vh - 60px - 48px - 82px); padding: 18px 24px; }
  .timer-block { padding: 16px 0 10px; }
  .timer-block time { font-size: 4.7rem; }
  .signal-rail { margin-top: 18px; margin-bottom: 8px; }
  .consent-check { padding: 10px 13px; }
  .record-controls { margin-top: 13px; }
  .record-button { width: 76px; height: 76px; border-width: 7px; }
  .record-button span { width: 25px; height: 25px; }
  .secondary-control { min-height: 52px; }
}

@media (max-width: 430px) {
  .login-panel { padding: 27px 22px; }
  .section-heading { margin-bottom: 18px; }
  .section-heading h1, .library-header h1 { font-size: 1.75rem; }
  .recorder-stage { min-height: calc(100dvh - 228px); }
  .consent-check { font-size: .86rem; }
  .recording-row { min-height: 82px; padding: 14px; }
  .recording-row { grid-template-columns: minmax(0, 1fr); gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
