/* ---------- tokens ---------- */
:root {
  --ground: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F6;
  --line: #DEE3EB;
  --ink: #16202B;
  --muted: #69768A;

  --washer: #1F6FEB;
  --washer-soft: #E4EEFD;
  --dryer: #E8892B;
  --dryer-soft: #FCEEDD;
  --busy: #D7373F;
  --busy-soft: #FBE3E4;
  --broken: #8B95A3;
  --broken-soft: #E9ECF0;
  --ok: #1F9D55;

  --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 8px 24px rgba(22, 32, 43, .06);
  --radius: 18px;
  --tab-h: 64px;

  --font-display: "Sora", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0F141A;
    --surface: #171E26;
    --surface-2: #1F2831;
    --line: #2A3441;
    --ink: #E8EDF2;
    --muted: #93A0B0;
    --washer: #5B9BFF;
    --washer-soft: #17283F;
    --dryer: #F5A052;
    --dryer-soft: #3A2814;
    --busy: #FF6B72;
    --busy-soft: #3E1C1F;
    --broken: #7C8796;
    --broken-soft: #242C36;
    --ok: #3FCB7A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0F141A;
  --surface: #171E26;
  --surface-2: #1F2831;
  --line: #2A3441;
  --ink: #E8EDF2;
  --muted: #93A0B0;
  --washer: #5B9BFF;
  --washer-soft: #17283F;
  --dryer: #F5A052;
  --dryer-soft: #3A2814;
  --busy: #FF6B72;
  --busy-soft: #3E1C1F;
  --broken: #7C8796;
  --broken-soft: #242C36;
  --ok: #3FCB7A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
a { color: var(--washer); }
button { font: inherit; color: inherit; }
.wrap { width: min(100%, 720px); margin-inline: auto; padding-inline: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--washer); outline-offset: 3px; border-radius: 6px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top__row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: conic-gradient(from 210deg, var(--washer), var(--dryer), var(--washer));
  position: relative;
}
.brand__mark::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  background: var(--ground);
}
.top__meta { display: flex; align-items: center; gap: 12px; }
.sync { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sync.is-error { color: var(--busy); }
.lang {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 10px; font-size: .75rem; font-weight: 600; letter-spacing: .06em; cursor: pointer;
}

/* ---------- board ---------- */
.view { padding-block: 20px 32px; }
.lede { margin: 0 0 12px; color: var(--muted); max-width: 60ch; }
.notice {
  background: var(--dryer-soft); color: var(--ink); border-left: 3px solid var(--dryer);
  padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .9375rem;
}
.section-title {
  display: flex; align-items: baseline; gap: 10px;
  font-size: .8125rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 10px;
}
.section-title small { font-weight: 500; letter-spacing: 0; text-transform: none; font-family: var(--font-body); }
.section-title .dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.section-title--washer .dot { background: var(--washer); }
.section-title--dryer .dot { background: var(--dryer); }

.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.card {
  --tone: var(--washer); --tone-soft: var(--washer-soft);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  text-align: left;
  cursor: pointer;
  display: grid; gap: 8px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
  overflow: hidden;
}
.card:active { transform: scale(.985); }
.card[data-kind="dryer"] { --tone: var(--dryer); --tone-soft: var(--dryer-soft); }
.card[data-status="running"], .card[data-status="done"] { --tone: var(--busy); --tone-soft: var(--busy-soft); }
.card[data-status="broken"] { --tone: var(--broken); --tone-soft: var(--broken-soft); }
.card[data-status="broken"] .card__num { color: var(--broken); }
.card[data-mine="true"]::after {
  content: "";
  position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent);
}

.card__head { display: flex; align-items: center; justify-content: space-between; }
.card__num {
  font-family: var(--font-display); font-weight: 700; font-size: 2.25rem; line-height: 1;
  color: var(--tone); letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.card__kind {
  font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.card__kind .kg { font-weight: 400; letter-spacing: 0; text-transform: none; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--tone-soft); color: var(--tone);
  border-radius: 999px; padding: 4px 10px;
  font-size: .8125rem; font-weight: 600; width: fit-content; max-width: 100%;
}
.pill__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.card[data-status="running"] .pill__dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.card__sub { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.card__sub strong { color: var(--ink); font-weight: 600; }

.bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--tone); border-radius: 2px; transition: width 1s linear; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 22px 0 0; font-size: .8125rem; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch--free-washer { background: var(--washer); }
.swatch--free-dryer { background: var(--dryer); }
.swatch--busy { background: var(--busy); }
.swatch--broken { background: var(--broken); }

/* ---------- busy ---------- */
.h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.h3 { font-size: 1.0625rem; font-weight: 600; margin: 22px 0 6px; }
.heat-wrap { overflow-x: auto; margin-top: 16px; padding-bottom: 4px; }
.heat {
  display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 3px;
  min-width: 620px; font-size: .6875rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.heat__lbl { display: flex; align-items: center; position: sticky; left: 0; background: var(--ground); z-index: 1; }
.heat__hr { text-align: center; }
.heat__cell {
  aspect-ratio: 1; border-radius: 3px;
  background: color-mix(in srgb, var(--washer) calc(var(--v) * 100%), var(--surface-2));
}
.heat__cell[data-now="true"] { outline: 2px solid var(--ink); outline-offset: -2px; }

/* ---------- info ---------- */
.facts { margin: 16px 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.facts__row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts__row dt { color: var(--muted); font-size: .875rem; font-weight: 500; }
.facts__row dd { margin: 0; }
@media (max-width: 420px) { .facts__row { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- feedback ---------- */
.fb { display: grid; gap: 10px; margin-top: 14px; }
.fb textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 12px; font: inherit; line-height: 1.45;
}
.fb__row { display: flex; align-items: center; justify-content: space-between; }
.fb .is-ok { color: var(--ok); }
.fb .is-err { color: var(--busy); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .12s ease, transform .12s ease;
}
a.btn { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.btn--washer { background: var(--washer); border-color: var(--washer); color: #fff; }
.btn--dryer { background: var(--dryer); border-color: var(--dryer); color: #fff; }
.btn--danger { color: var(--busy); }
.btn--block { width: 100%; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
@media (min-width: 720px) {
  .tabs { grid-template-columns: repeat(4, 140px); justify-content: center; }
}
.tab {
  background: none; border: 0; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .6875rem; font-weight: 600; letter-spacing: .02em;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--ink); }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(10, 14, 20, .45); }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  max-width: 560px; margin-inline: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet__title { font-size: 1.25rem; font-weight: 600; }
.sheet__panel .muted { margin: 4px 0 14px; }
.actions { display: grid; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.field { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.field input[type="number"] {
  width: 90px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-variant-numeric: tabular-nums;
}
.field input[type="text"] {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font: inherit;
}
.check { display: flex; align-items: center; gap: 10px; font-size: .9375rem; margin-bottom: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--washer); }
.hint { font-size: .8125rem; color: var(--muted); margin: -6px 0 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 999px;
  font-size: .875rem; font-weight: 500; z-index: 30; box-shadow: var(--shadow); max-width: calc(100% - 40px);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
