:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --fg: #151a23; --muted: #6a7384;
  --line: #e4e7ee; --accent: #4f46e5; --accent-soft: #eef0ff; --accent-fg: #fff;
  --rec: #ef4444; --rec-soft: #fee2e2; --ok: #16a34a; --ok-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015; --surface: #171a21; --surface-2: #1c2029; --fg: #eceef3; --muted: #8d95a6;
    --line: #272c37; --accent: #818cf8; --accent-soft: #1f2240; --accent-fg: #0e1015;
    --rec: #f87171; --rec-soft: #3a1c1f; --ok: #4ade80; --ok-soft: #14301f; --warn: #fbbf24; --warn-soft: #3a2d10;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14.5px/1.55 "Inter", "Noto Sans Sinhala", -apple-system, "Iskoola Pota", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 340px 1fr; height: 100vh; }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; height: auto; } }

/* ---------- sidebar ---------- */
.sidebar {
  padding: 20px 18px; overflow-y: auto; border-right: 1px solid var(--line);
  background: var(--surface-2); display: flex; flex-direction: column; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.recorder { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.field {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg-toggle { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; gap: 3px; }
.seg-toggle button { border: 0; background: transparent; padding: 6px 4px; border-radius: 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.seg-toggle button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.rec-stage { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 4px; }
#meter { width: 100%; max-width: 240px; height: 44px; opacity: .25; transition: opacity .2s; }
.recording #meter { opacity: 1; }
.timer { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--muted); }
.recording .timer { color: var(--fg); }
.rec-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--rec-soft); background: var(--rec);
  display: grid; place-items: center; transition: transform .12s, box-shadow .2s; box-shadow: 0 6px 18px rgba(239,68,68,.35);
}
.rec-btn:hover:not(:disabled) { transform: scale(1.05); }
.rec-btn:active:not(:disabled) { transform: scale(.96); }
.rec-dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: border-radius .2s, width .2s, height .2s; }
.recording .rec-btn { animation: pulse 1.6s infinite; }
.recording .rec-dot { border-radius: 5px; width: 20px; height: 20px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); } 70% { box-shadow: 0 0 0 16px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.rec-label { font-size: 12.5px; color: var(--muted); }

.drop {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer;
  border: 1.5px dashed var(--line); color: var(--muted); transition: all .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop span { display: flex; flex-direction: column; line-height: 1.3; }
.drop b { font-weight: 600; font-size: 13px; color: var(--fg); }
.drop small { font-size: 12px; }

.list-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.list-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.count { font-size: 12px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item {
  padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; background: transparent;
  display: flex; gap: 10px; align-items: flex-start; transition: background .12s;
}
.item:hover { background: var(--surface); }
.item.active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.item .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.dot.done { background: var(--ok); } .dot.error { background: var(--rec); } .dot.recording { background: var(--rec); animation: blink 1s infinite; }
.dot.converting, .dot.transcribing, .dot.summarizing { background: var(--warn); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.item .t { font-weight: 600; font-size: 13.5px; line-height: 1.35; word-break: break-word; }
.item .m { font-size: 12px; color: var(--muted); }
.empty-list { font-size: 13px; color: var(--muted); padding: 8px 4px; }

/* ---------- detail ---------- */
.detail { overflow-y: auto; padding: 28px 36px 60px; }
@media (max-width: 860px) { .detail { padding: 20px 16px 60px; } }
.wrap { max-width: 860px; margin: 0 auto; }
.empty { height: 70vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.empty h2 { color: var(--fg); margin: 0 0 4px; font-size: 18px; }
.empty p { margin: 0; max-width: 340px; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; line-height: 1.25; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 13.5px; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; display: none; z-index: 10; }
.menu.open .menu-pop { display: block; }
.menu-pop a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; font-size: 13.5px; }
.menu-pop a:hover { background: var(--surface-2); }
.menu-pop a small { color: var(--muted); }

.tabs { display: flex; gap: 4px; margin: 24px 0 16px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 9px 14px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { max-width: 260px; }
.spacer { flex: 1; }

.speakers { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; align-items: center; }
.speakers .lbl { font-size: 12.5px; color: var(--muted); margin-right: 4px; }
.spk-edit { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.spk-edit input { border: 0; background: transparent; outline: none; width: 110px; font-size: 13px; }

.chat { display: flex; flex-direction: column; gap: 14px; }
.turn { display: flex; gap: 10px; align-items: flex-end; max-width: 85%; }
.turn.right { flex-direction: row-reverse; margin-left: auto; }
.turn .avatar { width: 32px; height: 32px; font-size: 12px; flex: none; }
.bubble-wrap { min-width: 0; }
.turn .who { display: flex; gap: 8px; align-items: baseline; margin: 0 4px 3px; }
.turn.right .who { flex-direction: row-reverse; }
.bubble { padding: 10px 14px; border-radius: 16px 16px 16px 4px; font-size: 15.5px; line-height: 1.7;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 28%, var(--line)); }
.turn.right .bubble { border-radius: 16px 16px 4px 16px; }
.bubble p { margin: 0; } .bubble p + p { margin-top: 6px; }
@media (max-width: 860px) { .turn { max-width: 96%; } }
.line { display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.line .who { display: flex; gap: 10px; align-items: baseline; margin-bottom: 2px; }
.line .name { font-weight: 600; font-size: 13.5px; }
.line .time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.line .txt { font-size: 15.5px; line-height: 1.7; }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

.minutes { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 28px 24px; box-shadow: var(--shadow); }
.minutes h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); margin: 24px 0 8px; }
.minutes p { margin: 6px 0; } .minutes ul { margin: 6px 0; padding-left: 22px; } .minutes li { margin: 3px 0; }
.minutes table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.minutes th, .minutes td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.minutes th { color: var(--muted); font-weight: 600; font-size: 12.5px; }

/* progress */
.progress { margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.step { padding-top: 12px; border-top: 4px solid var(--line); font-size: 13px; color: var(--muted); }
.step.on { border-color: var(--accent); color: var(--fg); font-weight: 600; position: relative; overflow: hidden; }
.step.on::after { content: ""; position: absolute; top: -4px; left: 0; height: 4px; width: 40%; background: rgba(255,255,255,.55); animation: slide 1.4s infinite; }
.step.ok { border-color: var(--ok); color: var(--fg); }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.progress p { margin: 18px 0 0; color: var(--muted); }
.banner { margin-top: 24px; padding: 16px 18px; border-radius: 12px; background: var(--rec-soft); color: var(--rec); display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner b { display: block; color: var(--fg); margin-bottom: 2px; }
.banner span { color: var(--fg); opacity: .8; font-size: 13.5px; word-break: break-word; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.player { display: flex; gap: 12px; align-items: center; margin-top: 18px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.player audio { flex: 1; min-width: 0; height: 38px; }
button.time.seek { border: 0; background: none; padding: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
button.time.seek:hover { color: var(--accent); }
.turn.playing .bubble { box-shadow: 0 0 0 2px var(--c); }

a.btn { color: var(--fg); text-decoration: none; }

/* special points */
.points-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); }
.points-box[hidden] { display: none; }
.points-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.points-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; }
.points-list li { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; padding: 6px 10px; background: var(--surface); border-radius: 8px; font-size: 13.5px; word-break: break-word; }
.points-list li.none { color: var(--muted); background: none; padding-left: 0; }
.points-list small { color: var(--muted); margin-left: 4px; }
.points-list .x { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }
.points-list .x:hover { color: var(--rec); }
.points-card { margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
.points-card .points-list { max-height: none; }
.points-card .points-list li { font-size: 15px; font-weight: 500; border-left: 3px solid var(--accent); border-radius: 4px 8px 8px 4px; }

.rec-banner { display: flex; gap: 12px; align-items: center; margin-top: 24px; padding: 14px 16px; border-radius: var(--radius); background: var(--rec-soft); }
.rec-banner b { display: block; } .rec-banner small { color: var(--muted); }
.rec-pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; flex: none; }
.points-card.big { margin-top: 16px; padding: 20px; gap: 14px; }
.points-card.big .points-title { font-size: 13px; }
.points-card.big .field { font-size: 16px; padding: 14px 16px; order: -1; }
.points-card.big .points-list li { font-size: 16px; padding: 10px 14px; }

/* accounts */
.userbar { display: flex; align-items: center; gap: 12px; margin-top: -6px; font-size: 13px; }
.who-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; text-decoration: none; cursor: pointer; }
.link:hover { text-decoration: underline; }
.head-actions { display: flex; gap: 8px; align-items: flex-start; }
.btn.danger { color: var(--rec); }
.btn.danger:hover:not(:disabled) { background: var(--rec-soft); }
.banner details { margin-top: 8px; font-size: 12.5px; } .banner summary { cursor: pointer; color: var(--muted); }
.banner pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; font-size: 12px; max-height: 200px; overflow: auto; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.02em; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.muted-text { margin: 0; color: var(--muted); font-size: 13.5px; }
.form-error { color: var(--rec); font-size: 13.5px; min-height: 1.2em; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }

.admin-head { display: flex; justify-content: space-between; align-items: center; max-width: 980px; margin: 0 auto; padding: 24px 24px 0; }
.admin-head h1 { margin: 0; font-size: 22px; }
.admin-main { max-width: 980px; margin: 0 auto; padding: 18px 24px 60px; display: flex; flex-direction: column; gap: 18px; }
.add-user { padding: 18px; } .add-user h2 { margin: 0 0 12px; font-size: 15px; }
.add-grid { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr 110px auto; gap: 10px; }
@media (max-width: 860px) { .add-grid { grid-template-columns: 1fr; } }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th, .users td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.users th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.users tr:last-child td { border-bottom: 0; }
.users .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status.on { color: var(--ok); } .status.off { color: var(--rec); }
