/* wardrobe — portable-synth body: aluminium ground, off-white keycaps, one black dot-matrix band. */
:root {
  --ground: #d8d8d5;
  --frame: #e6e5e1;
  --key: #f5f4f0;
  --key-edge: #c9c7c1;
  --key-hi: rgba(255, 255, 255, .85);
  --key-shade: rgba(40, 38, 32, .16);
  --ink: #161616;
  --muted: #6e6d68;
  --line: #cfcdc7;
  --screen: #0c0c0c;
  --screen-ink: #f1f0ec;
  --screen-dim: #6a6964;
  --accent: #ea5a2b;
  --accent-ink: #ffffff;
  --danger: #c62828;
  --ok: #4caf6a;
  --scrim: rgba(20, 20, 18, .5);
  --c-pants: #3f66cf;
  --c-tee: #ea5a2b;
  --c-outer: #b88f5c;
  --c-shoes: #8f9193;
  --c-tops: #e9e7e1;
  --c-bag: #d23b3b;
  --font-dot: "Doto", "Space Mono", ui-monospace, monospace;
  --font-dotjp: "DotGothic16", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "Consolas", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121212; --frame: #1a1a1a; --key: #242423; --key-edge: #0a0a0a; --key-hi: rgba(255, 255, 255, .06);
    --key-shade: rgba(0, 0, 0, .5); --ink: #eeede9; --muted: #9b9a95; --line: #34332f;
    --screen: #050505; --screen-dim: #5a5954; --accent: #f0663a; --accent-ink: #160a05;
    --danger: #ef5350; --scrim: rgba(0, 0, 0, .7); --c-tops: #d9d7d0;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { touch-action: pan-y; background: var(--ground); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.6; padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--screen); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.key {
  background: var(--key); border: 0; border-radius: 12px; cursor: pointer; color: var(--ink);
  box-shadow: inset 0 1px 0 var(--key-hi), 0 1px 0 var(--key-edge), 0 3px 8px -2px var(--key-shade);
  transition: transform .06s, box-shadow .06s;
}
.key:active { transform: translateY(1px); box-shadow: inset 0 1px 0 var(--key-hi), 0 0 0 var(--key-edge), 0 1px 3px -1px var(--key-shade); }
.label { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* black band = the device screen */
.band { background: var(--screen); color: var(--screen-ink); padding-top: env(safe-area-inset-top, 0px); border-radius: 0 0 22px 22px; position: relative; overflow: hidden; }
.band::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1.2px); background-size: 4px 4px; }
.band-in { display: grid; gap: 12px; padding-block: 14px 18px; position: relative; z-index: 1; }
.topline { display: flex; align-items: center; justify-content: space-between; }
.topline h1 { margin: 0; font-family: var(--font-dot); font-weight: 900; font-size: 1.8rem; line-height: 1; letter-spacing: .04em; }
.menubtn { width: 44px; height: 36px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer; }
.menubtn i { width: 5px; height: 5px; border-radius: 50%; background: var(--screen-ink); }
.stats { display: flex; align-items: flex-end; gap: 10px; }
.big { font-family: var(--font-dot); font-weight: 900; font-size: clamp(3.4rem, 15vw, 5.2rem); line-height: .85; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.big-unit { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .14em; color: var(--screen-dim); padding-bottom: 4px; }
.state { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: .64rem; letter-spacing: .14em; color: var(--screen-dim); padding-bottom: 4px; }
.lamp { width: 7px; height: 7px; border-radius: 50%; background: var(--screen-dim); }
.state[data-s="ok"] .lamp { background: var(--ok); }
.state[data-s="busy"] .lamp { background: var(--accent); }
.state[data-s="off"] .lamp { background: var(--danger); }
.tape { display: flex; height: 8px; gap: 2px; }
.tape span { display: block; height: 100%; border-radius: 1px; min-width: 3px; }
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; font-size: .78rem; }
@media (min-width: 640px) { .legend { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.legend div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.legend b { font-family: var(--font-dot); font-weight: 900; font-size: 1rem; margin-left: auto; font-variant-numeric: tabular-nums; }
.sw { width: 8px; height: 8px; border-radius: 2px; flex: none; }

/* sticky controls */
.rail { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--ground); }
.rail-in { display: grid; gap: 8px; padding-block: 12px 6px; }
.search { display: flex; gap: 8px; }
.field {
  background: var(--frame); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 16px; min-width: 0;
  box-shadow: inset 0 1px 2px var(--key-shade); color: var(--ink);
}
.search input { flex: 1; }
.search select { font-size: 14px; padding-inline: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; padding: 2px 2px 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; font-size: .84rem; }
.chip .n { font-family: var(--font-mono); font-size: .7rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--key); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.led { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.status { display: flex; justify-content: space-between; align-items: baseline; padding-block: 6px 10px; }
.status button { background: none; border: 0; cursor: pointer; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; color: var(--accent); padding: 0; }

/* keycap cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; padding-bottom: 110px; }
@media (max-width: 380px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
@media (max-width: 520px) and (min-width: 381px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { display: grid; grid-template-rows: auto 1fr; text-align: left; padding: 6px; border-radius: 16px; min-width: 0; }
.ph { position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: #fff; max-width: 100%; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.none { position: absolute; inset: 0; display: grid; place-items: center; background: var(--frame); color: var(--muted); font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; }
.no { position: absolute; left: 6px; top: 6px; background: var(--screen); color: var(--screen-ink); font-family: var(--font-dot); font-weight: 900; font-size: .82rem; line-height: 1; padding: 4px 6px 3px; border-radius: 5px; }
.meta { padding: 8px 6px 4px; display: grid; gap: 4px; min-width: 0; }
.meta .name { font-size: .88rem; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.meta .sub { display: flex; align-items: center; gap: 6px; min-width: 0; font-family: var(--font-mono); font-size: .66rem; letter-spacing: .06em; color: var(--muted); }
.meta .sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.dotmsg { font-family: var(--font-dotjp); font-size: 1.05rem; color: var(--ink); }

/* add key */
.fab {
  position: fixed; z-index: 8; right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
}
.fab i { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-style: normal; font-size: 1.3rem; font-weight: 700; line-height: 1; }
.fab span { position: absolute; bottom: 5px; font-family: var(--font-mono); font-size: .56rem; letter-spacing: .14em; color: var(--muted); }

/* sheet */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: grid; place-items: end center; overscroll-behavior: contain; touch-action: pan-y; }
@media (min-width: 720px) { .overlay { place-items: center; } }
.sheet { width: 100%; max-width: 560px; max-height: calc(100% - env(safe-area-inset-top, 0px) - 12px); overflow-y: auto; overscroll-behavior: contain; background: var(--frame); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (min-width: 720px) { .sheet { border-radius: 20px; max-height: 92vh; } }
.bigph { margin: 10px 10px 0; border-radius: 14px; overflow: hidden; background: #fff; position: relative; min-height: 120px; }
.bigph img { width: 100%; max-height: 58vh; object-fit: contain; display: block; }
.sbody { padding: 14px max(18px, env(safe-area-inset-left, 0px)) 18px max(18px, env(safe-area-inset-right, 0px)); display: grid; gap: 14px; }
.sbody h2 { margin: 0; font-size: 1.15rem; font-weight: 700; text-wrap: balance; }
.sbody dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; align-items: center; }
.sbody dt { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.sbody dd { margin: 0; display: flex; align-items: center; gap: 6px; font-size: .92rem; overflow-wrap: anywhere; min-width: 0; }
.memo { white-space: pre-wrap; }
.row { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 10px; }
.btn { padding: 11px 8px; font-size: .88rem; text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); color: var(--key); }
.btn.warn { color: var(--danger); }
.btn.warn.armed { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

form.edit { display: grid; gap: 12px; }
form.edit label { display: grid; gap: 4px; min-width: 0; }
form.edit .field { width: 100%; background: var(--key); }
form.edit textarea { resize: vertical; min-height: 64px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-pick { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.thumb { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--key); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-family: var(--font-mono); font-size: .64rem; letter-spacing: .1em; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pickbtn { position: relative; overflow: hidden; display: grid; place-items: center; }
.pickbtn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.note { font-size: .82rem; color: var(--muted); }
.err { font-size: .82rem; color: var(--danger); }
.menu-list { display: grid; gap: 10px; }
.menu-list .btn { text-align: left; padding-inline: 16px; }
.who { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); overflow-wrap: anywhere; }

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: var(--screen); color: var(--screen-ink); font-family: var(--font-dotjp); padding: 8px 16px; border-radius: 10px; font-size: .9rem; max-width: calc(100% - 32px);
}

/* login */
.login { position: fixed; inset: 0; z-index: 40; background: var(--screen); color: var(--screen-ink); overflow-y: auto; display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
.login-in { width: 100%; max-width: 360px; display: grid; gap: 18px; justify-items: center; }
.login h1 { margin: 0; font-family: var(--font-dot); font-weight: 900; font-size: 2.4rem; letter-spacing: .04em; line-height: 1; }
.logo { display: grid; grid-template-columns: repeat(9, 12px); gap: 6px; }
.logo span { width: 12px; height: 12px; border-radius: 50%; background: #232321; }
.logo span.on { background: var(--screen-ink); }
.logo span.led { background: var(--accent); }
#login-form { width: 100%; display: grid; gap: 12px; }
#login-form label { display: grid; gap: 4px; }
#login-form .label { color: var(--screen-dim); }
#login-form .field { width: 100%; background: #1b1b1a; border-color: #2c2c2a; color: var(--screen-ink); box-shadow: none; }
#login-form .note { color: #b9b8b3; }
#login-form .err { color: #ff7a6b; }
.linkbtn { background: none; border: 0; color: var(--screen-dim); font-size: .85rem; cursor: pointer; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
