@font-face {
  font-family: Manrope;
  src: url("/assets/manrope.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --shell: #15252a;
  --ink: #172629;
  --muted: #48605f;
  --line: #a7bcb7;
  --ground: #e2ebe7;
  --panel: #f5f9f6;
  --accent: #bce2d3;
  --accent-ink: #154b3c;
  --focus: #1d6b58;
  --live: #207750;
  --alert: #882b2d;
  --display: Manrope, system-ui, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
  font: 500 15px / 1.5 var(--display);
  background: var(--ground);
  color: var(--ink);
  scrollbar-color: #708d83 var(--ground);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-underline-offset: 3px; }
button, a.button { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
::selection { color: var(--shell); background: #b1ddcd; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.masthead :focus-visible, .signal :focus-visible { outline-color: #a9e3d2; }
.skip { position: fixed; top: 10px; left: 10px; z-index: 5; padding: 10px; background: white; transform: translateY(-150%); }
.skip:focus { transform: none; }

.masthead { background: var(--shell); color: #f3f8f4; border-bottom: 1px solid #627d79; }
.mast-inner {
  width: min(100% - 72px, 1340px);
  min-height: 72px;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.lab, .brand { text-decoration: none; }
.lab:hover, .brand:hover { text-decoration: underline; }
.lab span { margin-right: 5px; color: #aad7ca; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.48rem; letter-spacing: -.035em; }
.identity { display: flex; align-items: center; justify-self: end; gap: 12px; font-size: .85rem; color: #c5dcd6; min-width: 0; }
#identity-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.on-dark, .button, .icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 760;
  font-size: .88rem;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover, .icon-button:hover { background: #e7f1ec; border-color: #65877b; }
.button svg, .icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.button.primary { background: var(--accent); border-color: #73988b; color: #18392f; }
.button.primary:hover { background: #a9d8c5; }
.button.danger { color: #fff8f6; background: var(--alert); border-color: var(--alert); }
.button.danger:hover { background: #701f28; }
.on-dark { color: #eef9f3; background: #23393d; border-color: #76948b; }
.on-dark:hover { background: #304c4d; }

main { width: min(100% - 72px, 1340px); margin: 0 auto; padding: clamp(25px, 4vw, 59px) 0 52px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px 24px; padding-bottom: 21px; border-bottom: 1px solid var(--line); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2.8rem, 5vw, 5rem); line-height: 1; letter-spacing: -.04em; font-weight: 800; }
.page-heading p { margin-top: 10px; color: var(--muted); }
.add-actions, .welcome-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.notice { margin: 14px 0 0; padding: 11px 14px; border: 1px solid #83ad9c; color: #174c39; background: #eaf6ed; }
.notice.error, .error { color: var(--alert); }
.notice.error { background: #f9efec; border-color: #c69993; }
.welcome {
  min-height: 302px;
  margin-top: 18px;
  padding: clamp(22px, 4vw, 55px);
  background: var(--shell);
  color: #f1f9f4;
  display: grid;
  grid-template-columns: 1fr minmax(240px, .9fr);
  align-items: center;
  gap: 16px;
  border: 1px solid #627d79;
}
.welcome h2 { font-size: clamp(1.6rem, 4vw, 3rem); letter-spacing: -.035em; }
.welcome p { margin: 10px 0 20px; color: #c6dbd5; max-width: 46ch; }
.welcome img { width: 100%; height: auto; }

.console {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(230px, .29fr) minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid var(--line);
  background: var(--panel);
}
.accounts { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #ebf3ef; min-width: 0; }
.rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 19px 18px; border-bottom: 1px solid var(--line); }
.rail-heading h2 { font-size: 1.06rem; }
.count { min-width: 29px; padding: 1px 5px; border: 1px solid var(--line); font: .8rem/1.6 var(--mono); text-align: center; }
.account-list { display: grid; align-content: start; padding: 9px; }
.account-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 9px;
  gap: 10px;
  min-height: 64px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 1px solid transparent;
  border-bottom-color: #c5d5cf;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.account-row:hover { background: #dfede6; }
.account-row[aria-pressed="true"] { border-color: #83aa9a; background: #d6ebe1; }
.account-initials { display: grid; place-items: center; aspect-ratio: 1; font-weight: 800; font-size: .78rem; background: #edf7f1; color: var(--accent-ink); border: 1px solid #92b0a6; }
.row-copy strong, .row-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-copy strong { font-size: .91rem; }
.row-copy small { font-size: .75rem; color: var(--muted); margin-top: 3px; }
.state-dot, .status-dot { display: inline-block; width: 9px; height: 9px; border: 1px solid currentColor; border-radius: 100%; color: #657c76; }
.state-dot.connected, .status-dot.online { color: #207750; background: currentColor; }
.state-dot.reconnecting, .state-dot.connecting, .status-dot.idle { color: #977000; background: currentColor; }
.state-dot.reauth, .state-dot.link_unavailable, .status-dot.dnd { color: #b04c47; background: currentColor; }
.rail-footer { margin-top: auto; padding: 14px 18px; font-size: .76rem; color: var(--muted); border-top: 1px solid var(--line); }

.workspace { min-width: 0; }
.signal {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1.25fr) auto;
  gap: 13px;
  min-height: 186px;
  align-items: center;
  padding: 19px clamp(16px, 2.7vw, 37px);
  background: #1c3034;
  color: #f2f8f3;
}
.signal-copy { min-width: 0; }
.source { color: #b1d4c8; font-size: .8rem; }
.signal h2 {
  overflow-wrap: anywhere;
  font-size: clamp(1.65rem, 3vw, 3.1rem);
  letter-spacing: -.038em;
  line-height: 1.09;
  margin: 5px 0;
}
.handle { color: #c2d7d1; font-size: .82rem; overflow-wrap: anywhere; }
.phase {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 700;
  border: 1px solid #789a91;
  color: #dbefe7;
}
.phase::before { content: ""; width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.phase.connected { color: #b8f0d0; }
.phase.connected::before { background: currentColor; }
.phase.reconnecting, .phase.connecting { color: #f3d691; }
.phase.reauth, .phase.link_unavailable { color: #ffc7bc; }
.instrument img { width: 100%; height: auto; display: block; }
.signal:not([data-phase="connected"]) .instrument img { opacity: .48; }
.signal-state { min-width: 0; justify-self: end; display: grid; gap: 7px; text-align: right; }
.signal-state > span { color: #c3d9d0; font-size: .76rem; }

.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); background: #e1ede6; }
.readouts > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 15px clamp(10px, 2.7vw, 37px); }
.readouts > div + div { border-left: 1px solid var(--line); }
.readouts span { font-size: .76rem; color: var(--muted); }
.readouts strong { font-size: .98rem; font-weight: 800; overflow-wrap: anywhere; }
.readouts small { font: .72rem/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.status-form { padding: 24px clamp(16px, 2.7vw, 37px); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 12px; font-size: 1.1rem; font-weight: 800; }
.status-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.status-options label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 9px;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: .85rem;
  cursor: pointer;
}
.status-options label:hover { background: #e8f2ed; }
.status-options label:has(input:checked) { background: #d9eee3; border-color: #638f7f; }
.status-options label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.status-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status-dot { flex: none; }
.duration-row { margin-top: 19px; }
.duration-row > label { display: inline-block; font-size: .86rem; font-weight: 800; margin-bottom: 5px; }
.duration-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
select, input:not([type="radio"]) {
  width: 100%;
  min-height: 44px;
  border: 1px solid #8faa9f;
  border-radius: 3px;
  background: #fcfefa;
  padding: 7px 10px;
  color: var(--ink);
  caret-color: var(--focus);
}
select { width: min(100%, 236px); }
input::placeholder { color: #536964; }
#custom-duration { width: min(100%, 105px); }
.duration-row p { font-size: .77rem; color: var(--muted); margin-top: 9px; }
.detail-footer { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; padding: 3px clamp(16px, 2.7vw, 37px); min-height: 48px; border-top: 1px solid var(--line); }
.detail-footer p { flex: 1 1 18ch; padding: 6px 0; font-size: .76rem; color: var(--muted); }
.text-button { min-height: 44px; border: 0; background: transparent; color: #224f43; text-decoration: underline; text-underline-offset: 3px; font-size: .78rem; font-weight: 760; padding: 6px 0; }
.text-button:hover { color: var(--ink); }
.empty-workspace { padding: 36px; min-height: 320px; }
.empty-workspace h2 { margin-top: 12px; }
.empty-workspace p { color: var(--muted); margin: 5px 0 18px; }
.empty-workspace .button { margin: 0 4px 6px 0; }

dialog { width: min(100% - 24px, 480px); max-height: calc(100% - 24px); padding: 22px; border: 1px solid #708e82; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: #132325b0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.dialog-head h2 { font-size: 1.45rem; letter-spacing: -.02em; }
.icon-button { width: 44px; flex: none; padding: 7px; }
dialog p { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }
#credential-form { display: grid; gap: 12px; }
#credential-form label { font-weight: 750; font-size: .84rem; }
#credential-form label input { display: block; margin-top: 4px; }
#credential-form button, #confirm-remove { justify-self: start; }
.rytmo-choice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.rytmo-choice > div { min-width: 0; overflow-wrap: anywhere; }
.rytmo-choice small { display: block; color: var(--muted); }

@media (max-width: 940px) {
  .signal { grid-template-columns: minmax(128px, 1fr) minmax(95px, .75fr) auto; }
  .status-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 690px) {
  .mast-inner, main { width: calc(100% - 28px); }
  .mast-inner { min-height: 60px; gap: 8px; }
  .brand { font-size: 1.06rem; gap: 5px; }
  .brand img { width: 21px; height: 21px; }
  .lab { font-size: .78rem; white-space: nowrap; }
  #identity-label:not([data-preview]) { display: none; }
  .identity .on-dark { font-size: .75rem; padding: 4px 7px; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading p { font-size: .88rem; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .accounts { border-right: 0; }
  .rail-heading { padding: 10px 12px; }
  .account-list { display: flex; overflow: auto; padding: 7px; gap: 4px; }
  .account-row { flex: 0 0 158px; grid-template-columns: 27px minmax(0, 1fr) 7px; gap: 6px; min-height: 49px; padding: 5px; }
  .account-row .state-dot { width: 7px; height: 7px; }
  .row-copy strong { font-size: .8rem; }
  .row-copy small { font-size: .66rem; }
  .rail-footer { display: none; }
  .signal { min-height: 137px; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .instrument { display: none; }
  .signal-state .on-dark { white-space: normal; max-width: 119px; padding-inline: 9px; }
  .readouts > div { padding: 11px 7px; }
  .readouts span { font-size: .69rem; }
  .readouts strong { font-size: .83rem; }
  .readouts small { font-size: .66rem; }
  .duration-controls:not(:has(#custom-duration:not([hidden]))) select { flex: 1 1 140px; width: auto; }
  .welcome { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .welcome img { max-width: 315px; }
}
@media (max-width: 360px) {
  .button { padding-inline: 9px; }
  .add-actions { gap: 6px; }
  .duration-controls:has(#custom-duration:not([hidden])) select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
