/* TriLingo · Apple-inspired light interface */
*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --placeholder: #a1a1a6;
  --line: rgba(60, 60, 67, 0.12);
  --line-soft: rgba(60, 60, 67, 0.08);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.08);
  --blue: #007aff;
  --blue-deep: #0066d6;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --teal: #30b0c7;
  --yellow: #ffcc00;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", system-ui, sans-serif;
}

html,
body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 8% -12%, rgba(0, 122, 255, 0.10), transparent 62%),
    radial-gradient(900px 460px at 92% -14%, rgba(175, 82, 222, 0.09), transparent 60%),
    radial-gradient(800px 500px at 50% 112%, rgba(255, 149, 0, 0.055), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(0, 122, 255, 0.22); }

* { scrollbar-width: thin; scrollbar-color: rgba(60, 60, 67, 0.18) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(60, 60, 67, 0.18); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

.aurora { display: none; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 11px 22px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6 55%, #ff375f);
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.logo svg { width: 26px; height: 26px; }
.brand-text h1 {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.025em;
  white-space: nowrap;
  color: var(--text);
}
.brand-text h1 span { font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.07em; }
.brand-text p { margin: 1px 0 0; font-size: 10.5px; color: var(--text-3); letter-spacing: 0.015em; }

.pivot {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}
.p-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  font-size: 12px;
  font-weight: 550;
  color: #3a3a3c;
  white-space: nowrap;
}
.p-chip .p-flag { font-size: 14px; line-height: 1; }
.p-pivot {
  background: rgba(0, 122, 255, 0.09);
  border-color: rgba(0, 122, 255, 0.16);
  box-shadow: none;
  color: var(--blue);
  font-weight: 600;
}
.p-note {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.12);
  padding: 1px 6px;
  border-radius: 999px;
}
.p-arrow { color: #c7c7cc; display: grid; place-items: center; }
.p-arrow svg { width: 16px; height: 16px; }
.board.is-translating .p-arrow { color: var(--blue); animation: arrowPulse 1s infinite; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.switch {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-2);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #e9e9eb;
  border: 0;
  position: relative;
  transition: background 0.22s ease;
  flex: 0 0 auto;
}
.switch-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-dot { left: 20px; }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(0, 122, 255, 0.35); outline-offset: 2px; }
.switch-label { white-space: nowrap; }

.engine-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  font-size: 11.5px;
  color: #3a3a3c;
  max-width: 235px;
  transition: background 0.15s;
}
.engine-chip:hover { background: #f2f2f7; }
.engine-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c7cc;
  box-shadow: none;
  flex: 0 0 auto;
}
.engine-chip .dot.ok { background: var(--green); }
.engine-chip .dot.warn { background: var(--orange); }
.engine-chip .dot.off { background: var(--red); }
.engine-chip .engine-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stop-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 59, 48, 0.22);
  background: rgba(255, 59, 48, 0.08);
  color: var(--red);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s;
}
.stop-chip:hover { background: rgba(255, 59, 48, 0.14); }
.stop-chip svg { width: 14px; height: 14px; }
.stop-chip[hidden] { display: none; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  place-items: center;
  color: #636366;
  transition: background 0.15s, transform 0.15s;
  flex: 0 0 auto;
}
.icon-btn:hover { background: #f2f2f7; color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.35); outline-offset: 2px; }

/* ----------------------------------------------------------------- board */

.board {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 16px 22px 8px;
}

.col {
  --accent: var(--blue);
  --accent-soft: rgba(0, 122, 255, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 22px;
  border: 1px solid var(--line-soft);
  background: var(--card);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.055), 0 1px 2px rgba(0, 0, 0, 0.035);
  overflow: hidden;
  transition: box-shadow 0.22s, border-color 0.22s;
}
.col[data-col="0"] { --accent: #30b0c7; --accent-soft: rgba(48, 176, 199, 0.12); }
.col[data-col="1"] { --accent: #007aff; --accent-soft: rgba(0, 122, 255, 0.12); }
.col[data-col="2"] { --accent: #ff9500; --accent-soft: rgba(255, 149, 0, 0.13); }

.col::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(90deg, transparent, rgba(0, 122, 255, 0.85), transparent);
  background-size: 200% 100%;
  opacity: 0;
  pointer-events: none;
}
.col.is-busy {
  border-color: rgba(0, 122, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.12), 0 10px 32px rgba(0, 122, 255, 0.10);
}
.col.is-busy::before { opacity: 1; animation: scan 1.3s linear infinite; }
.col.is-speaking {
  border-color: rgba(0, 122, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.14), 0 12px 36px rgba(0, 122, 255, 0.14);
}
.col.is-recording {
  border-color: rgba(255, 59, 48, 0.32);
  box-shadow: 0 0 0 1px rgba(255, 59, 48, 0.10), 0 12px 36px rgba(255, 59, 48, 0.10);
}
.col.just-translated { animation: flashBorder 0.85s ease; }

.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 15px 11px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line-soft);
}
.flag { font-size: 19px; line-height: 1; }
.lang-select-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.lang-select {
  appearance: none;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  padding: 5px 22px 5px 7px;
  margin-left: -7px;
  max-width: 185px;
  cursor: pointer;
  text-overflow: ellipsis;
  border-radius: 8px;
  transition: background 0.15s;
}
.lang-select:hover { background: #f2f2f7; }
.lang-select-wrap::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.6px solid #8e8e93;
  border-bottom: 1.6px solid #8e8e93;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.lang-select option { background: #fff; color: var(--text); }
.lang-select:disabled { opacity: 0.5; cursor: default; }
.lang-static { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.lang-static svg { width: 13px; height: 13px; color: var(--text-3); }
.pivot-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.09);
  border: 1px solid rgba(0, 122, 255, 0.13);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.col-letter {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, #fff);
  flex: 0 0 auto;
}

/* ------------------------------------------------------------ text zone */

.text-zone {
  flex: 1 1 48%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 8px;
}
.src {
  flex: 1 1 auto;
  width: 100%;
  min-height: 84px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  padding: 2px 2px 6px;
}
.src::placeholder { color: var(--placeholder); font-size: 15px; }
.col.is-busy .src::placeholder { color: transparent; }
.src:read-only { cursor: default; }

.aligned {
  display: none;
  flex: 1 1 auto;
  text-align: start;
  min-height: 84px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  padding: 2px 2px 6px;
}
.col.show-align .src { display: none; }
.col.show-align .aligned { display: block; }

.align-mark {
  background: color-mix(in srgb, var(--gc) 15%, transparent);
  border-radius: 5px;
  padding: 1px 2px;
  margin: 0 -1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: inherit;
  cursor: pointer;
  transition: background 0.16s, box-shadow 0.16s, opacity 0.16s;
}
.align-mark:hover { background: color-mix(in srgb, var(--gc) 25%, transparent); }
.align-mark.is-linked {
  background: color-mix(in srgb, var(--gc) 33%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gc) 45%, transparent);
}
.align-mark.is-pinned {
  background: color-mix(in srgb, var(--gc) 42%, transparent);
  box-shadow: 0 0 0 2px var(--gc);
}
.board.align-focus .align-mark:not(.is-linked):not(.is-pinned) { opacity: 0.4; }

.text-tools {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  min-height: 30px;
  margin-top: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.text-tools::-webkit-scrollbar { display: none; }
.trans-state {
  flex: 1 1 auto;
  min-width: 56px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trans-state .via { color: var(--blue); font-weight: 600; }
.trans-state svg { width: 11px; height: 11px; flex: 0 0 auto; }
.char-count { font-size: 10.5px; color: var(--placeholder); font-variant-numeric: tabular-nums; margin-right: 2px; flex: 0 0 auto; }
.mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: #636366;
  font-size: 11.5px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex: 0 0 auto;
}
.mini svg { width: 15px; height: 15px; }
.mini:hover { background: #f2f2f7; color: var(--text); }
.mini[data-act="translate"] {
  color: #fff;
  background: var(--blue);
  border-radius: 999px;
  padding: 0 13px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 122, 255, 0.22);
}
.mini[data-act="translate"]:hover { background: var(--blue-deep); color: #fff; }
.mini[data-act="align"].is-on { background: rgba(0, 122, 255, 0.10); color: var(--blue); }
.mini[data-act="align"].is-on:hover { background: rgba(0, 122, 255, 0.16); }
.mini:disabled { opacity: 0.4; cursor: default; }
.spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(60, 60, 67, 0.16);
  border-top-color: var(--blue);
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex: 0 0 auto;
}

/* ----------------------------------------------------------- audio zone */

.audio-zone {
  flex: 1 1 34%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line-soft);
  background: #fafafc;
}
.audio-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 6px;
  flex: 0 0 auto;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.zone-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.zone-title svg { width: 12px; height: 12px; color: var(--accent); }
.clip-count {
  font-size: 10px;
  color: var(--text-3);
  background: #e9e9ee;
  border-radius: 999px;
  padding: 1px 6px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.audio-head .upload { margin-left: auto; height: 24px; padding: 0 7px; }

.clip-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.clip {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border-radius: 13px;
  border: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
  transition: background 0.15s, border-color 0.15s;
}
.clip:hover { background: #f7f7fa; border-color: rgba(60, 60, 67, 0.14); }
.clip.active {
  background: color-mix(in srgb, var(--accent) 6%, #fff);
  border-color: color-mix(in srgb, var(--accent) 30%, #fff);
}
.clip.is-busy { opacity: 0.7; }
.clip-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex: 0 0 auto;
  transition: background 0.15s, transform 0.15s;
}
.clip-play svg { width: 14px; height: 14px; }
.clip-play:hover { background: color-mix(in srgb, var(--accent) 20%, #fff); transform: scale(1.05); }
.clip-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.clip-top { display: flex; align-items: baseline; gap: 8px; }
.clip-name {
  font-size: 11.5px;
  font-weight: 550;
  color: #3a3a3c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.clip-dur { font-size: 10px; color: var(--placeholder); font-variant-numeric: tabular-nums; margin-left: auto; flex: 0 0 auto; }
.clip-wave { position: relative; height: 15px; display: flex; align-items: center; overflow: hidden; }
.wave { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; color: #d1d1d6; }
.wave i { display: block; width: 2px; border-radius: 2px; background: currentColor; flex: 0 0 2px; }
.wave-fill {
  color: var(--accent);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0);
  transition: clip-path 0.12s linear;
  opacity: 0.9;
}
.clip-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  color: var(--placeholder);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
}
.clip-status { color: var(--accent); margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.clip-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.clip:hover .clip-actions,
.clip.active .clip-actions,
.clip:focus-within .clip-actions { opacity: 1; }
.clip-actions button {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: #8e8e93;
  display: grid;
  place-items: center;
}
.clip-actions button:hover { background: #e9e9ee; color: var(--text); }
.clip-actions svg { width: 13px; height: 13px; }
.clip-empty {
  flex: 1 1 auto;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  padding: 10px;
  border: 1px dashed #d1d1d6;
  border-radius: 13px;
  color: var(--placeholder);
  font-size: 10.5px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.45);
}
.clip-empty svg { width: 18px; height: 18px; opacity: 0.6; color: var(--accent); }
.clip-list.is-dropping { outline: 2px dashed var(--blue); outline-offset: -4px; border-radius: 12px; }

.karaoke {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 12px;
  border-top: 1px solid var(--line-soft);
  background: #fff;
  flex: 0 0 auto;
}
.karaoke[hidden] { display: none; }
.karaoke-label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--placeholder);
}
.karaoke-label svg { width: 11px; height: 11px; color: var(--accent); }
.karaoke-words {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.karaoke-words::-webkit-scrollbar { display: none; }
.karaoke-word {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.4;
  padding: 2px 3px;
  border-radius: 5px;
  white-space: pre;
  transition: background 0.12s, color 0.12s;
}
.karaoke-word:hover { background: #f2f2f7; color: var(--text); }
.karaoke-word.is-active {
  background: color-mix(in srgb, var(--accent) 15%, #fff);
  color: var(--accent);
  font-weight: 600;
}
.clip-karaoke {
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------- record zone */

.record-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line-soft);
  background: #fbfbfd;
  position: relative;
}
.rec-wrap { display: flex; align-items: center; justify-content: center; gap: 18px; width: 100%; }
.meter {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  width: 44px;
  opacity: 0.3;
  transition: opacity 0.2s;
}
.meter i {
  display: block;
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 25%, #fff));
  transform: scaleY(0.12);
  transform-origin: center;
  transition: transform 0.07s linear;
}
.col.is-recording .meter { opacity: 1; }
.rec-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 78%, #fff);
  color: var(--accent);
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: transform 0.18s, background 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.rec-btn:hover {
  background: color-mix(in srgb, var(--accent) 7%, #fff);
  transform: scale(1.04);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
}
.rec-btn:active { transform: scale(0.96); }
.rec-btn:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.35); outline-offset: 2px; }
.rec-btn svg { width: 26px; height: 26px; pointer-events: none; }
.rec-halo {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 38%, transparent);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.col.is-recording .rec-btn {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 59, 48, 0.35);
  animation: beat 1.5s ease-in-out infinite;
}
.col.is-recording .rec-btn .rec-halo { opacity: 1; border-color: rgba(255, 59, 48, 0.4); animation: halo 1.8s ease-out infinite; }
.col.is-recording .rec-btn:hover { background: var(--red); transform: none; }
.rec-time {
  width: 44px;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  opacity: 0.45;
  transition: 0.2s;
}
.col.is-recording .rec-time { opacity: 1; color: var(--red); }
.rec-hint { margin: 0; font-size: 10.5px; color: var(--text-3); letter-spacing: 0.01em; text-align: center; min-height: 14px; }
.col.is-recording .rec-hint { color: var(--red); }
.board.is-recording .col:not(.is-recording) .rec-btn {
  filter: grayscale(0.8);
  opacity: 0.35;
  pointer-events: none;
}
.board.is-recording .col:not(.is-recording) .rec-hint { opacity: 0.45; }

/* -------------------------------------------------------------- statusbar */

.statusbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 2px 24px 12px;
  font-size: 10.5px;
  color: var(--text-3);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.foot-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.foot-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.foot-item.right { margin-left: auto; }

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(560px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(60, 60, 67, 0.08);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.13);
  font-size: 12.5px;
  color: var(--text);
  animation: toastIn 0.25s ease;
  max-width: 100%;
}
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; }
.toast.info svg { color: var(--blue); }
.toast.success svg { color: var(--green); }
.toast.error svg { color: var(--red); }
.toast.warn svg { color: var(--orange); }
.toast-msg { flex: 1 1 auto; min-width: 0; line-height: 1.4; }
.toast button { border: 0; background: transparent; color: var(--text-3); font-size: 14px; padding: 2px 4px; border-radius: 6px; }
.toast button:hover { color: var(--text); background: #f2f2f7; }

/* ---------------------------------------------------------------- history */

.history-btn { position: relative; }
.history-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.history-badge[hidden] { display: none; }
body.history-open { overflow: hidden; }

.history-scrim {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgba(30, 30, 32, 0.24);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.history-scrim.is-open { opacity: 1; }
.history-scrim[hidden] { display: none; }

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(500px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 22px 0 0 22px;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.18);
  transform: translateX(102%);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}
.history-panel.is-open { transform: none; }
.history-panel[hidden] { display: none; }

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.history-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.025em; }
.history-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--text-3); }
.history-head .icon-btn { background: #e9e9ee; border: 0; width: 32px; height: 32px; }
.history-head .icon-btn:hover { background: #dedee3; }

.history-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.history-actions .btn { height: 30px; padding: 0 12px; font-size: 11.5px; }

.history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  background: #f2f2f7;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-empty {
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--placeholder);
  font-size: 12px;
  line-height: 1.6;
}
.history-empty svg { width: 28px; height: 28px; opacity: 0.55; color: var(--blue); }

.turn {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 12px 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.turn-head { display: flex; align-items: center; gap: 8px; }
.turn-time { font-size: 11px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.turn-route {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 10.5px;
  color: var(--placeholder);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.turn-actions button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
}
.turn-actions button:hover { background: #f2f2f7; color: var(--text); }
.turn-actions svg { width: 14px; height: 14px; }

.turn-texts { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.turn-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 9px;
  background: #fafafc;
}
.turn-row.is-source { background: rgba(0, 122, 255, 0.055); }
.turn-flag { font-size: 14px; line-height: 1.45; flex: 0 0 auto; }
.turn-row p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.turn-source {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
  font-size: 9px;
  font-weight: 600;
}
.turn-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.turn-audio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 45%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 3px 5px;
  border-radius: 6px;
  font-size: 10px;
}
.turn-audio:hover { background: #f2f2f7; color: var(--blue); }
.turn-audio svg { width: 12px; height: 12px; flex: 0 0 auto; }
.turn-audio span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-no-audio { font-size: 10px; color: var(--placeholder); }
.turn-meta { font-size: 10px; color: var(--placeholder); white-space: nowrap; }
.turn-restore {
  margin-left: auto;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.09);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 600;
}
.turn-restore:hover { background: rgba(0, 122, 255, 0.16); }
.history-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  background: #fff;
  font-size: 10.5px;
  color: var(--placeholder);
  text-align: center;
  flex: 0 0 auto;
}

@media (max-width: 560px) {
  .history-panel { width: 100vw; border-radius: 0; }
  .history-head { padding: 16px 16px 10px; }
  .history-head h2 { font-size: 19px; }
  .history-actions { padding: 10px 12px; }
  .history-list { padding: 10px; }
}

/* --------------------------------------------------------------- settings */

.settings {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  width: min(720px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
}
.settings::backdrop {
  background: rgba(30, 30, 32, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.settings[open] { animation: sheetIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1); }
.sheet {
  display: flex;
  flex-direction: column;
  max-height: min(92dvh, 940px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: #f2f2f7;
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}
.sheet:focus { outline: none; }
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 14px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.025em; }
.sheet-head p { margin: 3px 0 0; font-size: 12px; color: var(--text-3); }
.sheet-head .icon-btn { background: #e9e9ee; border: 0; width: 32px; height: 32px; }
.sheet-head .icon-btn:hover { background: #dedee3; }
.sheet-body {
  padding: 18px 20px 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}
.set-sec { display: flex; flex-direction: column; gap: 9px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.set-sec h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-2);
}
.group-note { font-size: 10.5px; color: var(--placeholder); }

.engine-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.engine-opt { position: relative; cursor: pointer; }
.engine-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.engine-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 13px;
  height: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.engine-card b { font-size: 13px; font-weight: 600; }
.engine-card small { font-size: 10.5px; line-height: 1.45; color: var(--text-3); }
.engine-opt:hover .engine-card { border-color: rgba(60, 60, 67, 0.18); }
.engine-opt input:checked + .engine-card {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 4px 14px rgba(0, 122, 255, 0.10);
  background: #fff;
}
.engine-opt input:checked + .engine-card::after {
  content: "✓";
  position: absolute;
  top: 9px;
  right: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.engine-opt input:checked + .engine-card b { color: var(--blue); }
.engine-opt input:focus-visible + .engine-card { outline: 3px solid rgba(0, 122, 255, 0.3); outline-offset: 2px; }

.engine-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
}
.engine-fields[hidden] { display: none; }
.engine-fields .wide { grid-column: 1 / -1; }
.engine-extra { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 11.5px; color: var(--text-2); }
.field > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; letter-spacing: 0.01em; }
.field b { color: var(--blue); font-weight: 600; }
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #f2f2f7;
  font-size: 13px;
  color: var(--text);
  outline: 0;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.field input::placeholder { color: var(--placeholder); }
.field input:focus,
.field select:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.14);
}
.field select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, #8e8e93 50%),
    linear-gradient(135deg, #8e8e93 50%, transparent 50%);
  background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field input[type="range"] { width: 100%; height: 22px; accent-color: var(--blue); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
}
.two-col .wide { grid-column: 1 / -1; }
.check-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #e9e9eb;
  position: relative;
  transition: background 0.22s;
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  cursor: pointer;
}
.check-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.check-row input[type="checkbox"]:checked { background: var(--green); }
.check-row input[type="checkbox"]:checked::after { left: 20px; }
.check-row input[type="checkbox"]:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.3); outline-offset: 2px; }

.health-note {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: #fff;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-2);
}
.health-note.ok { border-color: rgba(52, 199, 89, 0.25); background: rgba(52, 199, 89, 0.07); color: #1b7a3d; }
.health-note.warn { border-color: rgba(255, 149, 0, 0.25); background: rgba(255, 149, 0, 0.07); color: #8a5a00; }
.tiny-note { margin: 0; font-size: 10.5px; line-height: 1.5; color: var(--text-3); padding: 0 4px; }
.tiny-note code { font-size: 10px; background: var(--fill-2); padding: 1px 5px; border-radius: 4px; color: var(--text-2); }
.data-row { display: flex; gap: 9px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: #fff;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--blue);
  white-space: nowrap;
  transition: background 0.15s, filter 0.15s;
}
.btn:hover { background: #f2f2f7; }
.btn:focus-visible { outline: 3px solid rgba(0, 122, 255, 0.32); outline-offset: 2px; }
.btn.primary {
  border-color: transparent;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.22);
}
.btn.primary:hover { background: var(--blue-deep); filter: none; }
.btn.danger { color: var(--red); border-color: rgba(255, 59, 48, 0.22); }
.btn.danger:hover { background: rgba(255, 59, 48, 0.07); }
.btn.ghost { background: #fff; }
.btn.small { height: 30px; padding: 0 12px; font-size: 11.5px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  flex: 0 0 auto;
}
.test-result { flex: 1 1 auto; min-width: 0; font-size: 11px; line-height: 1.4; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.test-result.ok { color: #1b7a3d; }
.test-result.bad { color: var(--red); }

/* ------------------------------------------------------------- animations */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes scan {
  0% { background-position: 200% 0; opacity: 0.55; }
  50% { opacity: 1; }
  100% { background-position: -200% 0; opacity: 0.55; }
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes halo {
  0% { transform: scale(0.92); opacity: 0.85; }
  100% { transform: scale(1.34); opacity: 0; }
}
@keyframes arrowPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes flashBorder {
  0% { box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.30), 0 10px 30px rgba(0, 122, 255, 0.12); }
  100% { box-shadow: 0 8px 28px rgba(0, 0, 0, 0.055), 0 1px 2px rgba(0, 0, 0, 0.035); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .pivot { display: none; }
}
@media (max-width: 980px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .top-actions { margin-left: auto; gap: 10px; }
  .board { grid-template-columns: 1fr; padding: 12px 14px 14px; gap: 14px; }
  .col { min-height: 560px; }
  .statusbar { padding: 0 16px 12px; gap: 12px; }
  .foot-item.right { display: none; }
  .settings { width: calc(100vw - 20px); }
  .sheet-head, .sheet-foot { padding-left: 16px; padding-right: 16px; }
  .sheet-body { padding: 16px 16px 4px; }
  .engine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .engine-fields { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .engine-chip { display: none; }
}
@media (max-width: 560px) {
  .brand-text h1 span { display: none; }
  .brand-text p { display: none; }
  .logo { width: 36px; height: 36px; border-radius: 10px; }
  .brand-text h1 { font-size: 17px; }
  .switch-label { font-size: 11px; }
  .switch { gap: 5px; }
  .top-actions { gap: 8px; }
  .stop-chip { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 50%; }
  .stop-chip span { display: none; }
  body.is-translating .history-btn,
  body.is-translating #settingsBtn,
  body.is-speaking .history-btn,
  body.is-speaking #settingsBtn { display: none; }
  .col { min-height: 530px; }
  .mini span { font-size: 11px; }
  .char-count { display: none; }
  .statusbar { gap: 10px; }
  #alignFoot { display: none; }
}
@media (hover: none) {
  .clip-actions { opacity: 1; }
}
@media (max-height: 760px) and (min-width: 981px) {
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .col-head { padding: 10px 12px 8px; }
  .text-zone { padding: 10px 12px 6px; }
  .record-zone { padding: 9px 12px 11px; }
  .rec-btn { width: 56px; height: 56px; }
  .col-letter { display: none; }
  .statusbar { padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
