/* Facade Panes: structure and shared components. Each edition stylesheet
   supplies the tokens below plus its own window chrome. */

@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: #0f161c; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.shell {
  --accent: #e8b830;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  font: var(--ui-size)/1.4 var(--ui-font);
  color: var(--desk-fg);
  background: var(--desk-bg);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.shell[aria-busy="true"] > * { visibility: hidden; }
.shell.reduce-motion *, .shell.reduce-motion *::before, .shell.reduce-motion *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .shell *, .shell *::before, .shell *::after { transition: none !important; animation: none !important; }
}

input, textarea { user-select: text; -webkit-user-select: text; }

/* Desktop surface */
.desktop { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.wallpaper { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.windows { position: absolute; inset: 0; }
.shell.is-satellite .windows { inset: 0; }
.shell.is-satellite .win-handle { display: none; }

.desktop-icons {
  position: absolute; left: 8px; top: 8px; bottom: 8px;
  display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: 10px;
}
.desk-icon {
  width: 84px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; color: var(--icon-fg); text-align: center; font-size: 0.95em;
}
.desk-icon span { padding: 1px 3px; text-shadow: var(--icon-text-shadow); }
.desk-icon:focus span { background: var(--selection); color: var(--selection-fg); text-shadow: none; }
.desk-icon:focus-visible { outline: 1px dotted var(--icon-fg); outline-offset: 0; }

/* Windows */
.win {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--win-bg); color: var(--win-fg);
  border: var(--win-border); border-radius: var(--win-radius);
  box-shadow: var(--win-shadow);
  min-width: 0; min-height: 0;
}
.win:focus { outline: none; }
.win.is-max { border-radius: 0; }
.win.is-dragging, .win.is-resizing { user-select: none; }
.win-title {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: var(--title-h); padding: var(--title-pad);
  background: var(--title-bg-inactive); color: var(--title-fg-inactive);
  font-weight: 600; touch-action: none;
}
.win.is-active .win-title { background: var(--title-bg); color: var(--title-fg); }
.win-icon { display: grid; place-items: center; flex: none; }
.win-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-controls { display: flex; flex: none; align-self: stretch; align-items: center; gap: var(--ctl-gap); }
.win-btn { display: grid; place-items: center; padding: 0; background: none; border: 0; color: inherit; }
.win-body { flex: 1; min-height: 0; overflow: auto; position: relative; user-select: text; -webkit-user-select: text; background: var(--body-bg); }
.win-handle { position: absolute; z-index: 1; }
.win.is-max .win-handle { display: none; }
.win-handle-n, .win-handle-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.win-handle-n { top: -3px; } .win-handle-s { bottom: -3px; }
.win-handle-e, .win-handle-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.win-handle-e { right: -3px; } .win-handle-w { left: -3px; }
.win-handle-ne, .win-handle-nw, .win-handle-se, .win-handle-sw { width: 12px; height: 12px; }
.win-handle-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.win-handle-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.win-handle-nw { top: -4px; left: -4px; cursor: nwse-resize; }
.win-handle-se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.snap-preview { position: absolute; pointer-events: none; background: var(--snap-bg); border: var(--snap-border); border-radius: var(--win-radius); }
.app-error { padding: 24px; color: var(--muted); }

/* Taskbar */
.taskbar {
  flex: none; position: relative; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  height: var(--tb-h); padding: var(--tb-pad);
  background: var(--tb-bg); color: var(--tb-fg); border-top: var(--tb-border);
}
.tb-start { display: flex; align-items: center; gap: 8px; height: var(--tb-btn-h); padding: 0 10px; font-weight: 700; }
.tb-start-logo { display: grid; place-items: center; }
.tb-sep { width: 1px; height: 60%; background: var(--tb-sep); margin: 0 4px; }
.tb-pinned, .tb-tasks { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-tasks { flex: 1; overflow: hidden; }
.tb-pin { display: grid; place-items: center; width: var(--tb-btn-h); height: var(--tb-btn-h); padding: 0; }
.tb-task { display: flex; align-items: center; gap: 6px; height: var(--tb-btn-h); min-width: 0; max-width: 180px; flex: 0 1 180px; padding: 0 8px; }
.tb-task-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-tray { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
.tb-tray-btn { display: flex; align-items: center; gap: 6px; height: var(--tb-btn-h); padding: 0 8px; }
.tb-ws-name { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-char-text { display: flex; flex-direction: column; text-align: left; line-height: 1.15; min-width: 0; }
.tb-char-name { font-weight: 600; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-char-role { font-size: 0.85em; color: var(--tb-muted); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-clock { flex-direction: column; justify-content: center; gap: 0; line-height: 1.15; text-align: right; font-variant-numeric: tabular-nums; }
.tb-clock-date { font-size: 0.85em; color: var(--tb-muted); }
.tb-offline { display: grid; place-items: center; color: var(--danger); padding: 0 4px; }
.tb-avatar {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: var(--avatar-radius);
  font-size: 10.5px; font-weight: 700; color: #fff; background: #556270;
}
.tb-avatar.role-civilian { background: #3e6a52; }
.tb-avatar.role-leo { background: #2c4f7c; }
.tb-avatar.role-fire-ems { background: #8a3a2c; }

/* Popovers and menus */
.popover {
  position: fixed; z-index: 10000;
  background: var(--pop-bg); color: var(--pop-fg);
  border: var(--pop-border); border-radius: var(--pop-radius); box-shadow: var(--pop-shadow);
  max-height: calc(100vh - 16px); overflow: auto;
}
.menu { display: flex; flex-direction: column; padding: var(--menu-pad); min-width: 200px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; text-align: left;
  padding: var(--menu-item-pad); background: none; border: 0; border-radius: var(--menu-radius); color: inherit;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); color: var(--hover-fg); outline: none; }
.menu-item[disabled] { color: var(--muted); }
.menu-item.is-checked .menu-icon::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.menu-icon { width: 16px; display: grid; place-items: center; flex: none; }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--sep); }

.charlist { display: flex; flex-direction: column; gap: 6px; width: 320px; padding: 8px; }
.charlist.is-compact { width: auto; padding: 0; }
.charlist-search, .sm-search, .cp-input, .dialog-input {
  width: 100%; height: 32px; padding: 0 10px;
  background: var(--input-bg); color: var(--input-fg); border: var(--input-border); border-radius: var(--input-radius);
}
.charlist-items { display: flex; flex-direction: column; gap: 1px; max-height: 320px; overflow: auto; }
.charlist.is-compact .charlist-items { max-height: 300px; border: var(--input-border); border-radius: var(--input-radius); padding: 4px; background: var(--input-bg); }
.charlist-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; text-align: left; background: none; border: 0; border-radius: var(--menu-radius); color: inherit; }
.charlist-item:hover, .charlist-item:focus-visible { background: var(--hover); color: var(--hover-fg); outline: none; }
.charlist-item.is-current { background: var(--current-bg); }
.charlist-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.2; }
.charlist-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charlist-job { font-size: 0.88em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charlist-item:hover .charlist-job, .charlist-item:focus-visible .charlist-job { color: inherit; }
.charlist-note, .charlist-foot { margin: 4px 2px; color: var(--muted); font-size: 0.92em; max-width: 36ch; user-select: text; }

.clockpop-body { padding: 14px 16px; width: 260px; }
.clockpop-time { font-size: 2em; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clockpop-date { color: var(--muted); margin-bottom: 12px; }
.cal-title { font-weight: 600; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-variant-numeric: tabular-nums; }
.cal-dow { font-size: 0.8em; color: var(--muted); padding: 2px 0; }
.cal-day { padding: 3px 0; border-radius: var(--menu-radius); }
.cal-day.is-today { background: var(--accent); color: var(--accent-fg); font-weight: 700; }

/* Widgets */
.widgets { position: absolute; top: 14px; right: 14px; width: 240px; display: flex; flex-direction: column; gap: 10px; z-index: 0; }
.widget { background: var(--widget-bg); color: var(--widget-fg); border: var(--widget-border); border-radius: var(--widget-radius); padding: 10px 12px 12px; box-shadow: var(--widget-shadow); }
.widget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.widget-title { font: 500 0.78em/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--widget-muted); }
.widget-remove { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; background: none; border: 0; color: var(--widget-muted); opacity: 0; border-radius: var(--menu-radius); }
.widget:hover .widget-remove, .widget-remove:focus-visible { opacity: 1; }
.widget-remove:hover { background: var(--hover); color: var(--hover-fg); }
.widget-big { font-size: 2em; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.widget-sub { color: var(--widget-muted); margin-top: 2px; }
.widget-note-text { width: 100%; resize: vertical; min-height: 90px; max-height: 320px; padding: 6px 8px; background: var(--input-bg); color: var(--input-fg); border: var(--input-border); border-radius: var(--input-radius); line-height: 1.45; }

/* Dialogs */
.dialog-backdrop { position: fixed; inset: 0; z-index: 20000; display: grid; place-items: center; background: var(--backdrop); }
.dialog { width: min(420px, calc(100vw - 32px)); background: var(--win-bg); color: var(--win-fg); border: var(--win-border); border-radius: var(--win-radius); box-shadow: var(--win-shadow); }
.dialog-title { height: var(--title-h); padding: var(--title-pad); display: flex; align-items: center; background: var(--title-bg); color: var(--title-fg); font-weight: 600; }
.dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--body-bg); }
.dialog-label { font-weight: 600; }
.dialog-text { margin: 0; line-height: 1.5; user-select: text; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; background: var(--body-bg); border-radius: 0 0 var(--win-radius) var(--win-radius); }

/* Buttons used inside apps and dialogs */
.dialog-btn, .cp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; padding: 0 14px;
  background: var(--btn-bg); color: var(--btn-fg); border: var(--btn-border); border-radius: var(--btn-radius); box-shadow: var(--btn-shadow);
}
.dialog-btn:hover:not([disabled]), .cp-btn:hover:not([disabled]) { background: var(--btn-hover); }
.dialog-btn:active:not([disabled]), .cp-btn:active:not([disabled]) { box-shadow: var(--btn-shadow-active); }
.dialog-btn[disabled], .cp-btn[disabled] { opacity: 0.5; }
.dialog-btn.is-primary, .cp-btn.cp-primary { background: var(--primary-bg); color: var(--primary-fg); border: var(--primary-border); }
.dialog-btn.is-primary:hover:not([disabled]), .cp-btn.cp-primary:hover:not([disabled]) { background: var(--primary-hover); }
.dialog-btn.is-danger, .cp-btn.cp-danger { color: var(--danger); }
.dialog-btn.is-primary.is-danger { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: calc(var(--tb-h) + 12px); z-index: 30000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px 10px 10px 14px; background: var(--pop-bg); color: var(--pop-fg); border: var(--pop-border); border-radius: var(--pop-radius); box-shadow: var(--pop-shadow); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-text { flex: 1; user-select: text; }
.toast-action { background: none; border: 0; color: var(--link); font-weight: 600; padding: 4px 6px; }
.toast-close { background: none; border: 0; color: var(--muted); font-size: 1.2em; line-height: 1; padding: 2px 6px; }

/* Control Panel */
.cp { display: grid; grid-template-columns: 170px 1fr; height: 100%; }
.cp-nav { display: flex; flex-direction: column; gap: 1px; padding: 10px 6px; background: var(--side-bg); border-right: var(--side-border); overflow: auto; }
.cp-nav-item { text-align: left; padding: 7px 10px; background: none; border: 0; border-radius: var(--menu-radius); color: inherit; }
.cp-nav-item:hover { background: var(--hover-soft); }
.cp-nav-item.is-current { background: var(--current-bg); font-weight: 600; }
.cp-content { padding: 18px 22px 28px; overflow: auto; min-width: 0; }
.cp-title { font-size: 1.45em; margin: 0 0 14px; font-weight: 700; }
.cp-intro { margin: 0 0 14px; color: var(--muted); max-width: 60ch; line-height: 1.5; }
.cp-field { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--sep); }
.cp-field:first-of-type { border-top: 0; }
.cp-label { font-weight: 600; padding-top: 5px; }
.cp-control { min-width: 0; }
.cp-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.92em; max-width: 56ch; line-height: 1.45; }
.cp-stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.cp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cp-radios { display: flex; gap: 16px; flex-wrap: wrap; }
.cp-radio, .cp-check { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
.cp-radio input, .cp-check input { margin: 0; accent-color: var(--accent); }
.cp-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-swatch { width: 26px; height: 26px; padding: 0; border: var(--swatch-border); border-radius: var(--swatch-radius); }
.cp-swatch.is-current { outline: 2px solid var(--focus); outline-offset: 2px; }
.cp-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; width: 100%; }
.cp-preset { display: flex; flex-direction: column; gap: 4px; padding: 4px; background: none; border: 2px solid transparent; border-radius: var(--btn-radius); color: inherit; text-align: left; }
.cp-preset canvas { width: 100%; height: auto; display: block; border: 1px solid var(--sep); }
.cp-preset.is-current { border-color: var(--accent); }
.cp-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cp-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: var(--item-bg); border: var(--item-border); border-radius: var(--btn-radius); }
.cp-item.is-current { border-color: var(--accent); }
.cp-item .cp-input { width: 200px; }
.cp-item-name { font-weight: 600; }
.cp-item-meta { color: var(--muted); font-size: 0.92em; }
.cp-item-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.cp-icon { padding: 0 9px; }
.cp-tag { font: 500 0.78em var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }
input[type="range"] { accent-color: var(--accent); width: 220px; }
input[type="color"] { width: 34px; height: 28px; padding: 0 2px; background: none; border: var(--input-border); border-radius: var(--input-radius); }
output { font-variant-numeric: tabular-nums; min-width: 44px; }

/* About */
.about { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.about-brand { display: flex; align-items: center; gap: 14px; }
.about-name { font-size: 1.5em; font-weight: 700; line-height: 1.1; }
.about-edition { color: var(--muted); }
.about-facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.about-facts dt { color: var(--muted); }
.about-facts dd { margin: 0; }
.about-legal { margin: 0; color: var(--muted); font-size: 0.88em; }

/* Boot failure */
.boot-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: #dfe6ec; background: #0f161c; font-family: system-ui, sans-serif; }
.boot-error h1 { margin: 0; font-size: 22px; }
.boot-error p { margin: 0; max-width: 48ch; color: #9aa9b5; }

@media (max-width: 640px) {
  .tb-task-name, .tb-ws-name, .tb-char-text, .tb-start-label { display: none; }
  .widgets { display: none; }
  .cp { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .cp-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: var(--side-border); }
  .cp-field { grid-template-columns: 1fr; gap: 6px; }
}

/* Navigator */
.win-body.nav-body { display: flex; flex-direction: column; overflow: hidden; }
.nav-bar { flex: none; display: flex; align-items: center; gap: 4px; padding: var(--nav-bar-pad, 6px 8px); background: var(--nav-bar-bg, var(--title-bg)); border-bottom: var(--nav-bar-border, 1px solid var(--sep)); }
.nav-btn { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; background: none; border: 0; border-radius: var(--btn-radius); color: inherit; }
.nav-btn:hover:not([disabled]) { background: var(--hover-soft); }
.nav-btn[disabled] { opacity: 0.35; }
.nav-form { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; background: var(--input-bg); color: var(--input-fg); border: var(--input-border); border-radius: var(--input-radius); }
.nav-form:focus-within { outline: 2px solid var(--focus); outline-offset: -1px; }
.nav-zone { flex: none; font: 600 10px/1 var(--mono); padding: 3px 5px; color: #2f6b3a; background: #e9f1e9; border: 1px solid #bcd6bf; border-radius: 3px; }
.nav-address { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: inherit; }
.nav-frame { flex: 1; min-height: 0; width: 100%; border: 0; background: #fff; display: block; }
.nav-status { flex: none; display: none; justify-content: space-between; gap: 8px; padding: 2px 6px; font-size: 0.92em; }
