/* UT Space — the frame around the apps. Visual reference: ut-desk-ui/index.html (mockup). */
:root {
  --ink: #201E1D;
  --teal: #0088B0;
  --teal-soft: #d9eef5;
  --paper: #fbfaf8;
  --panel: #ffffff;
  --line: #e7e3df;
  --muted: #7a7470;
  --red: #e0453a;
  --amber: #e9a72a;
  --glass: rgba(255,255,255,.14);
  --dock-h: 86px;     /* room the floating Dock takes on the desktop */
  --bar-h: 48px;      /* the Dock as a taskbar while an app is open */
  --side-w: 64px;     /* the Dock as a sidebar (Settings → Dock position: left or right) */
  --wall: #10181c;
  font-family: "Inter", "Cantarell", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
body[data-mode="dark"] {
  --ink: #ece8e4;
  --teal-soft: #163a46;
  --paper: #1b1f21;
  --panel: #23282a;
  --line: #343a3d;
  --muted: #9b948e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { color: #fff; background: var(--wall); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
.defs { position: absolute; }
svg { flex: none; }

/* ---------- wallpapers (the eclipse is the default, SPACE.md §11.5) ---------- */
body[data-wall="eclipse"] {
  background:
    radial-gradient(circle at 78% 34%, rgba(0,136,176,.55) 0 15%, transparent 15.2%),
    radial-gradient(circle at 75.6% 36.5%, #16201f 0 15.4%, transparent 15.6%),
    radial-gradient(1200px 700px at 80% 30%, rgba(0,136,176,.35), transparent 70%),
    radial-gradient(900px 600px at 10% 100%, rgba(0,90,120,.45), transparent 70%),
    linear-gradient(160deg, #0d2a33 0%, #10181c 55%, #201E1D 100%);
}
body[data-wall="tide"] {
  background:
    radial-gradient(1100px 800px at 85% 0%, rgba(0,136,176,.55), transparent 65%),
    radial-gradient(900px 700px at 0% 100%, rgba(32,168,107,.30), transparent 70%),
    linear-gradient(170deg, #0b3442 0%, #0f2228 60%, #14191b 100%);
}
body[data-wall="night"] { background: linear-gradient(180deg, #1a1e20 0%, #121516 100%); }
/* A picture from Files (Settings → Wallpaper → From Files…): the image is set by space.js. */
body[data-wall="custom"] { background-color: #10181c; background-position: center; background-size: cover; background-repeat: no-repeat; }
body[data-wall="graphite"] {
  background:
    radial-gradient(1000px 700px at 70% 20%, rgba(255,255,255,.07), transparent 70%),
    linear-gradient(160deg, #3a3f42 0%, #24282a 100%);
}
/* Until the boot answers: wallpaper only, no flash of the desktop. */
body.booting .desk, body.booting .dock-wrap { visibility: hidden; }

/* ---------- account menu (opens above the Dock, right) ---------- */
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--teal); display: grid; place-items: center; font-size: 17px; font-weight: 700; color: #fff; flex: none; transition: width .18s, height .18s; }
/* The account is as big as the Dock's icons: 52 px on the desktop, 32 px on the taskbar, 44 px narrow. */
body.in-app .avatar { width: 32px; height: 32px; font-size: 12px; }
.avatar:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.menu {
  position: fixed; bottom: calc(var(--dock-h) + 4px); left: 12px; min-width: 200px; z-index: 40;   /* placed by space.js */
  background: rgba(28,34,36,.96); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 6px;
  box-shadow: 0 16px 50px rgba(0,0,0,.45);
}
.menu .who { padding: 8px 10px 10px; font-size: 12px; opacity: .7; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 4px; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; color: #fff; text-decoration: none; font-size: 13px; }
.menu button:hover, .menu a:hover, .menu button:focus-visible, .menu a:focus-visible { background: var(--glass); outline: none; }

/* ---------- desktop ---------- */
.desk {
  position: fixed; inset: 0 0 var(--dock-h) 0; padding: 22px;
  display: flex; gap: 22px; transition: opacity .2s;
}
body.full-app .desk { opacity: 0; pointer-events: none; }
.icons { display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 104px); gap: 6px 10px; align-content: start; }
.dicon {
  position: relative; width: 92px; padding: 8px 4px; border-radius: 10px; text-align: center; font-size: 12px;
  text-shadow: 0 1px 3px rgba(0,0,0,.6); line-height: 1.25; overflow-wrap: anywhere;
}
.dicon:hover, .dicon:focus-visible { background: var(--glass); outline: none; }
.dicon .glyph { display: block; width: 48px; height: 48px; margin: 0 auto 6px; }
.dicon .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.widgets { margin-left: auto; display: flex; flex-direction: column; gap: 14px; width: 300px; flex: none; }
.widget {
  background: rgba(20,26,28,.45); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 16px 18px;
}
.clock { font-size: 54px; font-weight: 300; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.date { opacity: .75; margin-top: 6px; font-size: 14px; }
.widget h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; font-weight: 600; }
.wrow { border-top: 1px solid rgba(255,255,255,.07); }
.wrow:first-child { border-top: 0; }
.wrow button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 0; font-size: 13px; }
.wrow svg { width: 22px; height: 22px; }
.wrow .n { margin-left: auto; background: var(--red); border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.wrow .n.calm { background: rgba(255,255,255,.18); }
.wempty { font-size: 13px; opacity: .55; padding: 4px 0; }

/* ---------- Dock ----------
 * Desktop: a floating Dock, big icons, the account at its right end.
 * An app open (body.in-app): the Dock becomes a taskbar along the bottom edge — app tools on the
 * left, small app icons in the middle, time and account on the right — and the app fills the
 * rest of the screen edge to edge. */
.dock-wrap { position: fixed; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; z-index: 30; pointer-events: none; }
.dock {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 8px 12px; max-width: calc(100vw - 16px);
  background: rgba(22,28,30,.55); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  font-size: 13px;
}
.dock-apps { display: flex; align-items: flex-end; gap: 14px; min-width: 0; }
.dock-apps .sep { width: 1px; align-self: stretch; margin: 4px 0; background: rgba(255,255,255,.18); flex: none; }
/* `.dock-right` holds the clock + account. By default (window buttons on the right) it sits on the
 * left: first in the floating Dock, the left column of the taskbar, the avatar at the outer edge. */
.dock-right { display: flex; flex-direction: row-reverse; align-items: center; gap: 12px; align-self: stretch;
  order: -1; padding-right: 10px; margin-right: 2px; border-right: 1px solid rgba(255,255,255,.18); }
body[data-tools="left"] .dock-right { flex-direction: row; order: 0; padding: 0 0 0 10px; margin: 0 0 0 2px; border-right: 0; border-left: 1px solid rgba(255,255,255,.18); }
.dock-clock { display: none; flex-direction: column; align-items: flex-start; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
body[data-tools="left"] .dock-clock { align-items: flex-end; }
.dock-clock .t { font-size: 13px; font-weight: 600; }
.dock-clock .d { font-size: 11px; opacity: .7; }
.tools-wrap { display: flex; align-items: center; }
.tools-btn { display: none; }
.app-tools { display: flex; align-items: center; gap: 2px; }
.app-tools button { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; opacity: .78; }
.app-tools button:hover, .app-tools button:focus-visible { background: var(--glass); opacity: 1; outline: none; }
.app-tools svg { width: 17px; height: 17px; }
.app-tools .tsep { width: 1px; height: 22px; margin: 0 6px; background: rgba(255,255,255,.18); }
.app-tools .t-x:hover, .app-tools .t-x:focus-visible { background: var(--red); opacity: 1; }

.dbtn { position: relative; width: 52px; height: 52px; border-radius: 14px; transition: transform .15s, width .18s, height .18s; flex: none; }
.dbtn:hover { transform: translateY(-4px) scale(1.06); }
.dbtn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.dbtn .glyph { width: 100%; height: 100%; display: block; }
.dbtn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #1c2224;
}
.dbtn .badge.urgent { box-shadow: 0 0 0 3px rgba(224,69,58,.35); }
/* one waiting: a round dot, no number */
.dbtn .badge.dot, body.in-app .dbtn .badge.dot { min-width: 0; width: 12px; height: 12px; padding: 0; top: -3px; right: -3px; }
.dbtn .run { position: absolute; bottom: -7px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #fff; opacity: 0; }
.dbtn.running .run { opacity: .55; }
.dbtn.active .run { opacity: 1; width: 14px; margin-left: -7px; border-radius: 3px; }
.dbtn .tip {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: rgba(20,20,20,.88); padding: 3px 8px; border-radius: 6px; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .12s;
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
.dbtn:hover .tip, .dbtn:focus-visible .tip { opacity: 1; }

/* the taskbar */
body.in-app .dock-wrap { bottom: 0; }
body.in-app .dock {
  width: 100%; max-width: none; height: var(--bar-h); padding: 0 8px 0 6px; border-radius: 0; border: 0;
  border-top: 1px solid rgba(255,255,255,.08); box-shadow: none; background: rgba(16,20,22,.92);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px;
}
/* One row: the clock + account cell comes first (order -1) but sits in column 1, the window
 * buttons in column 3; without a fixed row the icons (column 2) would wrap to a second row. */
body.in-app .dock > * { grid-row: 1; }
body.in-app .dock-left { grid-column: 3; justify-self: end; }
body[data-tools="left"].in-app .dock-left { grid-column: 1; justify-self: start; }
body.in-app .dock-apps { grid-column: 2; justify-self: center; gap: 12px; align-items: center; }
body.in-app .dock-right { grid-column: 1; justify-self: start; border: 0; padding: 0; margin: 0; }
body[data-tools="left"].in-app .dock-right { grid-column: 3; justify-self: end; }
body.in-app .dock-clock { display: flex; }
body.in-app .dbtn { width: 32px; height: 32px; border-radius: 9px; }
body.in-app .dbtn:hover { transform: translateY(-2px); }
body.in-app .dbtn .badge { top: -5px; right: -7px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; border-width: 1.5px; border-color: #161b1d; }
body.in-app .dbtn .run { bottom: -6px; width: 4px; height: 4px; margin-left: -2px; }
body.in-app .dbtn.active .run { width: 12px; margin-left: -6px; border-radius: 2px; }
body.in-app .dock-apps .sep { margin: 8px 2px; }

/* ---------- Dock at the top (Settings → Dock position) ---------- */
body[data-dock="top"] .dock-wrap { top: 10px; bottom: auto; }
body[data-dock="top"].in-app .dock-wrap { top: 0; }
body[data-dock="top"].in-app .dock { border-top: 0; border-bottom: 1px solid rgba(255,255,255,.08); }
body[data-dock="top"] .desk { inset: var(--dock-h) 0 0 0; }
body[data-dock="top"] .stage { inset: var(--bar-h) 0 0 0; }
body[data-dock="top"] .dbtn:hover { transform: translateY(4px) scale(1.06); }
body[data-dock="top"].in-app .dbtn:hover { transform: translateY(2px); }
body[data-dock="top"] .dbtn .tip { bottom: auto; top: calc(100% + 12px); }
body[data-dock="top"] .toast, body[data-dock="top"].in-app .toast { bottom: 16px; }

/* ---------- Dock on the left or right: a sidebar ----------
 * Always the full height, on the desktop too: the window buttons (one button; pointing at it opens
 * the row beside the sidebar), then the apps from the top; the clock and the account at the bottom. */
body.v-dock .dock-wrap { top: 0; bottom: 0; left: 0; right: auto; width: var(--side-w); justify-content: stretch; }
body[data-dock="right"] .dock-wrap { left: auto; right: 0; }
body.v-dock .dock, body.v-dock.in-app .dock {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; height: 100%; max-width: none; padding: 10px 0 12px; border-radius: 0; border: 0;
  border-right: 1px solid rgba(255,255,255,.08); box-shadow: none; background: rgba(16,20,22,.92);
}
body[data-dock="right"] .dock, body[data-dock="right"].in-app .dock { border-right: 0; border-left: 1px solid rgba(255,255,255,.08); }
body.v-dock .desk { inset: 0 0 0 var(--side-w); }
body[data-dock="right"] .desk { inset: 0 var(--side-w) 0 0; }
body.v-dock .stage { inset: 0 0 0 var(--side-w); }
body[data-dock="right"] .stage { inset: 0 var(--side-w) 0 0; }
body.v-dock .dock-left { order: -2; }
body.v-dock .dock-apps, body.v-dock.in-app .dock-apps { flex-direction: column; align-items: center; gap: 10px; min-height: 0; overflow: visible; }
body.v-dock .dock-apps .sep, body.v-dock.in-app .dock-apps .sep { width: 28px; height: 1px; align-self: center; margin: 2px 0; }
body.v-dock .dock-right, body.v-dock.in-app .dock-right {
  order: 1; margin: auto 0 0; padding: 0; border: 0; flex-direction: column; gap: 10px; align-self: center;
}
body.v-dock .dock-clock { display: flex; align-items: center; text-align: center; }
body.v-dock .dock-clock .d { font-size: 10px; white-space: normal; max-width: calc(var(--side-w) - 8px); }
body.v-dock .dbtn, body.v-dock.in-app .dbtn, body.v-dock .avatar, body.v-dock.in-app .avatar { width: 40px; height: 40px; border-radius: 11px; }
body.v-dock .avatar, body.v-dock.in-app .avatar { border-radius: 50%; font-size: 14px; }
body.v-dock .dbtn:hover, body.v-dock.in-app .dbtn:hover { transform: translateX(3px); }
body[data-dock="right"] .dbtn:hover, body[data-dock="right"].in-app .dbtn:hover { transform: translateX(-3px); }
body.v-dock .dbtn .run, body.v-dock.in-app .dbtn .run { bottom: auto; top: 50%; left: -10px; width: 4px; height: 4px; margin: -2px 0 0; }
body.v-dock .dbtn.active .run, body.v-dock.in-app .dbtn.active .run { width: 4px; height: 16px; margin: -8px 0 0; border-radius: 2px; }
body[data-dock="right"] .dbtn .run, body[data-dock="right"].in-app .dbtn .run { left: auto; right: -10px; }
body.v-dock .dbtn .tip { bottom: auto; top: 50%; left: calc(100% + 14px); transform: translateY(-50%); }
body[data-dock="right"] .dbtn .tip { left: auto; right: calc(100% + 14px); }
body.v-dock .toast, body.v-dock.in-app .toast { bottom: 16px; }
/* the window buttons: one button, the row beside the sidebar while pointed at (or focused, or tapped) */
body.v-dock .tools-wrap { position: relative; flex-direction: column; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.14); }
body.v-dock .tools-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; opacity: .82; }
body.v-dock .tools-btn:hover, body.v-dock .tools-btn:focus-visible, body.v-dock .tools-wrap.open .tools-btn { background: var(--glass); opacity: 1; outline: none; }
body.v-dock .tools-btn svg { width: 22px; height: 22px; }
body.v-dock .app-tools {
  display: none; position: absolute; top: 0; left: calc(100% + 12px); z-index: 35; padding: 4px; white-space: nowrap;
  background: rgba(22,28,30,.96); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
/* the gap between the sidebar and the row still counts as pointing at it */
body.v-dock .app-tools::before { content: ""; position: absolute; top: 0; bottom: 0; left: -16px; width: 16px; }
body[data-dock="right"] .app-tools { left: auto; right: calc(100% + 12px); }
body[data-dock="right"] .app-tools::before { left: auto; right: -16px; }
body.v-dock .tools-wrap:hover .app-tools, body.v-dock .tools-wrap:focus-within .app-tools, body.v-dock .tools-wrap.open .app-tools { display: flex; }

/* Settings → Show clock off: no clock on the Dock (the desktop's big clock stays) */
body[data-clock="off"] .dock-clock { display: none !important; }

/* ---------- app stage ---------- */
.stage { position: fixed; inset: 0 0 var(--bar-h) 0; z-index: 10; pointer-events: none; }
.frame {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--paper); color: var(--ink);
  opacity: 0; transform: scale(.985) translateY(8px); transition: opacity .18s, transform .18s, visibility 0s .18s;
  visibility: hidden; pointer-events: none;
}
.frame.show { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .18s, transform .18s; }
.frame iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--paper); }
/* An app's `prefers-color-scheme` follows the color-scheme of its <iframe> here, not the system:
 * the frames carry Settings → Appearance (the Space's own chrome stays dark). Apps that only know
 * the media query (Chat) follow the setting without any bridge code. */
.frame iframe { color-scheme: light; }
body[data-mode="dark"] .frame iframe { color-scheme: dark; }
.frame .loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--paper); color: var(--muted); font-size: 13px;
  transition: opacity .2s;
}
.frame.loaded .loading { opacity: 0; pointer-events: none; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- windows ----------
 * Every app is a window: full screen (maximised), or floating like Files' viewer and the CRM's
 * mail windows (a 40 px title bar that moves it, a grip at each corner; minimise, maximise,
 * close). Restored the first time: half the screen, in the middle. Stacked by
 * z-index from space.js; the one on top has the stronger shadow. Minimised = into the Dock. */
.frame.floating {
  inset: auto; display: flex; flex-direction: column; min-width: 320px; min-height: 240px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  box-shadow: 0 6px 24px rgba(0,0,0,.28);
}
.frame.floating.top { box-shadow: 0 0 40px rgba(0,0,0,.5); }
.frame.floating iframe { flex: 1; height: auto; min-height: 0; }
.frame.floating .loading { top: 40px; }
.fbar, .fgrip { display: none; }
.frame.floating .fbar {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 12px; flex: none;
  background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--line);
  font-size: 13px; cursor: move; user-select: none; touch-action: none;
}
.frame.floating:not(.top) .fbar { color: var(--muted); }
.fbar .ft { font-weight: 600; white-space: nowrap; }
.fbar .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.fbar .fbtns { display: flex; align-items: center; flex: none; }
.fbar button { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.fbar button:hover, .fbar button:focus-visible { background: var(--teal-soft); color: var(--teal); outline: none; }
.fbar .f-x:hover, .fbar .f-x:focus-visible { background: var(--red); color: #fff; }
.fbar svg { width: 17px; height: 17px; }
.frame.floating .fgrip { display: block; position: absolute; width: 14px; height: 14px; z-index: 2; touch-action: none; }
.fgrip.nw { left: 0; top: 0; cursor: nwse-resize; } .fgrip.se { right: 0; bottom: 0; cursor: nwse-resize; }
.fgrip.ne { right: 0; top: 0; cursor: nesw-resize; } .fgrip.sw { left: 0; bottom: 0; cursor: nesw-resize; }
.fgrip::after { content: ""; position: absolute; inset: 3px; border: 0 solid var(--muted); opacity: 0; transition: opacity .12s; }
.fgrip.nw::after { border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 4px; }
.fgrip.ne::after { border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 4px; }
.fgrip.sw::after { border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 4px; }
.fgrip.se::after { border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 4px; }
.fgrip:hover::after, body.dragging .frame.floating.top .fgrip::after { opacity: .7; }
.shield { display: none; position: absolute; inset: 0; z-index: 1; }
.frame.show:not(.top) .shield { display: block; }
.frame.floating .shield { top: 40px; }
body.dragging { user-select: none; }
body.dragging .frame iframe { pointer-events: none; }
/* Settings → Title bar always on: a maximised window keeps the bar too (name, what is open, the
 * three buttons; maximise reads "restore down"). It does not move the window. */
.frame.titled { display: flex; flex-direction: column; }
.frame.titled .fbar {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 12px; flex: none;
  background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--line);
  font-size: 13px; user-select: none;
}
.frame.titled iframe { flex: 1; height: auto; min-height: 0; }
.frame.titled .loading, .frame.titled .shield { top: 40px; }
.frame.titled[data-app="settings"] .settings { position: static; flex: 1; min-height: 0; }
/* Dock: a teal ring for a floating window; a lit dot for one visible behind the one on top */
.dbtn.floating { box-shadow: 0 0 0 2px var(--teal); border-radius: 14px; }
body.in-app .dbtn.floating { border-radius: 9px; }
.dbtn.visible .run { opacity: .9; }

/* ---------- settings: a window of the Space itself (no frame inside), floating by default ---------- */
.settings { overflow: auto; font-size: 14px; background: var(--paper); color: var(--ink); color-scheme: light; }
body[data-mode="dark"] .settings { color-scheme: dark; }
.frame[data-app="settings"] .settings { position: absolute; inset: 0; }
.frame.floating[data-app="settings"] .settings { position: static; flex: 1; min-height: 0; }
.settings .inner { max-width: 720px; margin: 0 auto; padding: 22px 26px 40px; }
.settings h1 { font-size: 20px; margin: 4px 0 18px; }
.settings h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
.settings .hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.walls { display: flex; flex-wrap: wrap; gap: 12px; }
.wall-opt { width: 120px; text-align: center; font-size: 12px; color: var(--ink); }
.wall-opt .sw { display: block; height: 72px; border-radius: 12px; border: 2px solid transparent; margin-bottom: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.wall-opt[aria-pressed="true"] .sw { border-color: var(--teal); }
.wall-opt:focus-visible .sw { outline: 2px solid var(--teal); outline-offset: 2px; }
.sw[data-wall] { background-size: cover; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-row { margin-top: 12px; }
.seg button { padding: 7px 14px; font-size: 13px; color: var(--ink); border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.list .row { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 12px; border-top: 1px solid var(--line); }
.list .row:first-child { border-top: 0; }
.list .row svg.g { width: 28px; height: 28px; }
.list .row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .row .sub { color: var(--muted); font-size: 12px; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover:not(:disabled), .icon-btn:focus-visible { background: var(--teal-soft); color: var(--teal); outline: none; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; }
.list .row .check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.list .row .check input { accent-color: var(--teal); margin: 0; }
.text-btn { padding: 5px 12px; border-radius: 8px; font-size: 13px; color: var(--teal); border: 1px solid var(--line); }
.text-btn:hover, .text-btn:focus-visible { background: var(--teal-soft); outline: none; }
.list .empty { padding: 14px; color: var(--muted); font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; width: fit-content; }
.check-row input { accent-color: var(--teal); margin: 0; width: 16px; height: 16px; }
.save-state { font-size: 12px; color: var(--muted); margin-left: 10px; }
.wall-opt .sw.files { display: grid; place-items: center; background: var(--panel) center / cover no-repeat; color: var(--muted); font-size: 24px; }
.wall-opt .sw.files.has-pic { color: transparent; }
.wall-opt .wn { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.picker .crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.picker .crumbs button { padding: 3px 7px; border-radius: 6px; color: var(--ink); }
.picker .crumbs button:hover, .picker .crumbs button:focus-visible { background: var(--teal-soft); outline: none; }
.picker .crumbs span { color: var(--muted); }
.picker .crumbs .x { margin-left: auto; }
.picker .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; padding: 12px; max-height: 340px; overflow: auto; }
.picker .pk { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; border-radius: 10px; font-size: 12px; color: var(--ink); min-width: 0; }
.picker .pk:hover, .picker .pk:focus-visible { background: var(--teal-soft); outline: none; }
.picker .pk .th { width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--line) center / cover no-repeat; }
.picker .pk svg { width: 56px; height: 56px; margin: 8px 0; }
.picker .pk .n { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .empty { padding: 16px; color: var(--muted); font-size: 13px; }
.wall-preview-eclipse { background:
    radial-gradient(circle at 74% 38%, rgba(0,136,176,.7) 0 17%, transparent 17.5%),
    radial-gradient(circle at 70% 41%, #16201f 0 17.4%, transparent 17.9%),
    linear-gradient(160deg, #0d2a33 0%, #10181c 55%, #201E1D 100%); }
.wall-preview-tide { background: radial-gradient(120px 90px at 85% 0%, rgba(0,136,176,.7), transparent 70%), linear-gradient(170deg, #0b3442, #14191b); }
.wall-preview-night { background: linear-gradient(180deg, #1a1e20, #121516); }
.wall-preview-graphite { background: linear-gradient(160deg, #3a3f42, #24282a); }

/* ---------- the message pill (0.14.0): bottom centre, above the Dock ---------- */
.peek {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + 12px); z-index: 55; transform: translate(-50%, 10px); opacity: 0;
  display: flex; align-items: center; max-width: min(560px, calc(100vw - 32px)); padding: 6px; gap: 2px;
  background: rgba(22,28,30,.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 999px; box-shadow: 0 12px 36px rgba(0,0,0,.45);
  transition: opacity .18s, transform .18s;
}
.peek.in { opacity: 1; transform: translate(-50%, 0); }
body.in-app .peek { bottom: calc(var(--bar-h) + 12px); }
body[data-dock="top"] .peek { bottom: 24px; }
body.v-dock .peek { bottom: 24px; left: calc(50% + var(--side-w) / 2); }
body[data-dock="right"] .peek { left: calc(50% - var(--side-w) / 2); }
.peek-main { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 12px 0 0; border-radius: 999px; text-align: left; }
.peek-main:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.peek-face { width: 36px; height: 36px; border-radius: 50%; flex: none; object-fit: cover; background: #2a3135; }
.peek-letter { display: grid; place-items: center; font-size: 15px; font-weight: 700; color: #fff; }
.peek-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 1.3; }
.peek-text b { font-weight: 600; margin-right: 6px; }
.peek-body { opacity: .85; }
.peek-x { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; opacity: .6; }
.peek-x:hover, .peek-x:focus-visible { background: var(--glass); opacity: 1; outline: none; }
.peek-x svg { width: 14px; height: 14px; }
@media (max-width: 719.98px) { .peek { bottom: calc(var(--dock-h) + 10px); } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + 8px); transform: translateX(-50%); z-index: 60;
  background: rgba(20,24,26,.94); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100vw - 32px);
}
body.in-app .toast { bottom: calc(var(--bar-h) + 12px); }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; }

/* ---------- narrow (< 720 px): the mockup's phone layout, nothing more (SPACE.md §11.6) ---------- */
@media (max-width: 719.98px) {
  .list .row .sub.note { display: none; }
  :root { --dock-h: 78px; }
  .desk { flex-direction: column; padding: 14px; overflow: auto; }
  .widgets { width: 100%; margin: 0; order: -1; }
  .clock { font-size: 40px; }
  .icons { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-template-rows: none; }
  .dicon { width: auto; }
  .dock-wrap { bottom: max(6px, env(safe-area-inset-bottom)); }
  .dock { gap: 4px; padding: 6px 7px; border-radius: 20px; }
  .dock-apps { gap: 6px; }
  .dbtn, .avatar { width: 44px; height: 44px; }
  .avatar { font-size: 15px; }
  .dbtn .tip { display: none; }
  .dock-apps .sep, .dbtn[data-app="settings"] { display: none; }
  .dock-right { gap: 8px; padding-right: 7px; }
  body[data-tools="left"] .dock-right { padding-left: 7px; padding-right: 0; }
  body.in-app .dock { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px; padding: 0 6px 0 2px; }
  body.in-app .dock-apps { gap: 6px; }
  body.in-app .avatar { width: 32px; height: 32px; }
  body.in-app .dock-clock, .app-tools .wide-only { display: none; }
  .app-tools button { width: 30px; }
  .settings .inner { padding: 16px; }
}
