/* ==========================================================================
 *  almegle shell — three-pane layout (sidebar / workspace / inspector) with
 *  a phone toggle so each panel can take the full viewport on small screens.
 *
 *  Derived from the originator shell.css that previously lived under
 *  /api/route/display/library/styles/shell.css. Tokens kept compatible with
 *  the inbox so /messages can opt into this shell without conflict.
 * ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
 * 01. THEME TOKENS
 * ────────────────────────────────────────────────────────────────────────── */
:root {
  /* Default page background. Cards stay --card-bg so the three-panel
   * shell reads as cards-on-canvas. Overridden per-user by the theme
   * picker in the inspector head; localStorage value wins once
   * shell.js boots. */
  --bg: #e8e6df;
  --fg: #000000;
  --card-bg: #ffffff;
  --chat-bg: #f8f7f3;
  --card-border: rgba(0, 0, 0, 0.18);
  --muted: rgba(0, 0, 0, 0.52);
  --surface: rgba(0, 0, 0, 0.04);
  --surface-strong: rgba(0, 0, 0, 0.07);
  --border: rgba(0, 0, 0, 0.14);
  --accent: #000000;
  --accent-fg: #ffffff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.05);
  --shell-gap: 18px;
  --shell-pad: 18px;
  --shell-top: 22px;
  --panel-radius: 24px;
  --header-height: 82px;
  --mobile-toggle-height: 62px;
  --mobile-bottom-safe: calc(var(--shell-pad) + var(--mobile-toggle-height) + 14px);
  /* Desktop footer is fixed-height (single line of links + copyright)
   * — reserved here so .shell stops eating the entire viewport and the
   * footer stays in view without scrolling. Mobile widens it back via
   * the 1040px breakpoint below. */
  --footer-height: 52px;
  --panel-height: calc(100vh - var(--shell-top) - var(--shell-pad) - var(--footer-height));
  color-scheme: light;
}
html.dark {
  --bg: #0e1226;
  --fg: #f0ede8;
  --card-bg: #171a30;
  --chat-bg: #171a30;
  --card-border: rgba(240, 237, 232, 0.18);
  --muted: rgba(240, 237, 232, 0.48);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #f0ede8;
  --accent-fg: #0a0a0a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  min-height: 100%; background: var(--bg); color: var(--fg);
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Single source of truth for base typography. Pages used to set
   * font-size + line-height in their own stylesheets (notably inbox.css
   * with 13px / 1.55), which left section-labels and other inherited
   * line-heights drifting between the home and messages pages. */
  font-size: 13px; line-height: 1.55;
}
body { position: relative; overflow-x: hidden; }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(0,0,0,.04), transparent 60%),
    radial-gradient(700px 400px at 90% 90%, rgba(0,0,0,.04), transparent 60%);
}
html.dark body::before {
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(255,255,255,.05), transparent 60%),
    radial-gradient(700px 400px at 90% 90%, rgba(255,255,255,.04), transparent 60%);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.glass-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--panel-radius); box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--card-border); background: transparent; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .2s, opacity .2s, background .2s;
  font-size: 12px; padding: 0; backdrop-filter: blur(14px);
}
.icon-btn:hover { opacity: .72; transform: scale(1.05); }
.eyebrow {
  font-size: 8px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.inspector-head .eyebrow { text-align: right; }
.section-label {
  font-size: 8px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted);
  padding: 12px 10px 5px; opacity: .55;
}
.serif { font-family: 'Fraunces', 'Times New Roman', serif; font-weight: 300; }
.hidden { display: none !important; }

/* ──────────────────────────────────────────────────────────────────────────
 * 02. SHELL LAYOUT
 * ────────────────────────────────────────────────────────────────────────── */
.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: var(--shell-gap);
  padding: var(--shell-top) var(--shell-pad) 0;
  align-items: stretch;
  /* Height = viewport minus reserved footer so the footer sits in-view
   * without scrolling. min-height stays explicit so a missing footer
   * (or a future header re-add) doesn't collapse the cards. */
  min-height: calc(100vh - var(--footer-height));
  height: calc(100vh - var(--footer-height));
}
.sidebar, .workspace, .inspector {
  position: relative; z-index: 1; min-width: 0;
  height: var(--panel-height); min-height: var(--panel-height); max-height: var(--panel-height);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ──────────────────────────────────────────────────────────────────────────
 * 03. SIDEBAR (left)
 * ────────────────────────────────────────────────────────────────────────── */
.sidebar-head {
  height: var(--header-height); min-height: var(--header-height); max-height: var(--header-height);
  padding: 14px 18px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sidebar-title-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
}
.header-mini-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--card-border); background: transparent; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .15s;
  font-size: 11px;
}
.header-mini-btn:hover { background: var(--surface); transform: translateY(-1px); }
.header-mini-btn.is-active { background: var(--fg); color: var(--bg); }

.sidebar-search { padding: 10px 14px; flex: 0 0 auto; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-input {
  width: 100%; height: 42px; padding: 0 40px 0 14px;
  border-radius: 14px; border: 1px solid var(--card-border);
  background: var(--card-bg); color: var(--fg); outline: none;
  box-shadow: var(--shadow-soft); transition: border-color .18s;
}
.search-input::placeholder { color: var(--muted); opacity: .8; }
.search-input:focus { border-color: var(--fg); }
.search-icon {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 12px; pointer-events: none;
}
.sidebar-section { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px; border-radius: 14px;
  color: var(--fg); transition: background .15s, transform .15s;
  /* Reset native <button> chrome so button-flavour nav items (used by
   * /messages for its conversation/ticket lists) look identical to the
   * <a href>-flavour ones the home page uses. */
  appearance: none; background: transparent; border: none;
  font: inherit; text-align: left; width: 100%;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface); transform: translateY(-1px); }
.nav-item.active { background: var(--surface-strong); }
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--fg); flex: 0 0 36px;
  overflow: hidden;
}
.nav-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.nav-avatar.online { box-shadow: 0 0 0 2px var(--fg); }
/* Safety net: any stray <img> rendered directly inside a .nav-item
   (e.g. due to a renderer hiccup or a third-party paste) gets clamped
   to the avatar slot's size so it can't take over the row. */
.nav-item > img {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; object-fit: cover; display: block;
}
.nav-meta img, .nav-name img, .nav-preview img {
  display: none !important;
}
.nav-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-name { font-size: 13px; font-weight: 600; }
.nav-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ──────────────────────────────────────────────────────────────────────────
 * 04. WORKSPACE (center)
 * ────────────────────────────────────────────────────────────────────────── */
.workspace-head {
  height: var(--header-height); min-height: var(--header-height); max-height: var(--header-height);
  padding: 18px; display: flex; flex-direction: column; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.workspace-head-top { display: flex; align-items: center; gap: 14px; }
.tool-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-strong); color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 44px; font-size: 15px;
}
.workspace-title {
  font-family: 'Fraunces', 'Times New Roman', serif;
  font-size: 22px; font-weight: 300; letter-spacing: -.01em;
}
.workspace-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.workspace-body { flex: 1 1 auto; overflow-y: auto; padding: 18px; }
.workspace-tabs {
  display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.workspace-tab {
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--card-border); background: transparent; color: var(--muted);
  font-size: 11px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.workspace-tab.is-active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.panel-card {
  border: 1px dashed var(--card-border); border-radius: 18px;
  padding: 24px; margin-bottom: 14px;
  background: var(--surface);
}
.panel-card-empty {
  min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-family: 'Fraunces', 'Times New Roman', serif;
  font-style: italic;
}

/* ──────────────────────────────────────────────────────────────────────────
 * 05. INSPECTOR (right)
 * ────────────────────────────────────────────────────────────────────────── */
.inspector-head {
  height: var(--header-height); min-height: var(--header-height); max-height: var(--header-height);
  padding: 14px 18px;
  display: flex; flex-direction: column; justify-content: center;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.inspector-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* Primary CTA button — boxy stamp shape (6px radius + inner dashed
 * perforated frame), accent-filled. Same silhouette as the welcome
 * card tile buttons and the empty-state primary CTAs — one button
 * shape across the entire site. Used by institution forms, room
 * confirm, /messages empty state, inbox new-chat, etc. */
.hm-cta {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 6px;
  background: var(--accent); color: var(--accent-fg);
  border: 1px solid var(--accent);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s, box-shadow .15s, background .15s, color .15s, border-color .15s;
}
.hm-cta::after {
  content: '';
  position: absolute; inset: 3px;
  border: 1px dashed color-mix(in srgb, var(--accent-fg) 45%, transparent);
  border-radius: 3px;
  pointer-events: none;
  transition: border-color .15s;
}
.hm-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hm-cta:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.hm-cta i { font-size: 11px; }

.hm-cta-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--card-border);
}
.hm-cta-ghost::after {
  border-color: color-mix(in srgb, var(--fg) 22%, transparent);
}
.hm-cta-ghost:hover {
  background: var(--surface);
  border-color: var(--fg);
  box-shadow: none;
}
.hm-cta-ghost:hover::after { border-color: var(--fg); }

/* ──────────────────────────────────────────────────────────────────────────
 * Workspace-head scope tabs (5 circles).
 *
 * Originally a world-chat-only construct (chat=world's scope toggles —
 * World / Continent / Country / Region / City) inlined as <style> in
 * index.php. Hoisted here so /messages can reuse the same horizontal
 * circle strip for its Conversations / Tickets / Requests tabs. Works
 * for both <a href> nav and <button data-tab> in-place switching.
 * ────────────────────────────────────────────────────────────────────────── */
.wld-scope-tabs {
  display: flex; gap: 22px;
  align-items: center; justify-content: center;
  flex-wrap: nowrap; overflow-x: auto;
  width: 100%; padding: 0;
  scrollbar-width: none;
}
.wld-scope-tabs::-webkit-scrollbar { display: none; }
.wld-scope-tab {
  appearance: none; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; color: var(--muted);
  cursor: pointer; padding: 0;
  font-family: inherit;
  transition: color .15s;
  /* Fixed-width tabs keep the circles perfectly evenly spaced when
   * labels have wildly different lengths (e.g. "Conversations" vs
   * "Tickets" on /messages, or "Continent" vs "City" on the home
   * world-chat strip). Longer labels truncate via .wld-scope-label's
   * ellipsis rule below; shorter labels just sit centered in their box. */
  flex: 0 0 80px; width: 80px; min-width: 0;
}
.wld-scope-tab:hover { color: var(--fg); }
.wld-scope-circle {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--card-border);
  background: transparent;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.wld-scope-circle i { font-size: 11px; line-height: 1; color: inherit; }
.wld-scope-tab:hover .wld-scope-circle {
  background: var(--surface); border-color: var(--fg);
}
.wld-scope-tab.is-active { color: var(--fg); }
.wld-scope-tab.is-active .wld-scope-circle {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.wld-scope-tab.is-disabled {
  opacity: .45; cursor: not-allowed;
}
.wld-scope-tab.is-disabled:hover { color: var(--muted); }
.wld-scope-tab.is-disabled:hover .wld-scope-circle {
  background: transparent; border-color: var(--card-border);
}
/* `.is-locked` is rendered as a non-anchor <span> when the viewer has
 * left world chat — the continent/country/region/city tabs grey out
 * and ignore clicks until they rejoin via the welcome panel. */
.wld-scope-tab.is-locked {
  opacity: .35; cursor: not-allowed; pointer-events: none;
  user-select: none;
}
.wld-scope-tab.is-locked .wld-scope-circle {
  border-style: dashed;
}
.wld-scope-label {
  font-size: 8.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  line-height: 1;
  max-width: 100%; display: block; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 720px) {
  .wld-scope-tabs { gap: 14px; }
  .wld-scope-label { font-size: 8px; }
}
/* Phones: drop the fixed 80 px per-tab width so 5 tabs always fit the
 * viewport without horizontal scrolling. Flex-grow distributes the
 * remaining width equally; the circles shrink slightly and the labels
 * ellipsis-truncate if a long word ("Continent") would otherwise wrap. */
@media (max-width: 560px) {
  .wld-scope-tabs {
    gap: 4px;
    justify-content: space-between;
    overflow-x: hidden;
  }
  .wld-scope-tab {
    flex: 1 1 0; width: auto; min-width: 0;
    gap: 3px;
  }
  .wld-scope-circle { width: 26px; height: 26px; }
  .wld-scope-circle i { font-size: 10px; }
  .wld-scope-label {
    font-size: 7.5px;
    letter-spacing: .06em;
  }
}
@media (max-width: 380px) {
  .wld-scope-tabs { gap: 2px; }
  .wld-scope-circle { width: 24px; height: 24px; }
  .wld-scope-label { font-size: 7px; letter-spacing: .04em; }
}

/* Theme-picker row in the inspector head — three swatches column-aligned
 * with the 3-col .action-grid below. The circle pops the native colour
 * picker; the small hex input under each is an editable fallback so
 * folks who think in hex can type a value directly. */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
  width: 100%;
  padding: 0 4px;
}
.theme-swatch {
  color: var(--fg);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
}
.theme-swatch-circle {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  cursor: pointer;
  display: inline-block;
  transition: transform .15s, border-color .15s, box-shadow .25s;
  animation: themeSwatchPulseLight 2.8s ease-in-out infinite;
}
html.dark .theme-swatch-circle { animation-name: themeSwatchPulseDark; }
.theme-swatch-circle:hover {
  transform: translateY(-1px);
  border-color: var(--fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 12%, transparent);
  animation-play-state: paused;
}
.theme-swatch-circle:focus-within {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 20%, transparent);
}
.theme-swatch-hex {
  width: 100%; max-width: 64px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 9.5px; font-weight: 600; letter-spacing: .04em;
  text-align: center; text-transform: lowercase;
  color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  padding: 2px 4px; cursor: text;
  transition: border-color .15s, color .15s, background .15s;
}
.theme-swatch-hex:hover { color: var(--fg); }
.theme-swatch-hex:focus {
  outline: none;
  border-color: var(--card-border);
  color: var(--fg);
  background: var(--surface);
}
.theme-swatch-hex.is-invalid {
  color: #c0392b;
  border-color: #c0392b;
}
/* Color input overlays the circle at full size with opacity 0, so taps
 * (on both desktop and mobile) open the native picker directly without
 * a programmatic .click() — mobile browsers ignore synthetic clicks on
 * pointer-events:none elements. */
.theme-swatch-circle input[type="color"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  border: none; padding: 0; margin: 0;
  background: transparent;
  appearance: none; -webkit-appearance: none;
}
.theme-swatch-circle input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.theme-swatch-circle input[type="color"]::-webkit-color-swatch { border: none; }
.theme-swatch-circle input[type="color"]::-moz-color-swatch { border: none; }
@keyframes themeSwatchPulseLight {
  0%, 100% { box-shadow: 0 0 0 0   rgba(0, 0, 0, .14); }
  50%      { box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);   }
}
@keyframes themeSwatchPulseDark {
  0%, 100% { box-shadow: 0 0 0 0   rgba(255, 255, 255, .18); }
  50%      { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);   }
}
@media (prefers-reduced-motion: reduce) {
  .theme-swatch-circle { animation: none; }
}
.inspector-head-row .eyebrow { margin-bottom: 0; }
.inspector-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inspector-action-chip {
  appearance: none; border: 1px solid var(--card-border); background: transparent; color: var(--fg);
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.inspector-action-chip:hover { background: var(--surface); transform: translateY(-1px); border-color: var(--fg); }
.inspector-action-chip.is-accent { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.inspector-action-chip.is-accent:hover { opacity: .9; background: var(--fg); color: var(--bg); }
.inspector-action-chip span { display: none; }
.nav-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--fg); color: var(--bg); margin-left: auto;
}
.inspector-actions-row {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.inspector-theme-toggle { margin-right: auto; }
.other-actions { display: flex; gap: 8px; }
.other-action-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--card-border); background: transparent; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; transition: background .15s, transform .15s;
}
.other-action-btn:hover { background: var(--surface); transform: translateY(-1px); }
.inspector-body { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.inspector-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 14px; margin-bottom: 12px;
}
.inspector-block-inner { display: flex; flex-direction: column; gap: 10px; }

/* ──────────────────────────────────────────────────────────────────────────
 * 06. 12-CELL QUICK-ACTIONS GRID (used in inspector on home; clone of widget grid)
 * ────────────────────────────────────────────────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
  padding: 6px 4px 4px;
}
.action-cell {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: transparent; border: none; cursor: pointer;
  color: var(--fg); padding: 6px 2px;
  transition: transform .18s;
}
.action-cell:hover { transform: translateY(-2px); }
.action-cell:hover .action-icon { background: var(--fg); color: var(--bg); }
.action-icon {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--card-border); background: transparent; color: var(--fg);
  display: grid; place-items: center;
  transition: background .18s, color .18s;
}
.action-icon i { font-size: 14px; line-height: 1; }
.action-label {
  font-size: 8.5px; font-weight: 600; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--muted);
  text-align: center; line-height: 1;
}
.action-cell:hover .action-label { color: var(--fg); }

/* ── 13th cell: light/dark toggle ──────────────────────────────────────
 * Spans the full 3-column grid and centers so it sits on its own row
 * under the 4 rows of icons. The circle reuses the .action-icon shape
 * (same --card-border as the topic cells) and swaps the FontAwesome
 * glyph for a Times-New-Roman ●○ pair — same visual language as the
 * home-page toggle on jamesotieno.ca. Letter-spacing stays at 0 so the
 * filled and empty glyphs render at the same nominal width. */
.action-cell--theme {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 8px;
}
.action-cell--theme .action-icon {
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1;
}
.action-cell--theme:hover .action-icon {
  background: var(--fg);
  color: var(--bg);
}

/* ──────────────────────────────────────────────────────────────────────────
 * 07. MOBILE PANEL TOGGLE + RESPONSIVE
 * ────────────────────────────────────────────────────────────────────────── */
.mobile-panel-toggle { display: none; }

@media (max-width: 1040px) {
  /* On mobile the footer lives below the chat panels (the toggle pill
   * already sits at the bottom of the viewport, so we don't want to
   * fight it for real-estate). Footer-height is zeroed out so the
   * panel-height calc matches the pre-footer-reservation behaviour. */
  :root {
    --footer-height: 0px;
    --panel-height: calc(100vh - var(--shell-top) - var(--mobile-bottom-safe));
  }
  /* Sturdy shell: lock the viewport vertically so the swipe gesture has
   * no vertical scroll to compete with. touch-action: pan-x tells the
   * browser we're only interested in horizontal pans (vertical drags
   * fall through to JS, which we then suppress in shell.js). The body
   * gets overscroll-behavior: none so pull-to-refresh / scroll chaining
   * can't sneak in from the address bar area. */
  html, body {
    height: 100vh; min-height: 100vh; max-height: 100vh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
  }
  body { touch-action: pan-x; }
  .shell {
    grid-template-columns: 1fr;
    gap: 0;
    height: 100vh; min-height: 100vh;
    padding-top: var(--shell-top);
    padding-right: var(--shell-pad); padding-left: var(--shell-pad);
    padding-bottom: var(--mobile-bottom-safe);
    align-items: stretch; overflow: hidden;
    touch-action: pan-x;
  }
  .sidebar, .workspace, .inspector {
    grid-column: 1; grid-row: 1;
    width: 100%;
    height: var(--panel-height); min-height: var(--panel-height); max-height: var(--panel-height);
    transition:
      transform .34s cubic-bezier(.22, 1, .36, 1),
      opacity .28s ease, visibility .28s ease;
    will-change: transform, opacity;
    touch-action: pan-x;
  }
  /* Kill all vertical scroll inside the three panel bodies — the shell
   * is the single fixed viewport. Pages that need to surface long
   * content opt back into scroll via .mobile-scroll on the inner
   * element (which re-enables pan-y just for that subtree). */
  .sidebar-section,
  .workspace-body,
  .inspector-body {
    overflow: hidden;
  }
  .mobile-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  /* Default visible panel per data-mobile-panel attribute on body. */
  body[data-mobile-panel="center"] .workspace,
  body[data-mobile-panel="left"]   .sidebar,
  body[data-mobile-panel="right"]  .inspector {
    opacity: 1; visibility: visible; pointer-events: auto; z-index: 5;
  }
  body[data-mobile-panel="center"] .sidebar   { transform: translateX(-108%); opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="center"] .workspace { transform: translateX(0); }
  body[data-mobile-panel="center"] .inspector { transform: translateX(108%);  opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="left"]   .sidebar   { transform: translateX(0); }
  body[data-mobile-panel="left"]   .workspace { transform: translateX(108%);  opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="left"]   .inspector { transform: translateX(108%);  opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="right"]  .sidebar   { transform: translateX(-108%); opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="right"]  .workspace { transform: translateX(-108%); opacity: 0; visibility: hidden; pointer-events: none; z-index: 1; }
  body[data-mobile-panel="right"]  .inspector { transform: translateX(0); }

  .mobile-panel-toggle {
    position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
    z-index: 1100; display: inline-flex; align-items: center; gap: 8px;
    padding: 8px; border-radius: 999px;
    border: 1px solid var(--card-border); background: var(--card-bg);
    box-shadow: var(--shadow-soft); backdrop-filter: blur(18px);
  }
  .mobile-toggle-btn {
    min-width: 92px; height: 44px; border-radius: 999px;
    border: 1px solid var(--card-border); background: transparent; color: var(--fg);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0 14px; cursor: pointer;
    transition: transform .18s, opacity .18s, background .18s;
    font-size: 12px; font-weight: 600;
  }
  .mobile-toggle-btn:hover { transform: translateY(-1px); opacity: .86; background: var(--surface); }
  .mobile-toggle-btn.is-active { background: var(--surface-strong); }
}
@media (max-width: 560px) {
  .mobile-toggle-btn { min-width: 0; width: 44px; padding: 0; }
  .mobile-toggle-btn span { display: none; }
  .mobile-toggle-btn i { font-size: 14px; }
}

/* ──────────────────────────────────────────────────────────────────
 * ui.toast / ui.confirm / ui.prompt — site-wide replacements for the
 * native alert()/confirm()/prompt() dialogs. Styled to match the rest
 * of almegle (rounded card on a dimmed backdrop, pill buttons, Fraunces
 * heading). See shell.js for the imperative API.
 * ────────────────────────────────────────────────────────────────── */

/* Bottom-centered stack of transient pills. */
.ui-toast-host {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 8px;
  align-items: center;
  z-index: 100000;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.ui-toast {
  background: var(--fg); color: var(--card-bg);
  font-family: inherit; font-size: 13px; line-height: 1.4;
  padding: 11px 18px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease-out, transform .2s ease-out;
  pointer-events: auto;
  max-width: 100%;
  text-align: center;
}
.ui-toast.is-show { opacity: 1; transform: translateY(0); }
.ui-toast--success { background: var(--accent); color: var(--accent-fg, #000); }
.ui-toast--danger  { background: #e05a2b; color: #fff; }

/* Confirm / prompt modal — same backdrop + card shape as the
 * page-local modals in studio so the visual language is consistent. */
.ui-modal {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity .18s ease-out;
}
.ui-modal.is-show { opacity: 1; }
.ui-modal-card {
  background: var(--card-bg); color: var(--fg);
  border: 1px solid var(--card-border); border-radius: 14px;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column;
  transform: scale(.96);
  transition: transform .18s ease-out;
  box-shadow: 0 20px 60px rgba(0,0,0,.32);
}
.ui-modal.is-show .ui-modal-card { transform: scale(1); }
.ui-modal-head { padding: 20px 22px 4px; }
.ui-modal-head h3 {
  margin: 0;
  font-family: 'Fraunces', serif; font-weight: 400;
  font-size: 18px; line-height: 1.35; color: var(--fg);
}
.ui-modal-body {
  padding: 6px 22px 14px;
  font-size: 13px; line-height: 1.55; color: var(--muted);
}
.ui-modal-input { padding: 6px 22px 14px; display: flex; flex-direction: column; gap: 6px; }
.ui-modal-input label {
  font-size: 11px; color: var(--muted); letter-spacing: .04em;
}
.ui-modal-input input,
.ui-modal-input textarea {
  font-family: inherit; font-size: 14px; color: var(--fg);
  background: transparent;
  border: none; border-bottom: 1px solid var(--card-border);
  padding: 8px 0;
  outline: none; resize: vertical;
}
.ui-modal-input input:focus,
.ui-modal-input textarea:focus { border-bottom-color: var(--accent); }
.ui-modal-foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 6px 22px 20px;
}
.ui-btn {
  appearance: none;
  border: 1px solid var(--card-border);
  background: var(--surface); color: var(--fg);
  padding: 7px 18px; border-radius: 999px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  letter-spacing: .02em; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, filter .15s;
}
.ui-btn:hover  { border-color: var(--fg); }
.ui-btn-ghost  { background: transparent; }
.ui-btn-accent {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-fg, #000); font-weight: 600;
}
.ui-btn-accent:hover { filter: brightness(.95); }
.ui-btn-danger {
  background: #e05a2b; border-color: #e05a2b;
  color: #fff; font-weight: 600;
}
.ui-btn-danger:hover { filter: brightness(.95); }
