:root {
  color-scheme: light;
  --sky: #1ba6df;
  --sky-dark: #1ba6df;
  --sky-pale: #e8f7fc;
  --orange: #f37032;
  --orange-dark: #f37032;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe4ee;
  --surface: #ffffff;
  --background: #f4f8fb;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

.app-header {
  height: 76px;
  padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(15,23,42,.05);
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand img { border-radius: 9px; }
.brand span { display: grid; line-height: 1.05; }
.brand strong { color: var(--sky); font-size: 22px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 4px; }
.version { color: var(--sky-dark); background: var(--sky-pale); padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }

main { min-height: calc(100vh - 76px); }
.connect-layout { width: min(900px, calc(100% - 32px)); margin: 46px auto; display: grid; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 26px; box-shadow: 0 14px 40px rgba(15,23,42,.06); }
.eyebrow { margin: 0 0 13px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; }
.identity-row, .connect-row { display: flex; gap: 14px; align-items: center; }
#own-id { color: var(--sky); font-size: clamp(29px, 6vw, 43px); font-weight: 500; letter-spacing: .035em; font-variant-numeric: tabular-nums; flex: 1; }
.state-line { color: var(--muted); font-size: 13px; margin-top: 15px; }
.state-line.online { color: #059669; }
.state-line.error { color: #dc2626; }
.state-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: currentColor; }
label { display: block; margin: 0 0 8px; color: #334155; font-size: 13px; font-weight: 600; }
input { min-width: 0; flex: 1; height: 50px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 0 15px; color: var(--ink); background: #fff; font-size: 19px; letter-spacing: .05em; outline: none; }
input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(27,166,223,.13); }
.primary-button, .secondary-button, .danger-button, .icon-button { min-height: 44px; border-radius: 9px; border: 0; padding: 0 18px; font-weight: 700; }
.primary-button { height: 50px; background: var(--orange); color: #fff; }
.primary-button:hover { background: var(--orange-dark); color: #fff; filter: brightness(.94); }
.secondary-button, .icon-button { background: #eff6ff; color: var(--sky-dark); }
.danger-button { background: #fee2e2; color: #b91c1c; }
.message { min-height: 20px; margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.message.error { color: #dc2626; }
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-list button { border: 1px solid var(--line); background: #f8fafc; border-radius: 9px; padding: 9px 12px; color: #334155; font-weight: 700; }
.platform-note { display: flex; gap: 8px; flex-direction: column; color: var(--muted); padding: 6px 9px 30px; font-size: 13px; line-height: 1.55; }
.platform-note strong { color: #334155; }

.session-view { height: calc(100vh - 76px); display: grid; grid-template-rows: auto 1fr; background: #020617; }
.session-toolbar { min-height: 62px; padding: 9px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid #cbd5e1; }
.session-toolbar > div:first-child { display: grid; gap: 4px; }
.session-state { color: var(--muted); font-size: 12px; }
.session-state.connected { color: #059669; }
.session-state.reconnecting { color: #d97706; }
.toolbar-actions, .quality { display: flex; align-items: center; gap: 10px; }
.quality { color: var(--muted); font-size: 12px; }
.quality-bars { height: 22px; display: flex; align-items: end; gap: 2px; }
.quality-bars i { display: block; width: 4px; background: #cbd5e1; border-radius: 2px; }
.quality-bars i:nth-child(1) { height: 6px; }.quality-bars i:nth-child(2) { height: 10px; }.quality-bars i:nth-child(3) { height: 15px; }.quality-bars i:nth-child(4) { height: 21px; }
.quality-bars.good i { background: #10b981; }.quality-bars.medium i { background: #eab308; }.quality-bars.bad i { background: #ef4444; }
.desktop-stage { min-height: 0; position: relative; display: grid; place-items: center; overflow: hidden; background: #020617; touch-action: none; }
#remote-canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; outline: none; cursor: default; }
#remote-canvas:focus { box-shadow: inset 0 0 0 2px var(--sky); }
.desktop-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 9px; color: #cbd5e1; text-align: center; pointer-events: none; }
.desktop-placeholder span { color: #64748b; font-size: 13px; }
.spinner { width: 35px; height: 35px; margin-bottom: 8px; border: 3px solid #1e293b; border-top-color: var(--sky); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.break-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(2,6,23,.92); padding: 20px; }
.break-dialog { width: min(560px, 100%); text-align: center; color: #fff; }
.break-dialog h2 { font-size: clamp(25px, 6vw, 38px); margin: 0 0 12px; }
.break-dialog p { color: #cbd5e1; }
#break-countdown { display: block; color: var(--orange); font-size: 72px; font-weight: 700; margin-top: 18px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 11px 16px; border-radius: 9px; background: #0f172a; color: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 13px; }
[hidden] { display: none !important; }

@media (max-width: 700px) {
  .app-header { height: 66px; }
  main { min-height: calc(100vh - 66px); }
  .connect-layout { margin: 24px auto; }
  .card { padding: 20px; border-radius: 14px; }
  .identity-row, .connect-row { align-items: stretch; flex-direction: column; }
  .secondary-button { align-self: flex-start; }
  .session-view { height: calc(100dvh - 66px); }
  .session-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: space-between; }
  .quality { margin-right: auto; }
  .icon-button { display: none; }
  .danger-button { padding: 0 12px; }
  #quality-label { display: none; }
}
