:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #17283f;
  background: #e7eff9;
  --ink: #17283f;
  --muted: #45617d;
  --line: #c8d6e6;
  --panel: #f8fbff;
  --blue: #0a5fd6;
  --blue-deep: #073c92;
  --focus: #235bb4;
  --mast: #293648;
  --gutter: clamp(1rem, 2.25vw, 2rem);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
::selection { background: #c3dcff; color: var(--ink); }
:where(a, button, input):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button, input { font: inherit; }
button {
  min-height: 44px;
  padding: .58rem .85rem;
  border: 1px solid #a4b7ce;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
}
button:hover:not(:disabled) { background: #e2edf9; }
button:disabled { opacity: .6; cursor: default; }
.danger { background: #a0273d; border-color: #a0273d; color: #fff; }
.danger:hover:not(:disabled) { background: #812136; }
.mast {
  display: flex;
  align-items: center;
  gap: clamp(.7rem, 2vw, 1.7rem);
  min-height: 66px;
  padding: .6rem max(var(--gutter), calc((100% - 104rem) / 2));
  background: var(--mast);
  color: #fff;
}
body:not([data-authenticated]) .mast { display: none; }
.brand {
  flex: none;
  padding-inline-end: clamp(.7rem, 2vw, 1.65rem);
  border-inline-end: 1px solid #71849a;
  font-size: clamp(1rem, 1.6vw, 1.4rem);
  font-weight: 850;
  letter-spacing: -.03em;
  white-space: nowrap;
}
.mast a { color: inherit; text-decoration: none; }
.mast nav, .mast-tools { display: flex; align-items: center; gap: .35rem; }
.mast nav { flex-wrap: wrap; }
.mast nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  border-radius: 8px; padding: .45rem .7rem; color: #e2ecf8; font-weight: 650;
}
.mast nav a:hover, .mast nav a[aria-current] { background: #465d76; color: #fff; }
.mast :is(a, button):focus-visible { outline-color: #c3dcff; }
.mast-tools { margin-inline-start: auto; flex: none; }
.lab { border: 1px solid #71849a; padding: .36rem .65rem; border-radius: 8px; white-space: nowrap; font-size: .8rem; }
.mast-tools button { background: transparent; color: #fff; border-color: transparent; }
.mast-tools button:hover { background: #465d76; }
main { max-width: 108rem; margin: auto; padding: clamp(1.25rem, 2.3vw, 2.15rem) var(--gutter) 2rem; }
.titlebar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .85rem; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 3.4rem); letter-spacing: -.035em; line-height: 1.08; }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.8rem); line-height: 1.15; letter-spacing: -.025em; }
h3 { letter-spacing: -.02em; }
#connection { color: var(--muted); margin: .65rem 0 1.35rem; font-size: .9rem; line-height: 1.45; }
.server-page.mc-settings { width: 100%; }
.server-page.mc-settings:not(:has(#admin-login-link:not([hidden]))) { width: 100%; margin: auto; }
.server-page #admin-status { margin: .65rem 0 1.35rem; line-height: 1.45; }
.server-page .mc-panel { padding: clamp(1rem,2vw,1.5rem); }
.server-page .mc-device-title:first-child { margin-top: 0; }
.server-page .mc-panel [type="submit"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.server-page .mc-panel [type="submit"]:hover:not(:disabled) { background: var(--blue-deep); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.workspace { display: grid; grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr); align-items: start; gap: clamp(.8rem, 1.4vw, 1.25rem); }
.workspace:has(#operation[hidden]) { grid-template-columns: minmax(0, 1fr); }
.readiness {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: clamp(.8rem,2vw,1.5rem);
  padding: 1rem clamp(.85rem,2vw,1.35rem); margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
}
.readiness h2 { font-size: 1rem; max-width: 11ch; }
.group-actions { display: flex; align-items: center; gap: .55rem; }
.group-actions button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 50px; padding-inline: .85rem; font-size: 1rem; }
.group-actions svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
#group-stop { color: #8c2537; border-color: #ce9aa4; background: #fff0f3; }
#group-stop:hover:not(:disabled) { background: #f7d7df; }
.channel-region, .overview { min-width: 0; }
.channels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(.75rem, 1.2vw, 1rem); }
.channel, .overview { border: 1px solid var(--line); border-radius: 14px; padding: clamp(.85rem, 1.4vw, 1.35rem); }
.channel {
  background: var(--panel); min-width: 0; display: flex; flex-direction: column;
  overflow-wrap: anywhere; --signal: #a76508; --tone: #fff0cf; --signal-ink: #734308;
}
.channel[data-tone="ready"] { --signal: #15754d; --tone: #dbf3e6; --signal-ink: #105c39; }
.channel[data-tone="active"] { --signal: #a0273d; --tone: #f9e0e5; --signal-ink: #812136; border-color: #ce9aa4; }
.channel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem .75rem; padding: .15rem 0 .85rem; }
.channel h3 { font-size: clamp(1.15rem, 1.9vw, 1.6rem); line-height: 1.15; }
.phase {
  display: inline-flex; align-items: center; gap: .4rem; max-width: 100%;
  font-size: .81rem; font-weight: 750; line-height: 1.25;
  padding: .4rem .55rem; border-radius: 8px; background: var(--tone); color: var(--signal-ink);
}
.phase::before, .connection-row dd::before, #operation-channels li::before {
  content: ""; display: inline-block; flex: none; width: .5rem; height: .5rem;
  border-radius: 50%; background: var(--signal);
}
.connection-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; gap: .6rem; padding: .65rem 0; border-block-start: 1px solid var(--line); font-size: .9rem; }
.connection-row :is(dt, dd) { display: flex; align-items: center; gap: .5rem; }
.connection-row dt { font-weight: 720; }
dd { margin: 0; font-variant-numeric: tabular-nums; }
.connection-row dd { --signal: #627992; }
.connection-row dd[data-health="ready"] { --signal: #15754d; }
.connection-row dd[data-health="warning"] { --signal: #a76508; }
.channel svg { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.connection-row svg, .channel-details svg { color: #45617d; }
.channel-primary svg { fill: currentColor; stroke: none; }
.channel-checked { margin: 0 0 .8rem; color: var(--muted); font-size: .78rem; border-block-start: 1px solid var(--line); padding-top: .6rem; }
.channel-actions { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: auto; }
.channel-actions button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-size: .86rem; }
.channel-actions .channel-details { margin-inline-start: auto; }
.channel-primary, #operator-login button, #setting-route button { background: var(--blue); border-color: var(--blue); color: #fff; }
.channel-primary:hover:not(:disabled), #operator-login button:hover, #setting-route button:hover:not(:disabled) { background: var(--blue-deep); }
.overview { background: #dbe9fa; border-color: #9ebce2; }
.overview h2 { margin-bottom: .9rem; }
#summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
#summary div { display: flex; flex-direction: column-reverse; justify-content: start; gap: .14rem; min-width: 0; padding-inline: .65rem; border-inline-start: 1px solid var(--line); }
#summary dd { font-weight: 800; font-size: 1.5rem; line-height: 1.1; }
#summary dt { font-size: .8rem; line-height: 1.25; }
#summary div:nth-child(2) dd { color: #15754d; }
#summary div[data-alarm-active] :is(dd,dt) { color: #a0273d; }
#summary div:nth-child(4) dd { color: #734308; }
#setting-status div { display: flex; justify-content: space-between; gap: .85rem; padding: .65rem 0; }
#setting-status div + div { border-top: 1px solid var(--line); }
#setting-status dd { font-weight: 750; text-align: end; }
#summary dt, #setting-status dt { color: var(--muted); }
#operation-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
#operation-counts div { display: flex; flex-direction: column; justify-content: space-between; background: #d2e4fc; padding: .85rem; border: 1px solid #fff; border-radius: 11px; }
#operation-counts div:first-child { background: #d2efe4; }
#operation[data-action="launch"] #operation-counts div:nth-child(2) { background: #f9e0e5; color: #812136; }
#operation[data-action="finish"] #operation-counts div:nth-child(2) { background: #d2efe4; color: #105c39; }
#operation-counts dt { font-weight: 700; font-size: .85rem; }
#operation-counts dd { margin-top: .28rem; font-size: clamp(1.4rem, 2.5vw, 2.35rem); font-weight: 800; letter-spacing: -.035em; }
#operation-channels { margin: .75rem 0 0; padding: 0 .8rem; list-style: none; border-radius: 10px; background: var(--panel); }
#operation-channels li { --signal: #627992; --result-fill: #e7eff9; --result-ink: #29455f; display: grid; grid-template-columns: .5rem minmax(5rem, .8fr) minmax(0, 1.5fr); gap: .6rem; align-items: center; padding: .62rem 0; overflow-wrap: anywhere; font-size: .86rem; font-weight: 630; }
#operation-channels .result-label { justify-self: start; padding: .3rem .48rem; border-radius: 7px; color: var(--result-ink); background: var(--result-fill); }
#operation-channels li + li { border-top: 1px solid var(--line); }
#operation-channels :is([data-result="accepted"], [data-result="completed"]) { --signal: #15754d; --result-fill: #dbf3e6; --result-ink: #105c39; }
#operation-channels [data-result="active"] { --signal: #a0273d; --result-fill: #f9e0e5; --result-ink: #812136; }
#operation-channels :is([data-result="not_sent"], [data-result="unconfirmed"]) { --signal: #a76508; --result-fill: #fff0cf; --result-ink: #734308; }
#operation-note { color: var(--muted); font-size: .85rem; line-height: 1.45; margin-top: .8rem; }
body:has(#sign-in:not([hidden])) { display: flex; flex-direction: column; }
main:has(#sign-in:not([hidden])) { width: 100%; flex: 1; display: grid; align-content: center; justify-items: center; }
main:has(#sign-in:not([hidden])) .titlebar { display: none; }
main:has(#sign-in:not([hidden])) #connection { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#sign-in { width: min(100%, 27rem); padding: clamp(1.25rem, 5vw, 2.1rem); border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.login-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto .85rem; border-radius: 12px; background: #deedfa; color: var(--blue-deep); }
.login-mark svg { width: 30px; height: 30px; }
#sign-in h2 { text-align: center; margin-bottom: 1.5rem; }
#operator-login button { min-height: 48px; margin-top: .2rem; }
#operator-login, #group-pin, #setting-route { display: grid; gap: .85rem; }
label { display: grid; gap: .4rem; font-size: .9rem; font-weight: 660; }
input { width: 100%; min-width: 0; min-height: 46px; padding: .55rem .75rem; border: 1px solid #839bb7; border-radius: 8px; background: #fff; color: var(--ink); caret-color: var(--blue); font-size: 1rem; }
#operator-error, #group-error { color: #89243c; margin-top: .75rem; }
:is(#operator-error, #group-error, #setting-note, #setting-route-note):empty { display: none; }
dialog { width: min(28rem, calc(100% - 1.5rem)); max-height: 90dvh; padding: clamp(1rem, 3vw, 1.55rem); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--panel); }
dialog::backdrop { background: #17283f80; }
#group-dialog h2 { margin-bottom: 1rem; }
#group-plan p { color: var(--muted); line-height: 1.45; }
#group-targets { padding-inline-start: 1.3rem; line-height: 1.55; }
#group-close { width: 100%; margin-top: .65rem; }
#group-hold { display: block; width: 8rem; aspect-ratio: 1; margin: 1rem auto 0; border-radius: 50%; touch-action: none; user-select: none; -webkit-touch-callout: none; }
#group-progress { display: block; width: min(100%, 14rem); margin: .8rem auto; accent-color: #a0273d; }
.center-code { position: relative; display: block; }
.center-code input { position: absolute; inset: 0; opacity: 0; height: 100%; cursor: text; }
.center-code-cells { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: clamp(.25rem,2vw,.55rem); pointer-events: none; }
.center-code-cells > span { display: grid; place-items: center; min-height: 48px; border: 1px solid #839bb7; border-radius: 8px; background: #fff; color: var(--ink); }
.center-code-cells > span[data-filled]::after { content: ""; width: .58rem; aspect-ratio: 1; border-radius: 50%; background: currentColor; }
.center-code:focus-within [data-current] { outline: 3px solid var(--focus); outline-offset: -3px; }
.pin-hint { color: var(--muted); font-size: .87rem; }
.channel-settings { position: fixed; inset: 0 0 0 auto; width: min(30rem,100%); height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 14px 0 0 14px; }
.drawer-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.drawer-heading h2 { overflow-wrap: anywhere; font-size: 1.25rem; }
#setting-probe, #setting-note { margin-top: .65rem; }
#setting-note { padding: .65rem .75rem; border-radius: 8px; background: #e7eff9; line-height: 1.4; }
#setting-note[data-tone=ready] { color: #105c39; background: #dbf3e6; }
#setting-note[data-tone=warning] { color: #734308; background: #fff0cf; }
#setting-route, #setting-directory { padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); }
#setting-route p { color: var(--muted); font-size: .9rem; line-height: 1.4; }
.route-ports { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: end; gap: .65rem; }
#setting-directory ul { padding-inline-start: 1.25rem; line-height: 1.55; }
@media (max-width: 67rem) {
  .mast { flex-wrap: wrap; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  #operation { grid-row: 1; }
}
@media (max-width: 60rem) {
  .readiness { grid-template-columns: minmax(0,1fr) auto; }
  .readiness h2 { max-width: none; }
  #summary { grid-column: 1 / -1; grid-row: 2; }
  .group-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 42rem) {
  .mast nav { order: 3; flex-basis: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .brand { border: 0; padding: 0; }
  .mast nav a { padding-inline: .45rem; font-size: .86rem; }
  .channels { grid-template-columns: minmax(0, 1fr); }
  .readiness { grid-template-columns: minmax(0,1fr); }
  #summary { grid-template-columns: repeat(2,minmax(0,1fr)); row-gap: .7rem; }
  .group-actions { grid-column: 1; grid-row: 3; flex-wrap: wrap; }
  .group-actions button { flex: 1 1 auto; }
}
@media (max-width: 23rem) {
  .channel-actions button { flex: 1 1 auto; }
  .mast-tools button { padding-inline: .4rem; }
}
