:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #131722;
  --muted: #5d6675;
  --line: #e1e4ea;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --rec: #d92d20;
  --ok: #067647;
  --warn-bg: #fef4e6;
  --warn-text: #93500b;
  --err-bg: #fdecea;
  --err-text: #a4160c;
  --busy-bg: #e8effd;
  --busy-text: #1c3f9c;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1017;
    --card: #161c27;
    --text: #e8ebf0;
    --muted: #98a2b3;
    --line: #262e3d;
    --accent: #5b8def;
    --accent-text: #0b1220;
    --rec: #f0584c;
    --ok: #47cd89;
    --warn-bg: #3a2a10;
    --warn-text: #f8c98a;
    --err-bg: #3d1614;
    --err-text: #fba49d;
    --busy-bg: #16284d;
    --busy-text: #a9c4fb;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; }
main {
  padding: 8px 16px calc(32px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
a { color: var(--accent); }
h1, h2, h3, h4, h5, p { margin: 0; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top h1 { flex: 1; font-size: 18px; font-weight: 650; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 12px; background: none;
  color: var(--text); font-size: 26px; line-height: 1; text-decoration: none; cursor: pointer;
}
.iconbtn:active { background: var(--line); }
.iconbtn.ghost { visibility: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.rec { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn.danger { color: var(--err-text); }
.btn.big { min-height: 56px; font-size: 17px; flex: 1; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 3px rgba(255,255,255,.55); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: 10px; margin: 8px 0 14px; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .iconbtn:focus-visible, .tab:focus-visible, .ts:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.45; }
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.hint { font-size: 14px; color: var(--muted); margin-top: 8px; }
.search { margin-bottom: 12px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.chip { flex: none; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.chip.busy { background: var(--busy-bg); color: var(--busy-text); }
.chip.err { background: var(--err-bg); color: var(--err-text); }
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.empty { color: var(--muted); text-align: center; padding: 36px 12px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.panel.busy { background: var(--busy-bg); border-color: transparent; color: var(--busy-text); }
.panel.err { background: var(--err-bg); border-color: transparent; color: var(--err-text); }
.panel.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-text); }
.panel .row { margin-top: 12px; }
.bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; margin-top: 10px; }
.bar > div { height: 100%; width: 0; border-radius: inherit; background: currentColor; transition: width .4s ease; }

/* recorder */
.recorder { text-align: center; padding: 22px 16px; }
.clock { font-size: 54px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -1px; line-height: 1.1; }
.state { min-height: 24px; margin-top: 6px; color: var(--muted); font-weight: 600; }
.state.live { color: var(--rec); }
.state.err { color: var(--err-text); }
.meter { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 16px auto 4px; max-width: 320px; }
.meter > div { height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .08s linear; }
.recorder .row { justify-content: center; margin-top: 18px; }
.saveinfo { font-size: 14px; color: var(--muted); margin-top: 12px; min-height: 21px; }

/* meeting */
.title-input { font-size: 22px; font-weight: 700; border-color: transparent; background: transparent; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px); }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--card); }
.meta { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
audio { width: 100%; margin: 8px 0 4px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--line); margin: 12px 0; }
.tab { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.md h2 { font-size: 20px; margin: 4px 0 8px; }
.md h3 { font-size: 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 6px; }
.md h4, .md h5 { font-size: 16px; margin: 14px 0 4px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 5px 0; }
.md li.nested { margin-left: 18px; }
.md code { font-size: .92em; background: var(--line); padding: 1px 5px; border-radius: 5px; }
.para { margin: 0 0 14px; }
.ts {
  display: inline-block; margin-right: 8px; padding: 1px 7px;
  border: 0; border-radius: 6px; background: var(--busy-bg); color: var(--busy-text);
  font: inherit; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer;
}
.more { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 8px; }
.more > summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--muted); }
.more .row { margin: 10px 0; }
.more select { width: auto; flex: 1; min-width: 150px; }

/* login */
.login { max-width: 360px; margin: 0 auto; padding: 18vh 20px 40px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; }
.login h1 { font-size: 26px; margin: 14px 0 22px; }
.login .btn { width: 100%; margin-top: 12px; }
.login input + input { margin-top: 10px; }
.whoami { text-align: center; font-size: 13px; color: var(--muted); margin-top: 28px; }
.msg { min-height: 22px; margin-top: 12px; font-size: 14px; color: var(--err-text); }
.msg.ok { color: var(--ok); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 88vw; padding: 10px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600;
  transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
