:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #eef0f4; --dim: #9aa3b2; --faint: #6b7383;
  --acc: #7c9cff; --acc2: #a6bbff; --ok: #3ecf8e; --warn: #f5b84b; --err: #ff6b6b;
  --me: #24303f; --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f2f6; --line: #e2e5eb;
    --text: #151821; --dim: #5a6272; --faint: #8b93a3;
    --acc: #3f63e6; --acc2: #2b4cc4; --me: #e7eefc; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
body.desktop { background: color-mix(in srgb, var(--bg) 88%, transparent); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: 10px; }
.primary { background: var(--acc); color: #fff; padding: 8px 14px; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.primary.stop { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.primary.big { padding: 13px 26px; font-size: 16px; border-radius: 12px; }
.ghost { background: transparent; color: var(--dim); padding: 6px 10px; }
.ghost:hover { background: var(--panel2); color: var(--text); }
.small { padding: 5px 10px; font-size: 13px; }
.icon { padding: 6px 8px; }
.desk { display: none; }
body.desktop .desk { display: inline-block; }
body.desktop label.desk { display: flex; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel); -webkit-app-region: drag;
}
body.desktop .bar { padding-left: 86px; }
.bar button, .bar input { -webkit-app-region: no-drag; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
@media (max-width: 520px) { .state { display: none; } }
.brand b { font-size: 15px; }
.state { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.wait { background: var(--warn); }
.dot.err { background: var(--err); }
.meters { display: flex; gap: 8px; margin-left: 6px; flex: none; }
.meter { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.meter i { font-style: normal; color: var(--faint); font-size: 11px; }
.meter em { display: block; width: 34px; height: 5px; border-radius: 3px; background: var(--ok); transform-origin: left; transform: scaleX(0); transition: transform .08s; }
.meter[hidden] { display: none; }
.acts { margin-left: auto; display: flex; gap: 2px; align-items: center; }

.main { flex: 1; display: grid; grid-template-rows: 1fr auto; min-height: 0; }
@media (min-width: 900px) {
  .main { grid-template-columns: 1fr 400px; grid-template-rows: 1fr; }
  .coach { border-top: 0 !important; border-left: 1px solid var(--line); }
}
.talk { overflow-y: auto; padding: 14px; scroll-behavior: smooth; }
.empty { max-width: 460px; margin: 6vh auto; text-align: center; }
.empty h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -.01em; }
.empty p { color: var(--dim); margin: 0 0 18px; }
.hint { font-size: 13.5px; }
.hint.small { font-size: 12px; color: var(--faint) !important; }
.lines { display: flex; flex-direction: column; gap: 10px; max-width: 760px; margin: 0 auto; }
.bub { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 13px; max-width: 92%; }
.bub.ben { align-self: flex-end; background: var(--me); border-color: transparent; }
.who { font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.ln + .ln { margin-top: 7px; }
.bub.karsi .orig { color: var(--dim); font-size: 14px; }
.bub.karsi .tr { font-size: 16.5px; font-weight: 500; margin-top: 1px; }
.bub.ben .orig { font-size: 15px; }
.ara .orig { color: var(--faint) !important; font-style: italic; }

.coach { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; max-height: 52vh; min-height: 0; }
@media (min-width: 900px) { .coach { max-height: none; } }
.coachHead { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--acc2); text-transform: uppercase; letter-spacing: .05em; }
.cards { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
@media (min-width: 900px) { .cards { flex: 1; } }
.card {
  text-align: left; background: var(--panel2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 12px;
  display: flex; flex-direction: column; gap: 3px; transition: border-color .15s;
}
.card:hover { border-color: var(--acc); }
.say { font-size: 17px; font-weight: 600; line-height: 1.35; }
.mean { font-size: 13px; color: var(--dim); }
.tip { margin: 2px 0 0; font-size: 13.5px; color: var(--dim); }
.answer { margin: 0; font-size: 15px; }
.muted { color: var(--faint); margin: 4px 0; font-size: 13.5px; }
.err { color: var(--err); margin: 4px 0; font-size: 13.5px; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.ask { display: flex; gap: 6px; }
.ask input { flex: 1; min-width: 0; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 11px; font: inherit; }
.ask input:focus { outline: 2px solid color-mix(in srgb, var(--acc) 50%, transparent); border-color: transparent; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.sheet { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; }
.sheet label.row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 500; }
.sheet label.row small { flex-basis: 100%; padding-left: 24px; }
.sheet small { font-weight: 400; color: var(--faint); font-size: 12px; }
.sheet a { color: var(--acc2); }
.sheet input:not([type=checkbox]), .sheet select, .sheet textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 8px 10px; font: inherit; font-weight: 400;
}
.sheet textarea { resize: vertical; }
.sheet details summary { cursor: pointer; color: var(--dim); font-size: 13.5px; margin-bottom: 8px; }
.sheet details label { margin-bottom: 10px; }
.sheetActs { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 9px 14px; border-radius: 10px; font-size: 13.5px; max-width: calc(100vw - 32px); z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
