/* The management panel, on the same parts as app.css: a dark rack on the
   left like the readouts, a control strip that never scrolls away, and the
   chosen section on the warm page. Orange still means only "press this" or
   "this is live". */

:root {
  --side: 248px;
  --strip: 68px;
  --knob: #fbfaf7;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --knob: #cfccc4; } }
:root[data-theme="dark"] { --knob: #cfccc4; }

/* The rack's colour runs the full height of the page, however long the
   section is; the rack itself stays put. */
.app {
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: 100vh;
  background: linear-gradient(90deg, var(--screen) calc(var(--side) - 1px), var(--screen-hair) calc(var(--side) - 1px) var(--side), transparent var(--side));
}

/* ---------- the rack ---------- */

.side {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 12px 12px;
  overflow-y: auto;
  background: var(--screen);
  color: var(--screen-dim);
  scrollbar-width: none;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; font-weight: 700; font-size: 16px; color: var(--screen-ink); letter-spacing: -0.01em; }
.side .mark .tile { fill: #2a2a27; }
.side .mark .bowl { fill: #edebe5; }
.side .mark .legs { stroke: #edebe5; }
/* In the panel the mark's coal is the server: an ember while it runs, a coal
   catching while it starts or installs, ash when it is off. */
.app[data-fire="on"] .mark .coal { animation: coal 4.2s linear infinite; }
.app[data-fire="busy"] .mark .coal { animation: coal-catch 1.1s var(--ease) infinite alternate; }
.app[data-fire="off"] .mark .coal { stroke: #6b6861; filter: none; }
.app[data-fire="bad"] .mark .coal { stroke: var(--bad); filter: none; }
@keyframes coal {
  0%, 100% { filter: drop-shadow(0 0 2.5px var(--accent)); }
  17% { filter: drop-shadow(0 0 3.5px var(--accent)) brightness(1.12); }
  29% { filter: drop-shadow(0 0 2px var(--accent)) brightness(0.94); }
  52% { filter: drop-shadow(0 0 3px var(--accent)) brightness(1.06); }
  71% { filter: drop-shadow(0 0 1.5px var(--accent)) brightness(0.9); }
}
@keyframes coal-catch { from { stroke: #6b6861; filter: none; } to { stroke: var(--accent); filter: drop-shadow(0 0 2.5px var(--accent)); } }
@media (prefers-reduced-motion: reduce) { .app[data-fire] .mark .coal { animation: none; } }
.side-server {
  margin: 20px 0 4px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--screen-hair);
  background: rgba(255, 255, 255, 0.03);
}
.side-name { color: var(--screen-ink); font-weight: 600; font-size: 14px; line-height: 1.4; }
.side-state { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; }
.nav { display: grid; }
.nav-group { padding: 18px 10px 6px; font-size: 11px; line-height: 1.4; font-weight: 600; letter-spacing: 0.06em; color: var(--screen-faint); }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--screen-dim);
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.75; transition: opacity 0.15s; }
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--screen-ink); }
.nav a[data-ro]::after { content: "보기"; margin-left: auto; font: 500 11px var(--mono); color: var(--screen-faint); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.09); color: var(--screen-ink); }
.nav a[aria-current="page"] svg, .nav a:hover svg { opacity: 1; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 2px 2px 0; background: var(--screen-ink); }
.side-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 20px 10px 4px; font-size: 12px; color: var(--screen-faint); }
.side-foot svg { width: 15px; height: 15px; flex: none; }

/* ---------- the strip ---------- */

.main-col { min-width: 0; display: flex; flex-direction: column; }
.strip {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--strip);
  padding: 12px 40px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--hair);
}
.strip-state { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; }
.strip-state b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.strip-mark { display: none; flex: none; margin-right: 4px; }
.strip-facts { color: var(--ink-3); font-size: 13px; font-feature-settings: "tnum"; }
.app[data-route="overview"] .strip-facts { display: none; }
.strip-facts::before { content: ""; display: inline-block; width: 1px; height: 12px; margin: 0 12px 0 2px; background: var(--hair-2); vertical-align: -1px; }
.strip .btn { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.icon-btn { width: 40px; padding: 0; }
.addr-chip {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 40px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  background: transparent;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.addr-chip:hover { border-color: var(--line); background: var(--surface); }
.addr-chip svg { width: 15px; height: 15px; color: var(--ink-3); }
.power-group { display: flex; gap: 8px; }
.restart-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---------- a section ---------- */

.view { width: 100%; max-width: 1240px; padding: 36px 40px 96px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 28px; }
.view-title { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; }
.view-sub { margin: 6px 0 0; max-width: 42em; font-size: 15px; color: var(--ink-2); }
.view > * + * { margin-top: 24px; }
.view > .view-head + * { margin-top: 0; }
.stack { display: grid; gap: 24px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.cols.wide-right { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.cols.aside { grid-template-columns: minmax(0, 1fr) 320px; }
.cols.even { align-items: stretch; }

.box { overflow: hidden; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 10px 20px; border-bottom: 1px solid var(--hair); }
.box-title { margin: 0; font-size: 15px; line-height: 1.4; font-weight: 600; letter-spacing: -0.01em; }
.box-head .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.box-head .btn.icon-btn { width: 36px; padding: 0; }
.box-body { padding: 20px; }
.box-body p, p.box-body { margin: 0; }
.box-body.stack { gap: 16px; }
.box > p.box-body + .items { border-top: 1px solid var(--hair); }
.setting select.input { width: auto; min-width: 128px; }
.box-foot { padding: 12px 20px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--ink-3); }

/* A list row: a picture or icon, the words, then controls. */
.items { margin: 0; padding: 0; list-style: none; }
.item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  min-height: 64px;
  padding: 10px 20px;
}
.item.plain { grid-template-columns: minmax(0, 1fr) auto; }
.item + .item { border-top: 1px solid var(--hair); }
.item-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-weight: 500; line-height: 1.45; min-width: 0; }
.item-title > .clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item-sub { font-size: 13px; line-height: 1.45; color: var(--ink-3); }
.item-end { display: flex; align-items: center; gap: 6px; }
.item-end .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.item-end .btn.icon-btn { width: 36px; padding: 0; }
.item.off .item-title { color: var(--ink-3); }
.item.off .face, .item.off .tile-icon { opacity: 0.5; }
.tile-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-2); box-shadow: 0 0 0 1px var(--hair) inset; flex: none; }
.tile-icon svg { width: 20px; height: 20px; }
img.tile-icon { object-fit: cover; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 7px;
  border-radius: var(--r-sm);
  font: 500 11px/20px var(--sans);
  color: var(--ink-2);
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--hair) inset;
  white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tag svg { width: 12px; height: 12px; flex: none; stroke-width: 2; }
.tag .lamp { width: 8px; height: 3px; }
.tag.warn { color: color-mix(in srgb, var(--warn) 80%, var(--ink)); background: color-mix(in srgb, var(--warn) 14%, transparent); box-shadow: none; }
.tag.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); box-shadow: none; }
.nowrap { white-space: nowrap; }

/* ---------- controls ---------- */

.input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder { color: var(--ink-3); }
select.input {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2366635c' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.input.short { width: 96px; text-align: right; font-family: var(--mono); font-feature-settings: "tnum"; }
.input.mid { width: 300px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 36px; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--track); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: calc(var(--r-md) - 3px);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(23, 22, 20, 0.1), 0 0 0 1px var(--hair) inset; }
.seg button:disabled { opacity: 0.4; cursor: default; }
.seg-n { font: 500 11px var(--mono); color: var(--ink-3); font-feature-settings: "tnum"; }
.on-screen .seg { background: rgba(255, 255, 255, 0.06); }
.on-screen .seg button { color: var(--screen-dim); }
.on-screen .seg button:hover { color: var(--screen-ink); }
.on-screen .seg button[aria-selected="true"] { background: rgba(255, 255, 255, 0.12); color: var(--screen-ink); box-shadow: none; }

.toggle {
  position: relative;
  flex: none;
  width: 44px; height: 26px;
  padding: 0;
  border: 0; border-radius: 13px;
  background: var(--track);
  box-shadow: 0 0 0 1px var(--hair-2) inset;
  cursor: pointer;
  transition: background 0.25s var(--ease), box-shadow 0.25s;
}
.toggle::before {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 2px rgba(23, 22, 20, 0.3);
  transition: transform 0.32s var(--spring), background 0.25s;
}
.toggle[aria-checked="true"] { background: var(--fill); box-shadow: none; }
.toggle[aria-checked="true"]::before { transform: translateX(18px); background: var(--on-fill); }
.toggle:disabled { opacity: 0.4; cursor: default; }

.btn.working { position: relative; color: transparent !important; pointer-events: none; }
.btn.working:disabled { opacity: 1; }
.btn.working::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink-2); border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn-primary.working:disabled { background: var(--accent); box-shadow: none; }
.btn-primary.working::after { border-color: var(--on-accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-danger-solid { border-color: transparent; background: var(--bad); color: #fff; font-weight: 600; }
.btn-danger-solid:hover { border-color: transparent; background: color-mix(in srgb, var(--bad) 88%, #000); }
.btn-danger-solid:disabled { opacity: 1; background: var(--surface-2); color: var(--ink-3); box-shadow: 0 0 0 1px var(--hair) inset; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* ---------- dialogs and menus ---------- */

.dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--hair), 0 28px 64px -16px rgba(0, 0, 0, 0.4);
}
.dialog[open] { animation: pop 0.24s var(--spring); }
.dialog::backdrop { background: rgba(18, 18, 17, 0.42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-body { display: grid; gap: 16px; padding: 24px; }
.dialog-text { color: var(--ink-2); font-size: 15px; }
.dialog-text p { margin: 0; }
.dialog-text p + p { margin-top: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 24px 24px; }
.dialog-body > .dialog-actions { padding: 8px 0 0; }
.dialog-field, .dialog-type { display: grid; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.dialog-field small { font-weight: 400; font-size: 12px; color: var(--ink-3); }
.dialog-type b { display: inline-block; margin-left: 2px; padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair-2) inset; color: var(--ink); font-weight: 600; line-height: 24px; }
.dialog.wide { width: min(560px, calc(100vw - 32px)); }
.dialog-body .stack { gap: 16px; }
.dialog-body > .stack:empty { display: none; }
.time-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.menu {
  position: fixed; z-index: 60;
  display: grid;
  min-width: 208px;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hair-2), 0 18px 44px -14px rgba(0, 0, 0, 0.35);
  animation: pop 0.18s var(--ease);
}
.menu button {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: calc(var(--r-md) - 3px);
  background: none;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu button svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button.is-danger, .menu button.is-danger svg { color: var(--bad); }
.menu button:disabled { opacity: 0.4; cursor: default; }
.menu hr { height: 1px; margin: 6px 4px; border: 0; background: var(--hair); }

.empty { display: grid; justify-items: center; gap: 6px; padding: 48px 24px; text-align: center; }
.empty .title { font-size: 15px; }
.empty p { margin: 0; max-width: 30em; font-size: 14px; color: var(--ink-3); }
.empty .btn, .empty .row { margin-top: 12px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 24px; font-size: 14px; color: var(--ink-3); }

/* ---------- player faces ---------- */

.face {
  --s: 32px;
  display: grid; place-items: center;
  flex: none;
  width: var(--s); height: var(--s);
  border-radius: max(3px, calc(var(--s) / 8));
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--hair);
  image-rendering: pixelated;
  font-size: calc(var(--s) * 0.42); font-weight: 600; line-height: 1;
  color: var(--ink-2);
}
span.face { background: color-mix(in srgb, var(--ink) 8%, var(--surface)); }
.faces { display: flex; }
.faces > * + * { margin-left: -4px; }
/* The first face sits on top, so no initial or eye is cut by the next one. */
.faces > * { position: relative; }
.faces > :nth-child(1) { z-index: 4; }
.faces > :nth-child(2) { z-index: 3; }
.faces > :nth-child(3) { z-index: 2; }
.faces .face { box-shadow: 0 0 0 2px var(--surface); }
.faces .more { display: grid; place-items: center; height: 24px; padding: 0 8px; margin-left: 4px; font: 500 12px/1 var(--mono); color: var(--ink-3); }

/* ---------- overview ---------- */

.ov-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; }
.ov-addr { display: flex; flex-direction: column; gap: 0; padding: 20px 20px 18px 24px; }
.ov-addr .lcd-main { min-height: 56px; }
.ov-addr .num { font-size: clamp(28px, 2.6vw, 38px); }
.ov-addr .lcd-how { margin-top: 14px; }
.ov-addr .label { color: var(--screen-dim); }
.mc-entry {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  margin-top: auto;
  padding: 10px 12px 10px 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 0 1px var(--screen-hair) inset;
}
.invite { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 16px 0 20px; }
.invite span { font-size: 12px; color: var(--screen-faint); }
.mc-entry img, .mc-entry .ph { display: block; width: 40px; height: 40px; image-rendering: pixelated; }
.mc-entry .ph svg { width: 40px; height: 40px; opacity: 0.55; }
.mc-entry .ph .tile { fill: #2a2a27; }
.mc-entry .ph .bowl { fill: #edebe5; }
.mc-entry .ph .legs { stroke: #edebe5; }
.mc-text { min-width: 0; }
.mc-motd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.45; font-weight: 500; color: var(--screen-ink); }
.mc-ver { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.45; color: var(--screen-faint); }
.lcd.bad .mc-ver { color: var(--screen-bad); }
.mc-side { display: flex; align-items: center; gap: 10px; align-self: start; padding-top: 2px; }
.mc-count { font: 12px var(--mono); color: var(--screen-dim); font-feature-settings: "tnum"; }
.mc-ping { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.mc-ping i { width: 3px; background: rgba(255, 255, 255, 0.14); }
.mc-ping i:nth-child(1) { height: 3px; }
.mc-ping i:nth-child(2) { height: 5px; }
.mc-ping i:nth-child(3) { height: 7px; }
.mc-ping i:nth-child(4) { height: 9px; }
.mc-ping i:nth-child(5) { height: 12px; }
.mc-ping.on i { background: #3fd46f; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { display: grid; align-content: start; gap: 12px; padding: 18px 20px 20px; min-width: 0; }
.stat:nth-child(even) { border-left: 1px solid var(--hair); }
.stat:nth-child(n + 3) { border-top: 1px solid var(--hair); }
.stat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 22px; }
.stat-value { display: flex; align-items: baseline; gap: 6px; min-height: 34px; white-space: nowrap; }
.stat-value .num { font-size: 30px; line-height: 1; font-weight: 500; letter-spacing: -0.03em; }
.stat-value small { font-size: 13px; color: var(--ink-3); }
.stat-value.dim .num { color: var(--ink-3); }
.stat-value .off-word { font-size: 20px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-3); }
.stat .leds i { height: 8px; }
.stat-foot { font-size: 12px; color: var(--ink-3); min-height: 18px; }

.install { display: grid; align-content: start; gap: 14px; padding: 18px 20px 20px; }
.install-title { font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -0.02em; }
.install .leds i { height: 8px; }
.install-steps { display: grid; gap: 10px; margin: 2px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink-3); }
.install-steps li { display: flex; align-items: center; gap: 12px; }
.install-steps li > :first-child { flex: none; width: 16px; }
.install-steps svg { height: 16px; color: var(--ink); stroke-width: 2; }
.install-steps .num { font: 500 12px/1 var(--mono); text-align: center; }
.install-steps .lamp { width: 14px; }
.install-steps .done { color: var(--ink-2); }
.install-steps .now { color: var(--ink); font-weight: 500; }
.install-steps .now .num { position: relative; color: var(--accent); }
.install-steps .now .num::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: -5px; height: 2px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 4px var(--accent); }

.chart-card { padding: 16px 20px 14px; border-radius: var(--r-lg); background: var(--screen); color: var(--screen-ink); border: 1px solid var(--screen-hair); }
.chart-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.chart-now-value { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 14px; }
.chart-now-value .num { font-size: 28px; line-height: 1; font-weight: 500; letter-spacing: -0.02em; text-shadow: 0 0 18px rgba(255, 255, 255, 0.1); }
.chart-now-value span:last-child { font-size: 13px; color: var(--screen-faint); }
.chart { --tone: var(--screen-ink); }
.chart.idle { --tone: var(--screen-dim); }
.chart-plot { position: relative; height: 200px; margin-left: 48px; touch-action: pan-y; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--tone); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--tone) 7%, transparent); }
.chart-y { position: absolute; left: -48px; width: 38px; transform: translateY(-50%); text-align: right; font: 11px/1 var(--mono); color: var(--screen-faint); font-feature-settings: "tnum"; }
.chart-x { position: relative; height: 16px; margin: 10px 0 0 48px; }
.chart-x div { position: absolute; transform: translateX(-50%); font: 11px/16px var(--mono); color: var(--screen-faint); white-space: nowrap; }
/* The newest reading is the one live thing on the chart: an ember pixel. */
.chart-now { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.chart.idle .chart-now { background: var(--screen-dim); box-shadow: none; }
.chart-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.28); pointer-events: none; }
.chart-read { position: absolute; top: 0; transform: translate(-50%, -115%); padding: 3px 8px; border-radius: var(--r-sm); background: var(--screen-2); box-shadow: 0 0 0 1px var(--screen-hair); font: 11px/1.5 var(--mono); color: var(--screen-ink); white-space: nowrap; pointer-events: none; }
.chart-empty { display: grid; place-items: center; height: 200px; margin-top: 18px; color: var(--screen-faint); font-size: 14px; }

.feed { margin: 0; padding: 4px 0; list-style: none; }
.feed li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 9px 20px; font-size: 14px; color: var(--ink-2); }
.feed li > .face { margin-top: -1px; }
.feed li > svg { width: 18px; height: 18px; margin: 2px 3px 0; color: var(--ink-3); }
.feed li b { font-weight: 600; color: var(--ink); }
.feed li q { color: var(--ink); quotes: "“" "”"; }
.feed li.warn > svg { color: var(--warn); }
.feed li.bad > svg { color: var(--bad); }
.feed-box { display: flex; flex-direction: column; min-height: 460px; }
.feed-box > :last-child { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.feed-box:not(.all) .feed { flex: 1 1 0; min-height: 0; overflow: hidden; }
.feed.clipped { -webkit-mask-image: linear-gradient(#000 calc(100% - 64px), transparent); mask-image: linear-gradient(#000 calc(100% - 64px), transparent); }
.feed-box .feed-more { margin-top: auto; }
.feed-more { display: block; width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--hair); background: none; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s; }
.feed-more:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.feed-more:disabled { color: var(--ink-3); cursor: default; }
.feed time { font: 12px/22px var(--mono); color: var(--ink-3); white-space: nowrap; font-feature-settings: "tnum"; }

.facts-list { display: grid; grid-template-columns: auto minmax(0, 1fr); margin: 0; }
.facts-list dt, .facts-list dd { display: flex; align-items: center; margin: 0; padding: 12px 20px; border-top: 1px solid var(--hair); font-size: 14px; }
.facts-list dt { padding-right: 8px; color: var(--ink-3); }
.facts-list dd { justify-content: flex-end; text-align: right; color: var(--ink); }
.facts-list dd .btn.icon-btn { width: 32px; min-height: 32px; margin: -6px -8px -6px 0; border-color: transparent; background: transparent; }
.facts-list dd .btn.icon-btn:hover { border-color: var(--hair-2); }
.facts-list > :nth-child(-n + 2) { border-top: 0; }

/* ---------- console ---------- */

.console.full { margin-top: 0; display: flex; flex-direction: column; }
.console.full .console-out { height: auto; min-height: 280px; flex: 1; }
.console-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.console-wrap .console { height: calc(100vh - var(--strip) - 200px); min-height: 480px; position: sticky; top: calc(var(--strip) + 24px); }
.console-head .search .input { min-height: 36px; width: 200px; border-color: rgba(255, 255, 255, 0.14); background: transparent; color: var(--screen-ink); font-size: 13px; }
.console-head .search .input:focus { border-color: rgba(255, 255, 255, 0.35); box-shadow: none; }
.console-head .search svg { color: var(--screen-faint); }
.console-in { position: relative; }
/* 명령 | 말하기: both ways are on show, the chosen one lit. */
.console-in .mode { flex: none; display: inline-flex; gap: 2px; padding: 2px; border-radius: calc(var(--r-sm) + 2px); background: rgba(255, 255, 255, 0.06); }
.console-in .mode button {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--screen-faint);
  font: 600 12px var(--sans);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.console-in .mode button:hover:not(:disabled) { color: var(--screen-ink); }
.console-in .mode button[aria-checked="true"] { background: rgba(255, 255, 255, 0.12); color: var(--screen-ink); }
.console-in .mode button[aria-checked="true"]:last-child { color: var(--screen-me); }
.console-in .mode button:disabled { opacity: 0.4; cursor: default; }
.console-in input::placeholder { font-family: var(--sans); }
.console-in.chat input { font: 14px var(--sans); }
.console-in .send { flex: none; width: 40px; min-height: 40px; display: grid; place-items: center; border: 0; border-radius: var(--r-md); background: transparent; color: var(--screen-dim); cursor: pointer; }
.console-in .send:hover:not(:disabled) { color: var(--screen-ink); background: rgba(255, 255, 255, 0.06); }
.console-in .send svg { width: 18px; height: 18px; }
.console-in .send:disabled { opacity: 0.35; cursor: default; }
.suggest {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 8px); z-index: 3;
  margin: 0; padding: 6px; list-style: none;
  border-radius: var(--r-md);
  background: var(--screen-2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 18px 40px -10px rgba(0, 0, 0, 0.6);
}
.suggest li { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 8px 10px; border-radius: calc(var(--r-md) - 3px); cursor: pointer; }
.suggest li[aria-selected="true"] { background: rgba(255, 255, 255, 0.08); }
.suggest code { font: 12.5px var(--mono); color: var(--screen-ink); white-space: nowrap; }
.suggest span { font: 13px var(--sans); color: var(--screen-dim); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-out mark { background: color-mix(in srgb, var(--screen-warn) 30%, transparent); color: inherit; border-radius: 2px; }
.console-out .reply { color: var(--screen-ink); }
.console-out .reply time { visibility: hidden; }
.console .quick-row { display: none; padding: 0 12px 12px 20px; background: var(--screen-2); }
.console-out .empty-line { grid-template-columns: minmax(0, 1fr); color: var(--screen-faint); font-family: var(--sans); padding: 24px 0; text-align: center; }

.helper { display: grid; gap: 16px; }
.helper-group > .label { margin-bottom: 8px; }
.helper-group .items { border: 1px solid var(--hair); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.helper button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px 8px 14px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.helper li + li button { border-top: 1px solid var(--hair); }
.helper button:hover { background: var(--surface-2); }
.helper button span { font-size: 14px; }
.helper button code { font: 11.5px var(--mono); color: var(--ink-3); }
.helper button:disabled { cursor: default; opacity: 0.45; }

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

.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; min-height: 68px; padding: 14px 20px; }
.setting + .setting { border-top: 1px solid var(--hair); }
.setting-text { min-width: 0; }
.setting-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.setting-help { margin-top: 2px; font-size: 13px; line-height: 1.5; color: var(--ink-3); max-width: 36em; }
.setting.changed .setting-name::after { content: "바뀜"; height: 18px; padding: 0 6px; border-radius: var(--r-sm); background: var(--fill); color: var(--on-fill); font: 600 10.5px/18px var(--sans); }
.setting.wide { grid-template-columns: minmax(0, 1fr); }
.setting .input.text { width: min(360px, 40vw); }
.range { display: flex; align-items: center; gap: 14px; }
.range input { width: 200px; accent-color: var(--ink); }
.range output { min-width: 5.5em; text-align: right; font: 500 13px var(--mono); font-feature-settings: "tnum"; }
.icon-pick { display: flex; align-items: center; gap: 14px; }
.icon-pick img, .icon-pick .ph { width: 48px; height: 48px; border-radius: var(--r-sm); image-rendering: pixelated; box-shadow: 0 0 0 1px var(--hair-2); background: var(--surface-2); }
.icon-pick .ph { display: grid; place-items: center; color: var(--ink-3); }
.icon-pick .ph svg { width: 20px; height: 20px; }
.advanced > summary { cursor: pointer; }
.advanced > summary::before { margin-right: 4px; }
.advanced:not([open]) > summary { border-bottom: 0; }
.advanced .box-body p { margin: 0; }
.env-rows { display: grid; gap: 8px; }
.env-rows:empty { display: none; }
.env-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 36px; gap: 8px; }
.env-row .input { min-height: 40px; font: 13px var(--mono); }

/* The slot is what sticks: a sticky element cannot leave its parent, and the
   slot's parent is the whole section. */
.savebar-slot { position: sticky; bottom: 20px; z-index: 15; }
.savebar-slot:empty { display: none; }
.savebar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 24px;
  padding: 12px 12px 12px 20px;
  border-radius: var(--r-lg);
  background: var(--fill);
  color: var(--on-fill);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.5);
  animation: rise 0.35s var(--spring) both;
}
.savebar small { display: block; font-size: 13px; opacity: 0.7; }
.savebar-text { white-space: nowrap; }
.savebar .btn:not(.btn-primary) { background: transparent; color: var(--on-fill); border-color: color-mix(in srgb, var(--on-fill) 30%, transparent); }
.savebar .btn:not(.btn-primary):hover { border-color: var(--on-fill); }

/* ---------- mods ---------- */

.mod-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.mod-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.mod-meta span { display: inline-flex; align-items: center; gap: 5px; }
.mod-meta svg { width: 13px; height: 13px; }
.results .item { align-items: start; padding-top: 14px; padding-bottom: 14px; }
.results .tile-icon { width: 48px; height: 48px; }
.results .item-end { align-self: center; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar .input { min-height: 36px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 32px; padding: 0 12px; border: 1px solid var(--hair-2); border-radius: var(--r-md); background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.chips button:hover { border-color: var(--line); color: var(--ink); }
.chips button[aria-pressed="true"] { border-color: var(--fill); background: var(--fill); color: var(--on-fill); }

/* ---------- world ---------- */

.dims { display: grid; gap: 14px; padding: 20px; }
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rule-grid .setting { min-height: 80px; border-top: 1px solid var(--hair); }
.rule-grid .setting:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.rule-grid .setting:nth-child(-n + 2) { border-top: 0; }
.rule-grid .setting:nth-child(odd) { border-right: 1px solid var(--hair); }
.seed { display: flex; align-items: center; gap: 10px; }
.seed .num { font-size: 14px; }

/* ---------- backups ---------- */

.gauges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gauges > * { padding: 18px 20px 20px; }
.gauges .stat-foot { margin-top: 10px; }
/* A number field with its unit inside, so every control ends on one edge. */
.num-input { position: relative; display: inline-flex; }
.num-input .input.short { width: 112px; padding-right: calc(18px + var(--unit-w)); }
.num-input .input { appearance: textfield; }
.num-input .input::-webkit-inner-spin-button, .num-input .input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.num-input .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--ink-3); pointer-events: none; }
/* Each fact's dot hangs in the gap before it, so the one that would open a
   wrapped line falls outside the box and is clipped. */
.item-sub:has(> .meta) { display: flex; flex-wrap: wrap; column-gap: 15px; overflow: hidden; }
.meta { position: relative; min-width: 0; }
.meta::before { content: "·"; position: absolute; right: calc(100% + 5px); }
.gauges > * + * { border-left: 1px solid var(--hair); }
.when-big { font-weight: 600; font-feature-settings: "tnum"; }

/* ---------- schedule ---------- */

.task-time { display: grid; place-items: center; width: 64px; height: 44px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; font: 500 16px/1 var(--mono); font-feature-settings: "tnum"; }
.item.off .task-time { color: var(--ink-3); }
.cmd-chip { font: 12.5px var(--mono); color: var(--ink-2); padding: 1px 6px; border-radius: var(--r-sm); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; max-width: 32em; }
.day-card { padding: 16px 20px 14px; }
.day-head { display: flex; justify-content: space-between; }
.day { position: relative; height: 64px; margin: 4px 0 6px; }
.day-line { position: absolute; left: 0; right: 0; bottom: 14px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.day-past { height: 100%; background: var(--hair-2); }
.day-now { position: absolute; bottom: 6px; width: 2px; height: 20px; margin-left: -1px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.day-mark { position: absolute; z-index: 1; bottom: 6px; display: grid; justify-items: center; gap: 4px; transform: translateX(-50%); }
.day-mark i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--fill); color: var(--on-fill); box-shadow: 0 0 0 3px var(--surface); }
.day-mark i svg { width: 12px; height: 12px; stroke-width: 2; }
.day-mark.off i { background: var(--surface); color: var(--ink-3); box-shadow: 0 0 0 3px var(--surface), 0 0 0 1px var(--line) inset; }
.day-time { font: 500 11px/1 var(--mono); color: var(--ink-2); font-feature-settings: "tnum"; }
/* A time too close to the one before it hangs its label under the rail. */
.day-mark.low { bottom: -9px; }
.day-mark.low .day-time { order: 1; }
.day:has(.low) { margin-bottom: 20px; }
/* A dot that would sit on the one before it shrinks to a plain pip. */
.day-mark.tight { bottom: 11px; }
.day-mark.tight.low { bottom: -9px; gap: 9px; }
.day-mark.tight { z-index: 0; }
.day-mark.tight i { width: 10px; height: 10px; box-shadow: none; }
.day-mark.tight i svg { display: none; }
.day-mark.off .day-time { color: var(--ink-3); }
.day-axis { display: flex; justify-content: space-between; font: 11px/1 var(--mono); color: var(--ink-3); }
.days { display: flex; gap: 4px; }
.days button {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.days button[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); border-color: var(--fill); }
.suggestions { display: grid; gap: 8px; width: min(420px, 100%); margin-top: 12px; }
.suggestions .btn { justify-content: flex-start; }

/* ---------- files ---------- */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-left: -8px; font-size: 14px; min-width: 0; }
.crumbs button { min-height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); cursor: pointer; }
.crumbs button:hover { background: var(--surface-2); color: var(--ink); }
.crumbs button:last-child { color: var(--ink); font-weight: 600; }
.crumbs svg { width: 14px; height: 14px; color: var(--ink-3); }
.ftable { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.ftable td { padding: 0 12px; height: 56px; border-top: 1px solid var(--hair); }
.ftable tr:first-child td { border-top: 0; }
.ftable td:first-child { padding-left: 20px; }
.ftable td.act { width: 68px; padding-right: 20px; text-align: right; }
.ftable .fname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ftable .fname button { padding: 0; border: 0; background: none; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftable .fname button:hover { text-decoration: underline; text-decoration-color: var(--hair-2); text-underline-offset: 3px; }
.ftable .fname svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.ftable .fname-text { display: grid; min-width: 0; }
.ftable .fname-text button { justify-self: start; max-width: 100%; }
.ftable .fname-text small { font-size: 12px; color: var(--ink-3); font-feature-settings: "tnum"; }
.ftable .fname .dir svg { color: var(--ink-2); }
.ftable tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ftable .btn.icon-btn { width: 36px; min-height: 36px; }
.editor { border-radius: var(--r-lg); background: var(--screen); border: 1px solid var(--screen-hair); overflow: hidden; color: var(--screen-ink); }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--screen-hair); }
.editor-head .mono { font-size: 13px; color: var(--screen-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-head .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.editor-head .btn:not(.btn-primary) { background: transparent; color: var(--screen-ink); border-color: rgba(255, 255, 255, 0.2); }
.editor-head .btn-primary:disabled { background: rgba(255, 255, 255, 0.07); color: var(--screen-faint); box-shadow: none; }
.editor textarea {
  display: block;
  width: 100%;
  height: calc(100vh - var(--strip) - 240px);
  min-height: 360px;
  padding: 16px 20px;
  border: 0;
  background: transparent;
  color: var(--screen-ink);
  font: 13px/1.7 var(--mono);
  resize: none;
  outline: none;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

/* ---------- network ---------- */

.port-plate { display: grid; place-items: center; align-content: center; gap: 1px; width: 64px; height: 44px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; font: 500 10px/1.2 var(--mono); letter-spacing: 0.06em; color: var(--ink-3); }
.port-plate b { font: 500 15px/1.2 var(--mono); letter-spacing: 0; color: var(--ink); font-feature-settings: "tnum"; }
.dns { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 20px; margin: 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; font-size: 13px; }
.dns dt { color: var(--ink-3); }
.dns dd { margin: 0; font-family: var(--mono); color: var(--ink); }

/* ---------- machine ---------- */

/* The spec plate: printed like the label on the back of a unit. */
.plate { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.plate > div { padding: 18px 20px; min-width: 0; }
.plate > div + div { border-left: 1px solid var(--hair); }
.plate .num { display: block; margin-top: 6px; font-size: 22px; line-height: 1.2; font-weight: 500; letter-spacing: -0.02em; }
.plate small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; padding: 20px; }
.keycmd { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 14px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; font: 12.5px/1.6 var(--mono); color: var(--ink-2); }
.keycmd span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.keycmd .btn { flex: none; }
.keycmd .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.danger-zone .box-title { color: var(--bad); }

/* ---------- phone tabs (hidden on wide screens) ---------- */

.tabbar { display: none; }

/* ---------- friends who help run the server ---------- */

.item.member .face { font-size: 13px; font-weight: 600; }
.owner-only { max-width: 52em; margin: 0; padding: 0 4px; font-size: 13px; line-height: 1.6; color: var(--ink-3); }

.perm-dialog { display: flex; flex-direction: column; overflow: hidden; }
.perm-dialog[open] { display: flex; }
.perm-form { display: flex; flex-direction: column; min-height: 0; }
.perm-form > .dialog-body { overflow-y: auto; min-height: 0; }
.perm-form > .dialog-actions { padding-top: 16px; border-top: 1px solid var(--hair); }
.role-pick { display: grid; gap: 8px; }
.role-pick .seg { display: flex; width: 100%; }
.role-pick .seg button { flex: 1 0 auto; justify-content: center; }
.role-blurb { margin: 0; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.perm-rows { border-top: 1px solid var(--hair); }
.perm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.perm-name { font-weight: 500; font-size: 14px; }
.perm-help { margin-top: 1px; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.perm-row .seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 252px; }
.perm-row .seg button { justify-content: center; padding: 0 8px; font-size: 13px; }
.perm-sum { display: grid; gap: 8px; padding-top: 4px; }
.perm-sum .grant-list { margin: 0; }
.perm-sum .btn-text { justify-self: start; }
.perm-form > .dialog-body { mask-image: linear-gradient(#000 calc(100% - 24px), transparent); padding-bottom: 24px; }
.invite-who { margin: -6px 0 0; font-size: 14px; color: var(--ink-3); }

.invite-steps { display: grid; gap: 20px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.invite-steps > li { display: grid; gap: 10px; padding-left: 36px; position: relative; counter-increment: step; }
.invite-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--fill); color: var(--on-fill); font: 600 12px/1 var(--mono);
}
.invite-step-title { font-weight: 600; line-height: 24px; }
.invite-link { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 7px 7px 7px 14px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: 0 0 0 1px var(--hair) inset; font-size: 12.5px; color: var(--ink-2); }
.invite-link .clip { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.invite-pass { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 14px 14px 20px; }
.invite-pass .num { font-size: 30px; letter-spacing: 0.06em; }
.invite-note { margin: 0; font-size: 13px; color: var(--ink-3); }

/* What a friend sees where the owner kept the change for themselves. */
.read-only { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--hair-2) inset; font-size: 14px; font-weight: 500; color: var(--ink); }
.read-only svg { width: 18px; height: 18px; flex: none; color: var(--ink-2); }
.console-ro { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 24px; background: var(--screen-2); border-top: 1px solid var(--screen-hair); font-size: 13px; color: var(--screen-faint); }
.console-ro svg { width: 16px; height: 16px; flex: none; }
.console-wrap.solo { grid-template-columns: minmax(0, 1fr); }
fieldset.bare { min-width: 0; margin: 0; padding: 0; border: 0; }
/* Where a friend may only look, controls read as their values. */
.ro .toggle { width: auto; height: auto; background: none; box-shadow: none; opacity: 1; font: 500 14px var(--sans); color: var(--ink-3); }
.ro .toggle::before { content: none; }
.ro .toggle::after { content: "꺼짐"; }
.ro .toggle[aria-checked="true"]::after { content: "켜짐"; color: var(--ink); }
.ro .seg { padding: 0; background: none; }
.ro .seg button:not([aria-selected="true"]) { display: none; }
.ro .seg button[aria-selected="true"] { padding: 0; background: none; box-shadow: none; opacity: 1; font-size: 14px; }
.ro .input { min-height: 0; padding-left: 0; border-color: transparent; background: none; box-shadow: none; opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); text-align: right; font-size: 14px; }
.ro select.input { width: auto; padding-right: 0; background-image: none; }
.ro .input::placeholder { color: transparent; -webkit-text-fill-color: transparent; }
.ro input[type="range"] { display: none; }
.ro .btn:disabled { display: none; }
.gauges.single { grid-template-columns: minmax(0, 1fr); }

.side-server.switch { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.side-server.switch > svg { grid-column: 2; grid-row: 1 / span 2; width: 16px; height: 16px; color: var(--screen-faint); }
.side-server.switch:hover { background: rgba(255, 255, 255, 0.06); }
.side-server.switch:hover > svg { color: var(--screen-ink); }

.removed { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.removed-card { display: grid; justify-items: start; gap: 12px; max-width: 420px; padding: 32px; }
.removed-card .mark { width: 36px; height: 36px; }
.removed-card .title { margin: 8px 0 0; font-size: 20px; }
.removed-card p { margin: 0 0 8px; color: var(--ink-2); }

@property --seg-fade { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes seg-fade { 0%, 80% { --seg-fade: 32px; } 100% { --seg-fade: 0px; } }

@media (max-width: 1180px) {
  :root { --side: 224px; }
  .strip { padding: 12px 28px; }
  .view { padding: 32px 28px 96px; }
  .strip-facts { display: none; }
  .ov-top { grid-template-columns: minmax(0, 1fr); }
  .console-wrap { grid-template-columns: minmax(0, 1fr); }
  .console-wrap .helper { display: none; }
  .console .quick-row { display: flex; }
  .cols.aside { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .cols, .cols.wide-left, .cols.wide-right { grid-template-columns: minmax(0, 1fr); }
  .plate { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plate > div:nth-child(3) { border-left: 0; }
  .plate > div:nth-child(n + 3) { border-top: 1px solid var(--hair); }
  .rule-grid { grid-template-columns: minmax(0, 1fr); }
  .rule-grid .setting:nth-child(2) { border-top: 1px solid var(--hair); }
  .rule-grid .setting:nth-child(odd) { border-right: 0; }
}

@media (max-width: 760px) {
  :root { --strip: 64px; }
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { display: none; }
  .strip { gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .strip-state { font-size: 14px; }
  .strip-mark { display: block; }
  .strip-mark + .lamp { display: none; }
  .addr-chip, .restart-chip { display: none; }
  .power-group { gap: 6px; }
  .power-group .btn, .strip .btn.icon-btn { width: 44px; min-height: 44px; padding: 0; }
  .power-group .btn.btn-primary, .power-group .btn[data-act="stop"] { width: auto; padding: 0 18px; }
  .power-group .btn.btn-primary span, .power-group .btn[data-act="stop"] span { display: inline; }
  .power-group .btn[data-act="restart"] { display: none; }
  .power-group .btn span { display: none; }
  .view { padding: 24px 16px calc(104px + env(safe-area-inset-bottom)); }
  .view-head { margin-bottom: 20px; align-items: stretch; }
  .view-head > .row { width: 100%; }
  .view-head > .row > .btn { flex: 1; }
  .view-title { font-size: 24px; }
  .view-sub { font-size: 14px; }
  .stack, .cols, .ov-top { gap: 16px; }
  .view > * + * { margin-top: 16px; }
  .ov-addr { padding: 16px 16px 14px 18px; }
  .ov-addr .num { font-size: 26px; }
  .stat { padding: 16px; }
  .stat-value .num { font-size: 24px; }
  .chart-card { padding: 14px 14px 12px; }
  .chart-top { flex-direction: column; align-items: stretch; }
  .chart-plot { height: 170px; margin-left: 40px; }
  .chart-y { left: -40px; width: 32px; }
  .chart-x { margin-left: 40px; }
  .box-head { padding-left: 16px; padding-right: 16px; }
  .item { padding-left: 16px; padding-right: 16px; gap: 12px; }
  .item-end .btn { min-height: 44px; }
  .item-end .btn.icon-btn { width: 44px; }
  /* A text button with more beside it moves under the words; the switch and
     the menu stay in the right-hand column like every other row. */
  .item:has(> .item-end > .btn:not(.icon-btn) ~ *) { grid-template-columns: auto minmax(0, 1fr) auto auto; row-gap: 8px; }
  .item.plain:has(> .item-end > .btn:not(.icon-btn) ~ *) { grid-template-columns: minmax(0, 1fr) auto auto; }
  .item:has(> .item-end > .btn:not(.icon-btn) ~ *):not(:has(.toggle)) { grid-template-columns: auto minmax(0, 1fr) auto; }
  .item.plain:has(> .item-end > .btn:not(.icon-btn) ~ *):not(:has(.toggle)) { grid-template-columns: minmax(0, 1fr) auto; }
  .ftable .btn.icon-btn, .box-head .btn { min-height: 44px; }
  .ftable .btn.icon-btn, .box-head .btn.icon-btn { width: 44px; }
  /* Five tabs are wider than a phone: the strip scrolls and fades at the
     end that still has more, until it is scrolled there. */
  .perm-row { grid-template-columns: minmax(0, 1fr); }
  .perm-row .seg { display: flex; width: 100%; }
  .perm-row .seg button { flex: 1 0 auto; justify-content: center; }
  .invite-pass .num { font-size: 24px; }
  .tabs .seg { display: flex; width: 100%; mask-image: linear-gradient(90deg, #000 calc(100% - var(--seg-fade)), transparent); }
  @supports (animation-timeline: scroll()) {
    .tabs .seg { animation: seg-fade linear both; animation-timeline: scroll(self inline); }
  }
  .tabs .seg button { flex: 1 0 auto; justify-content: center; padding: 0 9px; }
  .console-in .mode button { min-height: 36px; }
  .item:has(> .item-end > .btn:not(.icon-btn) ~ *) > .item-end { display: contents; }
  .item:has(> .item-end > .btn:not(.icon-btn) ~ *) > .item-end > .btn:not(.icon-btn) { grid-row: 2; grid-column: 2; justify-self: start; }
  .item.plain:has(> .item-end > .btn:not(.icon-btn) ~ *) > .item-end > .btn:not(.icon-btn) { grid-column: 1; }
  .item:has(> .item-end > .btn:not(.icon-btn) ~ *) > .tile-icon { align-self: start; }
  /* A plain row with one text button puts it under the words, which then
     keep the full width. */
  .item.plain:has(> .item-end > .btn:not(.icon-btn):only-child) { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
  .item.plain:has(> .item-end > .btn:not(.icon-btn):only-child) > .item-end { justify-self: start; }
  /* On a phone the recovery nudge is its title and buttons only. */
  .rec-nudge p { display: none; }
  .rec-nudge .row { margin-top: 12px; }
  .editor-head { padding: 10px 16px; }
  .ftable td.act { padding-right: 16px; width: 72px; }
  .feed li { padding: 9px 16px; gap: 10px; }
  .facts-list dt, .facts-list dd { padding: 12px 16px; }
  .setting { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; }
  .setting:has(> .toggle), .setting:has(> .num-input) { grid-template-columns: minmax(0, 1fr) auto; }
  .setting .input.text, .input.mid { width: 100%; }
  .range input { flex: 1; width: auto; }
  .gauges { grid-template-columns: minmax(0, 1fr); }
  .gauges > * + * { border-left: 0; border-top: 1px solid var(--hair); }
  .meters { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .console-wrap .console { position: static; height: calc(100vh - var(--strip) - 260px); min-height: 420px; }
  .console-head { padding: 10px 10px 10px 16px; }
  .console-head .search { display: none; }
  .ftable td:first-child { padding-left: 16px; }
  .editor textarea { height: 60vh; padding: 14px 16px; }
  .savebar-slot { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .savebar { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .savebar-text { padding-left: 4px; }
  .savebar-text { white-space: normal; }
  .savebar small { font-size: 12px; }
  .savebar .row { flex: 1 1 100%; flex-wrap: nowrap; }
  .savebar .row .btn-primary { flex: 1; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    backdrop-filter: blur(16px) saturate(1.2);
    border-top: 1px solid var(--hair);
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; align-content: center; gap: 3px;
    min-height: 56px;
    border: 0; background: none;
    color: var(--ink-3);
    font-size: 11px; font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar [aria-current="page"], .tabbar [aria-expanded="true"] { color: var(--ink); }
  .tabbar:has([aria-expanded="true"]) a[aria-current="page"] { color: var(--ink-3); }
  .tabbar:has([aria-expanded="true"]) a[aria-current="page"] svg { stroke-width: 1.6; }
  .tabbar [aria-current="page"] svg { stroke-width: 2; }
}
