/* EmbodiedOS -- theme and shell layout (spec E1, E9).

   Two palettes on :root[data-theme]. "auto" follows the device. Glass:
   translucent panels over a soft gradient, 12 px radii, the system font,
   one accent -- the route ribbon's blue, so the dog's intent and its
   interface share a colour. Nothing at shell level scrolls: html and body
   are the viewport, apps scroll inside their windows. */

:root {
  --accent: #4fa3ff;
  --radius: 12px;
  --sb-h: 30px;
  --dock-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Dark */
:root[data-theme="dark"], :root[data-theme="auto"] {
  color-scheme: dark;
  --bg0: #0b1018; --bg1: #141b27;
  --glass: rgba(22, 29, 41, .72); --glass-strong: rgba(22, 29, 41, .92);
  --edge: rgba(255, 255, 255, .09); --edge-strong: rgba(255, 255, 255, .16);
  --fg: #e8edf3; --muted: #93a0b2; --faint: #5d6a7d;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
  --ok: #4cd47a; --warn: #f0b53a; --bad: #f06060;
}
/* Light */
:root[data-theme="light"] {
  color-scheme: light;
  --bg0: #e9eef6; --bg1: #f7f9fc;
  --glass: rgba(255, 255, 255, .66); --glass-strong: rgba(255, 255, 255, .9);
  --edge: rgba(0, 0, 0, .08); --edge-strong: rgba(0, 0, 0, .16);
  --fg: #141a24; --muted: #5b6676; --faint: #98a3b3;
  --shadow: 0 18px 50px rgba(20, 30, 50, .18), 0 2px 8px rgba(20, 30, 50, .10);
  --ok: #1f9d55; --warn: #b7791f; --bad: #c53030;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg0: #e9eef6; --bg1: #f7f9fc;
    --glass: rgba(255, 255, 255, .66); --glass-strong: rgba(255, 255, 255, .9);
    --edge: rgba(0, 0, 0, .08); --edge-strong: rgba(0, 0, 0, .16);
    --fg: #141a24; --muted: #5b6676; --faint: #98a3b3;
    --shadow: 0 18px 50px rgba(20, 30, 50, .18), 0 2px 8px rgba(20, 30, 50, .10);
    --ok: #1f9d55; --warn: #b7791f; --bad: #c53030;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;           /* the shell never scrolls (E1) */
  font: 14px/1.4 var(--font); color: var(--fg);
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg1), var(--bg0) 60%),
              radial-gradient(900px 700px at 90% 90%, color-mix(in srgb, var(--accent) 18%, var(--bg0)), transparent 60%),
              var(--bg0);
  -webkit-font-smoothing: antialiased;
}
body { height: 100dvh; display: grid; grid-template-rows: var(--sb-h) 1fr; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent); }

/* --- status bar ----------------------------------------------------------------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 10px; height: var(--sb-h);
  background: var(--glass-strong); backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--edge); font-size: 12.5px; user-select: none;
  padding-top: env(safe-area-inset-top);
}
.sb-left, .sb-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sb-logo { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.sb-title { font-weight: 600; letter-spacing: .01em; }
.sb-app { color: var(--muted); }
.sb-item { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sb-item.ok { color: var(--ok); } .sb-item.warn { color: var(--warn); } .sb-item.bad { color: var(--bad); }
.sb-time { color: var(--fg); }
@media (max-width: 759px) { .sb-item[title="CPU"], .sb-item[title="Memory"] { display: none; } }

/* --- desk ------------------------------------------------------------------------ */
.desk { position: relative; overflow: hidden; }

/* --- windows (desktop) ------------------------------------------------------------ */
.win {
  position: absolute; display: grid; grid-template-rows: 36px 1fr; min-width: 280px; min-height: 180px;
  background: var(--glass); backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22), 0 1px 3px rgba(0, 0, 0, .18);   /* resting: a window lies on the desk */
  overflow: hidden; transition: box-shadow .2s var(--ease), opacity .18s var(--ease), transform .18s var(--ease);
}
.win.focused { border-color: var(--edge-strong); box-shadow: var(--shadow); }   /* in front: it floats above the others */
.win.opening { animation: win-in .22s var(--ease); }
@keyframes win-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.win-title {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 0 10px; cursor: default; user-select: none;
  border-bottom: 1px solid var(--edge); background: color-mix(in srgb, var(--glass) 60%, transparent);
}
.win-title .lights { display: flex; gap: 7px; }
.win-title .lights button { width: 12px; height: 12px; border-radius: 50%; padding: 0; background: var(--faint); }
.win-title .lights .close { background: #ff5f57; } .win-title .lights .max { background: #28c840; }
.win-title .centre { display: flex; align-items: center; gap: 6px; justify-self: center; min-width: 0; }
.win-title .name { font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-title .icon { width: 16px; text-align: center; }
.win-body { position: relative; overflow: auto; min-height: 0; }
.win-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.win-resize::after { content: ''; position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px;
  border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); border-radius: 1px; }

/* --- dock -------------------------------------------------------------------------- */
.dock {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px; border-radius: 18px;
  background: var(--glass-strong); backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--edge); box-shadow: var(--shadow); z-index: 1000;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.dock button {
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; display: grid; place-items: center;
  position: relative; transition: transform .15s var(--ease), background .15s var(--ease);
}
.dock button:hover { transform: translateY(-4px) scale(1.08); background: color-mix(in srgb, var(--fg) 8%, transparent); }
.dock button.open::after { content: ''; position: absolute; bottom: -5px; width: 4px; height: 4px; border-radius: 50%; background: var(--fg); }
.dock button .badge { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; }

/* --- toasts ------------------------------------------------------------------------ */
.toasts { position: fixed; top: calc(var(--sb-h) + 8px); right: 12px; display: grid; gap: 8px; z-index: 1100; pointer-events: none; }
.toast { pointer-events: auto; max-width: 360px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--glass-strong); backdrop-filter: blur(18px); border: 1px solid var(--edge); box-shadow: var(--shadow);
  animation: win-in .2s var(--ease); font-size: 13px; }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.toast.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.toast .t-count { color: var(--muted); font-weight: 400; margin-left: 4px; }
.toast .t-actions:empty { display: none; }
.toast .t-actions { display: flex; gap: 6px; margin-top: 8px; }
.sb-bell { position: relative; background: none; border: 0; padding: 0 4px; font: inherit; cursor: pointer; color: var(--muted); }
.sb-bell-n { position: absolute; top: -4px; right: -6px; min-width: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--bad); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }

/* --- banner -------------------------------------------------------------------------- */
.banner { position: fixed; left: 50%; top: calc(var(--sb-h) + 8px); transform: translateX(-50%); z-index: 1050;
  padding: 8px 14px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 18%, var(--glass-strong));
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); font-size: 13px; }

/* --- phone mode (pointer: coarse and narrow) ------------------------------------------ */
body.phone .desk { display: grid; grid-template-rows: 1fr; }
body.phone .win { position: static; grid-template-rows: 1fr; height: 100%; min-height: 0; border-radius: 0; border: 0; box-shadow: none; background: transparent; backdrop-filter: none; min-width: 0; }
body.phone .win-body { height: 100%; }
body.phone .win-title { display: none; }
body.phone .win-resize { display: none; }
body.phone .desk.split { grid-template-rows: var(--split, 45%) 6px 1fr; }
body.phone .divider { background: var(--edge-strong); border-radius: 3px; margin: 0 40%; cursor: row-resize; touch-action: none; }
body.phone .dock { left: 0; right: 0; bottom: 0; transform: none; border-radius: 0; justify-content: space-around; border-left: 0; border-right: 0; border-bottom: 0; }
body.phone .dock button:hover { transform: none; }
body.phone .desk { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); }

/* --- app surfaces --------------------------------------------------------------------- */
.app-root { height: 100%; width: 100%; overflow: auto; padding: 10px; }
.app-root.flush { padding: 0; overflow: hidden; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); }
.card { background: color-mix(in srgb, var(--glass) 70%, transparent); border: 1px solid var(--edge); border-radius: var(--radius); padding: 12px; }
input, select, textarea { font: inherit; color: var(--fg); background: color-mix(in srgb, var(--fg) 6%, transparent);
  border: 1px solid var(--edge); border-radius: 8px; padding: 6px 8px; }
.btn { padding: 6px 12px; border-radius: 9px; background: color-mix(in srgb, var(--fg) 8%, transparent); border: 1px solid var(--edge); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }

/* --- login --------------------------------------------------------------------------- */
.login { position: fixed; inset: var(--sb-h) 0 0 0; display: grid; place-items: center; z-index: 1200;
  background: color-mix(in srgb, var(--bg0) 55%, transparent); backdrop-filter: blur(10px); }
.login-card { width: min(380px, calc(100vw - 32px)); display: grid; gap: 10px; background: var(--glass-strong); backdrop-filter: blur(22px); box-shadow: var(--shadow); }
.login-head { display: flex; align-items: center; gap: 10px; } .login-head h2 { margin: 0; font-size: 17px; }
.login-why { margin: 0 0 4px; font-size: 12.5px; }
.login-card label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.login-card input { width: 100%; font-size: 15px; }
.login-error { margin: 0; min-height: 1.2em; color: var(--bad); font-size: 13px; }
.login-card .btn { padding: 9px; font-size: 14px; }

/* --- system menu ---------------------------------------------------------------------- */
.sb-logo-btn { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; padding: 0; }
.sb-logo-btn:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.menu { position: fixed; top: calc(var(--sb-h) + 4px); left: 8px; z-index: 1300; min-width: 200px; padding: 6px;
  background: var(--glass-strong); backdrop-filter: blur(22px); border: 1px solid var(--edge); border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; animation: win-in .15s var(--ease); }
.menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu-who { padding: 6px 10px; color: var(--muted); } .menu-label { padding: 4px 10px 2px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.menu-sep { height: 1px; background: var(--edge); margin: 5px 4px; }
.menu.brain { max-width: min(340px, calc(100vw - 16px)); }
.menu.brain .brain-text { color: var(--fg); line-height: 1.4; }
.sh-tile[data-tile="sb-brain"] { cursor: pointer; }

/* --- app frames (E13) ------------------------------------------------------------------ */
.app-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }

/* --- notifications with actions, the update sheet (E14) ------------------------------- */
.toast { position: relative; padding-right: 28px; }
.toast .t-close { position: absolute; top: 4px; right: 6px; font-size: 16px; color: var(--muted); padding: 2px 6px; }
.toast .t-body { white-space: pre-line; }
.toast .t-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.toast .t-actions:empty { display: none; }
.sb-title.away::after { content: ' · away'; color: var(--warn); font-weight: 400; }
.sheet { position: fixed; inset: var(--sb-h) 0 0 0; display: grid; place-items: center; z-index: 1150;
  background: color-mix(in srgb, var(--bg0) 45%, transparent); backdrop-filter: blur(6px); }
.sheet-card { width: min(440px, calc(100vw - 32px)); display: grid; gap: 10px; background: var(--glass-strong); box-shadow: var(--shadow); }
.sheet-title { margin: 0; font-size: 16px; }
.sheet-body { white-space: pre-line; }
.sheet-steps:empty { display: none; }
.sheet-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 10%, transparent); overflow: hidden; margin-bottom: 6px; }
.sheet-fill { height: 100%; background: var(--accent); transition: width .3s var(--ease); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sheet-actions:empty { display: none; }
.sheet-card { position: relative; }
.sheet-close { position: absolute; top: 6px; right: 8px; }
.win.minimised { display: none; }
.win-title .lights .min { background: #febc2e; }

/* --- dock: pinned + running, the launcher, the phone overview (E12) --------------------- */
.dock button.unpinned { opacity: .85; }
.dock button.unpinned::before { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.dock button.min::after { background: var(--faint); }
.dock .dock-search { font-size: 17px; color: var(--muted); border-left: 1px solid var(--edge); border-radius: 0 12px 12px 0; margin-left: 2px; }
body.phone .dock .dock-search { border-left: 0; }
.dock-menu { position: fixed; top: auto; left: auto; }
.launcher { position: fixed; inset: var(--sb-h) 0 0 0; z-index: 1250; display: grid; place-items: start center; padding-top: 10vh;
  background: color-mix(in srgb, var(--bg0) 35%, transparent); backdrop-filter: blur(6px); }
.launcher-card { width: min(520px, calc(100vw - 32px)); padding: 8px; background: var(--glass-strong); box-shadow: var(--shadow); }
.launcher-card input { width: 100%; font-size: 17px; padding: 10px 12px; border-radius: 10px; }
.launcher-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.launcher-list li { display: grid; grid-template-columns: 28px 1fr auto; grid-template-areas: "icon name state" "icon desc state"; gap: 0 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.launcher-list li .icon { grid-area: icon; font-size: 20px; text-align: center; }
.launcher-list li .name { grid-area: name; font-weight: 600; }
.launcher-list li .desc { grid-area: desc; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.launcher-list li .state { grid-area: state; font-size: 11px; }
.launcher-list li.active, .launcher-list li:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.overview { position: fixed; inset: var(--sb-h) 0 0 0; z-index: 1240; background: color-mix(in srgb, var(--bg0) 70%, transparent); backdrop-filter: blur(10px);
  display: grid; grid-template-rows: 1fr auto; padding: 16px 16px calc(var(--dock-h) + 16px + env(safe-area-inset-bottom)); }
.overview-cards { display: grid; gap: 14px; align-content: start; overflow: auto; }
.ovcard { background: var(--glass-strong); border: 1px solid var(--edge); border-radius: 14px; box-shadow: var(--shadow); min-height: 120px;
  transition: transform .18s var(--ease), opacity .18s var(--ease); touch-action: pan-y; }
.ovcard.gone { transform: translateY(-120%); opacity: 0; }
.ovcard-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--edge); }
.ovcard-head .name { flex: 1; font-weight: 600; }
.ovcard-close { font-size: 18px; color: var(--muted); padding: 2px 8px; }
.ovcard-body { height: 70px; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent); border-radius: 0 0 14px 14px; }
.overview-hint { text-align: center; margin: 10px 0 0; font-size: 12px; }
.faint { color: var(--faint); }
.menu.devices { right: 8px; left: auto; min-width: 280px; }
.menu.devices .dev { white-space: nowrap; color: var(--fg); font-size: 12.5px; }
.menu.devices .dev.me { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 6px; }
[hidden] { display: none !important; }

/* --- phone: fit the screen (owner's iPhone, 2026-10-06 22:35: bar overflowing, dock under
   Safari's toolbar, app bar clipped) ------------------------------------------------------ */
body.phone { overflow: hidden; width: 100vw; }
body.phone .statusbar { padding-left: 8px; padding-right: 8px; gap: 8px; overflow: hidden; }
body.phone .sb-left { gap: 8px; min-width: 0; flex: 0 1 auto; }
body.phone .sb-right { gap: 9px; flex: 1 1 auto; justify-content: flex-end; min-width: 0; overflow: hidden; }
body.phone .sb-title { display: none; }                 /* the logo says it; the name costs 90 px */
body.phone .sb-app { display: none; }
body.phone .sb-item[title="Memory"], body.phone .sb-item[title="CPU"] { display: none; }
body.phone .sb-item { font-size: 12px; }
/* The phone bar keeps what is glanced at -- awake, battery, notices, time --
   and pulls down into a sheet for the rest (owner, 2026-10-11: the bar was
   crowded and the devices bubble opened off the screen). */
.sb-grab, .sb-sheet { display: none; }
body.phone .statusbar { position: relative; z-index: 1210; }
body.phone #sb-brain, body.phone #sb-devices, body.phone #sb-wifi { display: none; }
body.phone .sb-grab { display: block; position: absolute; left: 50%; bottom: 1px; transform: translateX(-50%);
  width: 64px; height: 12px; padding: 0; border: 0; background: none; cursor: pointer; }
body.phone .sb-grab span { display: block; margin: 4px auto 0; width: 36px; height: 4px; border-radius: 2px;
  background: color-mix(in srgb, var(--fg) 35%, transparent); transition: width .2s var(--ease); }
body.phone .statusbar.pulling .sb-grab span, body.phone .sb-grab[aria-expanded="true"] span { width: 48px; background: var(--accent); }
body.phone .sb-sheet { display: block; position: fixed; left: 0; right: 0; top: calc(var(--sb-h) + env(safe-area-inset-top));
  z-index: 1200; max-height: calc(100dvh - var(--sb-h) - env(safe-area-inset-top) - 24px); overflow: auto;
  padding: 12px 12px 8px; background: var(--glass-strong); backdrop-filter: blur(22px) saturate(150%);
  border-bottom: 1px solid var(--edge-strong); box-shadow: var(--shadow); border-radius: 0 0 18px 18px;
  transform: translateY(-105%); transition: transform .25s var(--ease); touch-action: none; }
body.phone .sb-sheet.open { transform: translateY(0); }
body.phone .sb-sheet.dragging { transition: none; }
body.phone .sb-sheet[hidden] { display: none; }
.sb-shade { position: fixed; inset: 0; z-index: 1150; background: rgba(0, 0, 0, .25); }
.sh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sh-tile { padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--fg) 7%, transparent); min-width: 0; }
.sh-tile .k { font-size: 11px; color: var(--muted); }
.sh-tile .v { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.sh-tile .v.ok { color: var(--ok); } .sh-tile .v.warn { color: var(--warn); } .sh-tile .v.bad { color: var(--bad); }
.sh-wide { grid-column: 1 / -1; }
.sh-dev { font-size: 12.5px; padding: 3px 0; border-top: 1px solid var(--edge); overflow-wrap: anywhere; }
.sh-dev:first-of-type { border-top: 0; } .sh-dev.me b::after { content: ' (this phone)'; font-weight: 400; color: var(--muted); }
.sh-actions { display: flex; gap: 8px; margin-top: 10px; }
.sh-actions .btn { flex: 1; }
.sh-pull { width: 40px; height: 4px; border-radius: 2px; margin: 10px auto 0; background: color-mix(in srgb, var(--fg) 30%, transparent); }
body.phone .desk { padding-bottom: 0; height: calc(100dvh - var(--sb-h) - var(--dock-h) - env(safe-area-inset-bottom)); width: 100vw; overflow: hidden; }
body.phone .win, body.phone .win-body, body.phone .app-root, body.phone .app-frame { width: 100%; max-width: 100vw; }
body.phone .dock { height: calc(var(--dock-h) + env(safe-area-inset-bottom)); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 2px; overflow-x: auto; overflow-y: hidden; }
body.phone .dock button { width: 40px; height: 40px; font-size: 20px; flex: 0 0 auto; }
body.phone .toasts { left: 8px; right: 8px; }
body.phone .toast { max-width: none; }
