/* wolpi — a night-time remote control. Single deliberate dark look. */
:root {
  --app: #13171a;
  --surface: #1a1f23;
  --surface-2: #222830;
  --line: #2b323a;
  --fg: #e8ecee;
  --muted: #8a959d;
  --on: #3ddc84;
  --boot: #f5b83d;
  --off: #6b757d;
  --bad: #ff6b6b;
  --bad-dim: rgba(255,107,107,.13);
  --accent: #7cc4ff;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--app); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5; overscroll-behavior: none; }
.screen { position: relative; height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }

/* toast */
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); transform: translateX(-50%); z-index: 20; background: rgba(40,46,52,.97); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast.bad { border-color: rgba(255,107,107,.5); }

/* chrome */
.view { flex: 1; overflow-y: auto; padding: 10px 18px 18px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.apphead { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.brand { font: 700 22px var(--font); letter-spacing: .02em; }
.brand span { color: var(--on); }
.brand.big { font-size: 38px; text-align: center; }
.conn { font-size: 12px; border-radius: 999px; padding: 3px 10px; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); color: var(--muted); white-space: nowrap; }
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--on); }
.conn.bad { background: var(--bad-dim); color: var(--bad); }
.conn.bad::before { background: var(--bad); }
.conn.wait::before { background: var(--off); }
.lbl { font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.pad { padding: 0 4px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 0; }

/* power */
.power-card { background: var(--surface); border-radius: 22px; padding: 18px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pc-label { font-size: 12.5px; color: var(--muted); letter-spacing: .06em; align-self: flex-start; }
.pbtn { position: relative; width: 168px; height: 168px; border-radius: 50%; border: 0; background: radial-gradient(circle at 50% 40%, #232a30, #161b1f 70%); cursor: pointer; display: grid; place-items: center; color: var(--off); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pbtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.pbtn:disabled { cursor: default; }
.pbtn svg.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.pbtn svg.ring circle { fill: none; stroke-width: 6; }
.pbtn .track { stroke: #2a3138; }
.pbtn .prog { stroke: var(--on); stroke-linecap: round; stroke-dasharray: 490; stroke-dashoffset: 490; }
.pbtn .glyph { width: 56px; height: 56px; }
.pbtn.on { color: var(--on); box-shadow: 0 0 0 1px rgba(61,220,132,.35), 0 0 40px rgba(61,220,132,.18); }
.pbtn.on .track { stroke: rgba(61,220,132,.45); }
.pbtn.boot { color: var(--boot); }
.pbtn.boot .track { stroke: rgba(245,184,61,.35); }
.pbtn.boot svg.ring { animation: spin 1.4s linear infinite; }
.pbtn.boot .prog { stroke: var(--boot); stroke-dashoffset: 360; }
@keyframes spin { to { transform: rotate(270deg); } }
.state { font-size: 22px; font-weight: 700; text-align: center; }
.state.on { color: var(--on); } .state.boot { color: var(--boot); }
.substate { font-size: 13.5px; color: var(--muted); text-align: center; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.hint { font-size: 12.5px; color: var(--muted); background: var(--surface-2); padding: 4px 12px; border-radius: 999px; text-align: center; }
.hint.bad { color: var(--bad); background: var(--bad-dim); }

/* tiles */
.sect { display: flex; align-items: baseline; justify-content: space-between; }
.sect h2 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }
.sect .upd { font: 12px var(--mono); color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border-radius: 14px; padding: 10px 10px 9px; min-width: 0; display: flex; flex-direction: column; gap: 4px; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; position: relative; }
.tile::after { content: "›"; position: absolute; right: 9px; top: 6px; color: var(--muted); font-size: 14px; }
.tile:active { transform: scale(.97); }
.tile:disabled { cursor: default; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile .k { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.tile .v { font: 600 16px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .v small, .sv small, .bignum small { font: 400 11px var(--mono); color: var(--muted); margin-left: 2px; }
.tile .v.warn { color: var(--boot); }
.mbar { height: 4px; border-radius: 2px; background: #2a3138; overflow: hidden; display: block; }
.mbar i { display: block; height: 100%; width: 0; background: var(--on); transition: width .5s ease; }
.mbar i.warn { background: var(--boot); }
.tiles.dim .v { color: var(--off); }
.refresh-row { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* detail */
.detail { animation: pushin .28s cubic-bezier(.2,.9,.3,1); }
.detail.leaving { animation: pushout .2s ease forwards; }
@keyframes pushin { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pushout { to { transform: translateX(40px); opacity: 0; } }
.dnav { display: flex; align-items: center; min-height: 32px; margin-bottom: -6px; }
.back { background: transparent; border: 0; color: var(--accent); font: 500 16px var(--font); padding: 4px 6px 4px 0; cursor: pointer; }
.back:focus-visible { outline: 2px solid var(--accent); border-radius: 6px; }
.dtitle { margin: 0; font-size: 24px; font-weight: 700; }
.sh-now { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bignum { font: 600 34px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.bignum small { font-size: 15px; }
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--on); }
.rseg { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 2px; background: var(--surface); padding: 3px; border-radius: 10px; }
.rseg button { font: 500 12px var(--font); white-space: nowrap; color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 6px 0; cursor: pointer; }
.rseg button[aria-pressed="true"] { background: var(--surface-2); color: var(--fg); }
.rseg button:focus-visible { outline: 2px solid var(--accent); }
#chartPanel { display: flex; flex-direction: column; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.stat .sk { font-size: 11.5px; color: var(--muted); }
.stat .sv { font: 600 16px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .st { font: 11px var(--mono); color: var(--muted); }
.chart-wrap { position: relative; background: var(--surface); border-radius: 14px; padding: 8px 6px 4px; touch-action: pan-y; min-height: 200px; }
.chart-wrap svg { display: block; width: 100%; height: 190px; overflow: visible; }
.chart-wrap .grid line { stroke: #2a3138; stroke-width: 1; }
.chart-wrap .ax text { fill: var(--muted); font: 10.5px var(--mono); }
.chart-wrap .line { fill: none; stroke: var(--on); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .area { fill: var(--on); opacity: .08; }
.chart-wrap .warnline { stroke: var(--boot); stroke-width: 1; stroke-dasharray: 4 4; }
.chart-wrap .warntxt { fill: var(--boot); font: 10.5px var(--mono); }
.chart-wrap .ext { fill: var(--app); stroke: var(--fg); stroke-width: 2; }
.chart-wrap .extt { fill: var(--fg); font: 600 10.5px var(--mono); }
.chart-wrap .xh { stroke: var(--muted); stroke-width: 1; }
.chart-wrap .xd { fill: var(--on); stroke: var(--app); stroke-width: 2; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; }
.tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; font: 12px var(--mono); white-space: nowrap; pointer-events: none; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.tip b { font-weight: 600; }
.tip span { color: var(--muted); margin-left: 6px; }
.sh-note { font-size: 12.5px; color: var(--muted); }
.boots { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 12px; }
.boots li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.boots li:last-child { border-bottom: 0; }
.boots li span:last-child { color: var(--muted); font: 12px var(--mono); white-space: nowrap; }
.boots .empty { color: var(--muted); }

/* history */
.tl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl li { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); align-items: start; }
.tl .dot { width: 10px; height: 10px; border-radius: 50%; margin: 6px auto 0; background: var(--off); }
.tl .dot.on { background: var(--on); } .tl .dot.boot { background: var(--boot); } .tl .dot.bad { background: var(--bad); } .tl .dot.info { background: var(--accent); }
.tl .t { font-size: 14px; } .tl .d { font-size: 12.5px; color: var(--muted); }
.tl .tm { font: 12px var(--mono); color: var(--muted); padding-top: 2px; white-space: nowrap; }
.tl .empty { display: block; color: var(--muted); text-align: center; padding: 40px 0; border: 0; }

/* settings */
.set-group { background: var(--surface); border-radius: 16px; padding: 4px 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.set-row:last-child { border-bottom: 0; }
.set-row .sd { font-size: 12px; color: var(--muted); }
.seg { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; margin: 6px 0 12px; }
.seg button { font: 600 13px var(--mono); color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 7px 0; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--app); color: var(--fg); }
.seg button:focus-visible { outline: 2px solid var(--accent); }
.sw { position: relative; width: 46px; height: 28px; flex: none; }
.sw input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.sw span { position: absolute; inset: 0; background: #39424a; border-radius: 999px; transition: background .2s; pointer-events: none; }
.sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sw input:checked + span { background: var(--on); }
.sw input:checked + span::after { transform: translateX(18px); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill { font: 500 13px var(--font); color: var(--fg); background: var(--surface-2); border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.pill:disabled { opacity: .5; cursor: default; }
.pill:focus-visible { outline: 2px solid var(--accent); }
.danger { color: var(--bad); background: transparent; border: 0; font: 500 14.5px var(--font); padding: 12px 0; cursor: pointer; width: 100%; text-align: left; }

/* tab bar */
.tabbar { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: rgba(19,23,26,.97); padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.tabbar button { background: transparent; border: 0; color: var(--muted); font: 500 11px var(--font); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; cursor: pointer; position: relative; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-selected="true"] { color: var(--fg); }
.tabbar button:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font: 700 10px var(--mono); display: grid; place-items: center; padding: 0 4px; }

/* login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 0 28px 60px; }
.login .sub { margin: 0 0 18px; color: var(--muted); text-align: center; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login input { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--fg); font: 16px var(--font); }
.login input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.err { color: var(--bad); font-size: 13px; }
.primary { width: 100%; background: var(--on); color: #06210f; border: 0; border-radius: 12px; padding: 13px; font: 700 15px var(--font); cursor: pointer; }
.primary:disabled { opacity: .6; }
.primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login .note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .mbar i, .sw span, .sw span::after { transition: none; }
  .pbtn.boot svg.ring, .detail, .detail.leaving { animation: none; }
}
