/* Phone first. White base, black / white / gray only; red only for recording, mistakes and destructive actions.
   Glass for the floating control layer (header, tab bar, sheet, toast); content stays on solid white. */
:root {
  --page: #ffffff; --card: #ffffff; --ink: #111114; --ink2: #3a3a3f; --muted: #6a6a70; --line: #e4e4e8; --soft: #f2f2f5;
  --danger: #c0261b; --del: #c0261b; --delbg: #fdeeec; --rec: #d6281e;
  --glass: rgba(255, 255, 255, .78); --edge: rgba(0, 0, 0, .08);
  --shadow: 0 8px 28px rgba(0, 0, 0, .10), inset 0 1px 0 rgba(255, 255, 255, .85);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif; overscroll-behavior-y: contain; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button:active { transform: scale(.97); }
.glass { background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow);
         -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top { position: sticky; top: calc(8px + env(safe-area-inset-top)); z-index: 10; margin: calc(8px + env(safe-area-inset-top)) 16px 0; height: 56px;
       border-radius: 28px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.langpick { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 4px 0 10px; border-radius: 22px; color: var(--ink2); }
.langpick select { appearance: none; border: 0; background: none; font-weight: 600; min-height: 44px; padding: 0 8px 0 4px; color: var(--ink); }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); }
section { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; min-width: 0; }
.card.err { border-color: var(--danger); color: var(--danger); }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 6px; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-color: var(--ink); }
.banner .btn { flex: none; white-space: nowrap; }

/* speak */
.chip-select { justify-self: center; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px 0 16px;
               border-radius: 22px; background: var(--soft); font-size: 14px; color: var(--muted); }
.chip-select select { appearance: none; border: 0; background: none; font-weight: 600; color: var(--ink); min-height: 44px; padding: 0 12px 0 0; }
.micwrap { display: grid; justify-items: center; gap: 10px; padding: 18px 0 6px; }
.bigmic { width: 132px; height: 132px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer;
          box-shadow: 0 10px 30px rgba(0, 0, 0, .22); transition: transform .12s, background .15s; }
.bigmic.rec { background: var(--rec); animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214, 40, 30, .45); } 70% { box-shadow: 0 0 0 22px rgba(214, 40, 30, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 40, 30, 0); } }
.miclabel { font-weight: 600; color: var(--ink2); }
.live { font-size: 18px; white-space: pre-wrap; word-break: break-word; min-height: 56px; }
.live .interim, .live-text { color: var(--muted); }
.live-text { white-space: pre-wrap; word-break: break-word; margin: 4px 0 10px; }
.skl { display: grid; gap: 8px; }
.skl i { display: block; height: 14px; border-radius: 7px; background: var(--line); animation: fade 1.4s ease-in-out infinite; }
.skl i:nth-child(2) { width: 86%; }
.skl i:nth-child(3) { width: 58%; }
@keyframes fade { 50% { opacity: .5; } }

/* result */
.score { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--soft); border-radius: 14px; margin-bottom: 8px; }
.band { font-size: 34px; font-weight: 800; line-height: 1; }
.bandlbl { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.crit { display: flex; gap: 14px; flex: 1; justify-content: flex-end; }
.crit div { text-align: center; }
.crit b { display: block; font-size: 17px; }
.crit span { font-size: 11px; color: var(--muted); }
.label { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin: 12px 0 4px; }
.text { font-size: 17px; white-space: pre-wrap; word-break: break-word; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); }
.text.best { border: 1.5px solid var(--ink); }
.del { color: var(--del); background: var(--delbg); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
.add { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); min-height: 32px; }
.issues { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 8px; }
.tip { margin-top: 10px; padding: 10px 12px; background: var(--soft); border-radius: 14px; font-size: 14px; }
.actions { display: grid; gap: 8px; margin-top: 14px; }
.actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* buttons & form */
.btn { min-height: 48px; border-radius: 24px; padding: 0 18px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--ink2); cursor: pointer; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 22px; padding: 2px; margin: 4px 0; }
.seg button { min-height: 44px; border: 0; background: none; border-radius: 20px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.keyrow { display: flex; gap: 8px; margin: 4px 0 8px; }
.keyrow input { flex: 1; min-width: 0; }
input[type=password], input.num, select { border: 1px solid var(--line); border-radius: 24px; padding: 0 14px; min-height: 48px; background: var(--card); }
input.num { width: 110px; text-align: right; }
.setrow { display: grid; gap: 6px; padding: 8px 0; }
.setrow select { width: 100%; }
.setrow:has(input.num) { grid-template-columns: 1fr auto; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 8px; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 6px 0 8px; font-size: 14px; }
.stats dt { color: var(--ink2); }
.stats dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ok { color: var(--ink); }
.errtxt { color: var(--danger); }
a { color: var(--ink); }

/* history: swipe left to reveal Delete; on a desktop the button shows on hover */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 13px; transition: height .15s; }
.list { display: grid; gap: 10px; }
.item { position: relative; overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--card); }
.item .face { position: relative; background: var(--card); padding: 12px 14px; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; cursor: pointer; transition: transform .2s; touch-action: pan-y; }
.item.dragging .face { transition: none; }
.item .swdel { position: absolute; inset: 0 0 0 auto; width: 96px; border: 0; background: var(--danger); color: #fff; font-weight: 700; cursor: pointer; }
.hband { font-size: 19px; font-weight: 800; text-align: center; background: var(--soft); border-radius: 10px; padding: 6px 0; height: fit-content; }
.hband small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); }
.hmeta { font-size: 12px; color: var(--muted); }
.htext { margin: 2px 0; word-break: break-word; }
.hfixed { color: var(--ink2); }
@media (hover: hover) { .item .face:hover { transform: translateX(-96px); } }

/* bottom sheet (a centered dialog on wide screens) */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 82vh; overflow: auto; border-radius: 24px 24px 0 0;
         padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: rgba(255, 255, 255, .94); }
.grabber { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: #c9c9ce; margin: 2px 0 6px; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; transform: translate(-50%, -50%); border-radius: 24px; }
  .grabber { display: none; }
}

/* tab bar */
.tabbar { position: fixed; left: 16px; right: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 10; max-width: 520px; margin: 0 auto;
          display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 32px; padding: 6px; }
.tabbar button { display: grid; justify-items: center; gap: 1px; min-height: 52px; border: 0; background: none; border-radius: 26px; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; }
.tabbar button[aria-selected="true"] { color: var(--ink); background: rgba(0, 0, 0, .06); }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px;
         min-height: 44px; padding: 4px 18px; border-radius: 22px; font-weight: 600; white-space: nowrap; max-width: calc(100vw - 32px); }
.toastact { min-height: 36px; border: 0; background: none; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* full-screen skeleton until saved data is read */
.skeleton { position: fixed; inset: 0; z-index: 50; background: var(--page); padding: calc(8px + env(safe-area-inset-top)) 16px; display: grid; align-content: start; gap: 18px; }
.sk { background: var(--soft); border-radius: 20px; animation: fade 1.4s ease-in-out infinite; }
.sk.bar0 { height: 56px; border-radius: 28px; }
.sk.circle { width: 132px; height: 132px; border-radius: 50%; justify-self: center; margin-top: 40px; }
.sk.h1 { height: 90px; }
.sk.h2 { height: 180px; }

@media (prefers-reduced-transparency: reduce) { .glass, .sheet { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-reduced-motion: reduce) {
  .sk, .skl i, .bigmic.rec { animation: none; }
  button:active { transform: none; }
  .item .face, .ptr { transition: none; }
}
