/* Dare Phone: the screen on plain black, the keys as bold icons floating
   underneath (front keys, then a second row of side keys). No frame. The
   layout itself is computed in app.js (layout()), as on iOS. */
:root {
  --ink: #e0e0e0;
  --ink-dim: #8a8a8a;
  --press: rgba(255, 255, 255, 0.16);
  --sheet: #1c1c1e;
  --sheet-line: #3a3a3c;
  --accent: #4aa3ff;
  color-scheme: dark;
}
html, body {
  margin: 0; height: 100%; background: #000; color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#face { position: fixed; inset: 0; touch-action: none; }
#lcd-wrap { position: absolute; background: #000; }
#lcd { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; background: #000; }
#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 24px; box-sizing: border-box; text-align: center;
  color: var(--ink); background: #000;
}
#overlay[hidden] { display: none; }
#overlay h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: 0.2px; }
#overlay p { margin: 0; color: var(--ink-dim); font-size: 14px; max-width: 30em; }
#overlay .progress { width: 70%; height: 4px; background: #222; border-radius: 2px; overflow: hidden; }
#overlay .progress > div { height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }
#overlay .err { color: #ff8a80; white-space: pre-wrap; font-size: 13px; }
#overlay.drop { outline: 2px dashed var(--ink-dim); outline-offset: -12px; }
.btn {
  appearance: none; border: 1px solid #555; background: #111; color: var(--ink);
  border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #1b1b1b; }
.btn.primary { background: var(--ink); color: #000; border-color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.key {
  position: absolute; display: flex; align-items: center; justify-content: center;
  color: var(--ink); border-radius: 999px; cursor: pointer;
}
.key svg { display: block; overflow: visible; }
.key.down::before {
  content: ""; position: absolute; inset: 4px; border-radius: 999px; background: var(--press);
}
.key.toggle.on { color: #000; }
.key.toggle.on::after {
  content: ""; position: absolute; inset: 6px; border-radius: 999px; background: var(--ink); z-index: -1;
}
.key:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

#kbd-input {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0;
  font-size: 16px; /* no zoom on iOS focus */
}

#sheet {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex;
  align-items: flex-end; justify-content: center; z-index: 10;
}
#sheet[hidden] { display: none; }
.sheet-card {
  background: var(--sheet); border-radius: 14px; margin: 8px; width: min(420px, calc(100% - 16px));
  margin-bottom: max(8px, env(safe-area-inset-bottom)); overflow: hidden;
  max-height: calc(100% - 16px); overflow-y: auto;
}
.sheet-title { text-align: center; color: var(--ink-dim); font-size: 13px; padding: 12px 16px 8px; }
.sheet-item {
  display: block; width: 100%; text-align: center; padding: 14px 16px; background: none;
  border: 0; border-top: 1px solid var(--sheet-line); color: var(--accent); font: inherit;
  font-size: 17px; cursor: pointer;
}
.sheet-item:hover { background: #26262a; }
.sheet-item.danger { color: #ff6961; }
.sheet-item.cancel { font-weight: 600; }
.sheet-note { padding: 10px 16px 14px; color: var(--ink-dim); font-size: 13px; text-align: left; }
.sheet-note code { color: var(--ink); }
.sheet-field { display: block; padding: 8px 16px; }
.sheet-field input, .sheet-field select {
  width: 100%; box-sizing: border-box; background: #000; color: var(--ink); border: 1px solid var(--sheet-line);
  border-radius: 8px; padding: 8px 10px; font: inherit; -webkit-user-select: text; user-select: text;
}
.toast {
  position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%);
  background: #1c1c1e; color: var(--ink); padding: 8px 14px; border-radius: 10px; font-size: 13px;
  z-index: 20; pointer-events: none; transition: opacity 0.3s;
}
.key.hidden { visibility: hidden; pointer-events: none; }

/* ---------------------------------------------------------------- wide layout
   (desktop: a mouse and room beside the phone; app.js wideLayout) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.wide .key { background: #141414; border: 1px solid #2c2c2c; border-radius: 14px; }
body.wide .key:hover { background: #1c1c1c; }
/* pressed: the key's own background changes, so the highlight has exactly
   the key's shape (pills, the split volume rocker) */
body.wide .key.down::before { content: none; }
body.wide .key.down, body.wide .key.down:hover { background: #2e2e2e; border-color: #444; }
body.wide .key.toggle.on::after { content: none; }
body.wide .key.toggle.on, body.wide .key.toggle.on:hover { background: var(--ink); border-color: var(--ink); }
/* the three front keys: legends of one ink height on one baseline (icons.js
   gives each a viewBox that is its ink box) */
body.wide #front .key svg { height: 26px; width: auto; }
/* side keys: slim pills on the screen's edges */
body.wide .key[data-side] { border-radius: 8px; }
body.wide .key[data-side] svg { width: 16px; height: 16px; }
body.wide .key[data-key="vol-up"] { border-radius: 8px 8px 2px 2px; border-bottom-color: #222; }
body.wide .key[data-key="vol-down"] { border-radius: 2px 2px 8px 8px; }
/* turned face (app.js layout): the rocker's halves side by side; vol-up is
   the half nearer the phone's top, which is on the left at 270 degrees and
   on the right at 90 */
body.wide[data-turn="270"] .key[data-key="vol-up"] { border-radius: 8px 2px 2px 8px; border-bottom-color: #2c2c2c; border-right-color: #222; }
body.wide[data-turn="270"] .key[data-key="vol-down"] { border-radius: 2px 8px 8px 2px; }
body.wide[data-turn="90"] .key[data-key="vol-up"] { border-radius: 2px 8px 8px 2px; border-bottom-color: #2c2c2c; border-left-color: #222; }
body.wide[data-turn="90"] .key[data-key="vol-down"] { border-radius: 8px 2px 2px 8px; }
/* focus: no ring after a click; a keyboard ring that follows the key's own
   corners (outline takes the border-radius) */
.key:focus { outline: none; }
.key:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#hint {
  position: fixed; z-index: 30; pointer-events: none; background: #1c1c1e; border: 1px solid #3a3a3c;
  border-radius: 6px; padding: 4px 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
#hint[hidden] { display: none; }
#hint kbd {
  font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); border: 1px solid #555;
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; background: #0b0b0b;
}

#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 248px; box-sizing: border-box; padding: 52px 16px 16px;
  background: #0c0c0c; border-left: 1px solid #1f1f1f; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  -webkit-user-select: none; user-select: none;
}
#panel h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); margin: 12px 0 2px; }
#panel button {
  appearance: none; text-align: left; background: #161616; color: var(--ink); border: 1px solid #2a2a2a;
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; cursor: pointer;
}
#panel button:hover { background: #1f1f1f; }
#panel button:active, #panel-toggle:active { background: #2a2a2a; }
#panel button:focus, #panel-toggle:focus { outline: none; }
#panel button:focus-visible, #panel-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#panel button.danger { color: #ff8a80; }
#panel button.link { background: none; border: 0; color: var(--accent); padding: 8px 2px; text-decoration: underline; }
#panel .p-status { font-size: 13px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 4px; }
#panel .p-pill { color: #000; background: var(--ink); border-radius: 999px; padding: 3px 10px; align-self: flex-start; font-weight: 600; }
#panel .p-pill[hidden] { display: none; }
#panel .p-hint { font-size: 12px; color: #777; margin: 10px 0 0; }
#panel-toggle {
  position: fixed; top: 12px; right: 16px; z-index: 5; appearance: none; background: #161616; color: var(--ink);
  border: 1px solid #2a2a2a; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
body:not(.wide) #panel-toggle, body:not(.wide) #panel { display: none !important; }
table.shortcuts { border-collapse: collapse; width: 100%; font-size: 14px; color: var(--ink); }
table.shortcuts td { padding: 5px 4px; border-top: 1px solid var(--sheet-line); vertical-align: top; }
table.shortcuts kbd {
  font: 600 12px ui-monospace, Menlo, monospace; border: 1px solid #555; border-bottom-width: 2px; border-radius: 4px;
  padding: 1px 5px; background: #0b0b0b; white-space: nowrap;
}
/* upside down (a hold, app.js): vol-up is the lower half of the rocker */
body.wide[data-turn="180"] .key[data-key="vol-up"] { border-radius: 2px 2px 8px 8px; border-bottom-color: #2c2c2c; border-top-color: #222; }
body.wide[data-turn="180"] .key[data-key="vol-down"] { border-radius: 8px 8px 2px 2px; }

/* holding the phone (app.js): quarter turns, top left; the motion permission chip, top centre */
#tilt {
  position: fixed; z-index: 5; top: max(12px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left));
  display: flex; gap: 6px;
}
#tilt[hidden] { display: none; }
#tilt button {
  appearance: none; display: flex; align-items: center; justify-content: center; width: 34px; height: 30px; padding: 0;
  background: #161616; color: var(--ink); border: 1px solid #2a2a2a; border-radius: 8px; cursor: pointer;
}
#tilt button:hover { background: #1f1f1f; }
#tilt button:active { background: #2a2a2a; }
#tilt button:focus { outline: none; }
#tilt button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
body:not(.wide) #tilt button { background: rgba(22, 22, 22, 0.8); }
#motion-chip {
  position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: stretch; background: #1c1c1e; border: 1px solid #3a3a3c; border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6); max-width: calc(100% - 24px); overflow: hidden;
}
#motion-chip[hidden] { display: none; }
#motion-chip button {
  appearance: none; background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; padding: 10px 12px; cursor: pointer;
}
#motion-chip .m-no { color: var(--ink-dim); border-left: 1px solid #3a3a3c; font-size: 18px; padding: 6px 12px; }

/* the 3D view (app.js, view3d.js): the model on a soft dark backdrop; the
   flat face is hidden but keeps its layout, so switching back is instant */
#stage { position: fixed; inset: 0; z-index: 1; }
#stage[hidden] { display: none; }
#stage canvas { display: block; outline: none; }
body.v3d { background: radial-gradient(ellipse at 50% 42%, #2b2b2e 0%, #121213 55%, #050505 100%); }
body.v3d.bg-none, html:has(body.v3d.bg-none) { background: transparent; }
body.v3d #face { visibility: hidden; z-index: 7; }   /* above the stage only for its overlay card */
/* progress is drawn on the phone's own screen; anything else (choose the
   firmware, an error) is a card at the bottom */
body.v3d #overlay.busy { display: none; }
body.v3d #overlay:not([hidden]) {
  visibility: visible; position: fixed; z-index: 8; inset: auto auto max(20px, env(safe-area-inset-bottom)) 50%;
  transform: translateX(-50%); width: min(380px, calc(100vw - 32px)); padding: 18px 20px; gap: 10px;
  background: rgba(14, 14, 15, 0.94); border: 1px solid #333; border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}
#view-toggle {
  position: fixed; z-index: 6; top: max(12px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  appearance: none; background: #161616; color: var(--ink); border: 1px solid #2a2a2a; border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; min-width: 44px;
}
#view-toggle:hover { background: #1f1f1f; }
#view-toggle:active { background: #2a2a2a; }
#view-toggle:focus { outline: none; }
#view-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
body:not(.wide) #view-toggle { background: rgba(22, 22, 22, 0.8); }
/* the flat phone layout's LCD reaches the top corner: there the menu (long
   press on the background) opens the 3D view; in 3D the button covers no LCD */
body:not(.wide):not(.v3d) #view-toggle { display: none; }
body.v3d #panel-toggle, body.v3d #panel { z-index: 6; }
