/* --- Brand themes ------------------------------------------------------
   Meraki Halo brand: charcoal #1b1918, beige #d3cbbe, teal #378797, white.
   Dark mode (default): charcoal first, teal and beige as accents.
   Light mode: beige first, charcoal and teal as accents. */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1918;
  --panel: #242220;
  --panel-border: rgba(211, 203, 190, 0.1);
  --raised: #2e2b29;
  --input-bg: #1b1918;
  --surface: rgba(211, 203, 190, 0.05);
  --surface-border: rgba(211, 203, 190, 0.12);
  --text: #f3efe9;
  --muted: #a79f93;
  --teal: #378797;
  --accent: #5fadba;          /* teal that reads well as text on charcoal */
  --beige: #d3cbbe;
  --icon: #d3cbbe;
  --selected-bg: #d3cbbe;
  --selected-text: #1b1918;
  --thinking: #d3cbbe;
  --user-bubble: rgba(55, 135, 151, 0.24);
  --user-bubble-border: rgba(55, 135, 151, 0.45);
  --danger: #dd9274;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --orb-bg: radial-gradient(circle at 50% 38%, #2f2c2a 0%, #1f1d1c 62%, #161413 100%);
  --orb-ring: rgba(211, 203, 190, 0.14);
  --orb-glow: rgba(55, 135, 151, 0.22);
  --focus: rgba(95, 173, 186, 0.7);
  --backdrop: rgba(10, 9, 9, 0.6);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e3ddd2;
  --panel: #f4f1eb;
  --panel-border: rgba(27, 25, 24, 0.08);
  --raised: #ffffff;
  --input-bg: #ffffff;
  --surface: rgba(27, 25, 24, 0.04);
  --surface-border: rgba(27, 25, 24, 0.1);
  --text: #1b1918;
  --muted: #6b645b;
  --teal: #378797;
  --accent: #2b7482;          /* darker teal so it reads well on beige */
  --beige: #d3cbbe;
  --icon: #1b1918;
  --selected-bg: #1b1918;
  --selected-text: #f4f1eb;
  --thinking: #5a534b;
  --user-bubble: rgba(55, 135, 151, 0.14);
  --user-bubble-border: rgba(55, 135, 151, 0.32);
  --danger: #a8502f;
  --shadow: 0 16px 44px rgba(27, 25, 24, 0.12);
  --orb-bg: radial-gradient(circle at 50% 38%, #ece6dc 0%, #d3cbbe 70%, #c7beb0 100%);
  --orb-ring: rgba(27, 25, 24, 0.1);
  --orb-glow: rgba(55, 135, 151, 0.16);
  --focus: rgba(43, 116, 130, 0.6);
  --backdrop: rgba(27, 25, 24, 0.35);
}

[hidden] { display: none !important; }

/* Keep signed-in pages blank until the sign-in check has finished. */
.auth-pending body { visibility: hidden; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: background-color 0.3s, color 0.3s;
}

body {
  display: flex;
  flex-direction: column;
}

/* --- Top bar ------------------------------------------------------------ */

.topbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 16px 12px;
}

.view-switch {
  grid-column: 2;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}

.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.view-switch button:hover { color: var(--text); }

.view-switch button[aria-selected="true"] {
  background: var(--selected-bg);
  color: var(--selected-text);
}

.view-switch svg,
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 8px;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle svg { width: 20px; height: 20px; }

/* Show the sun in dark mode (switch to light) and the moon in light mode. */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* --- Settings / Log out buttons in the top bar ------------------------------ */

.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.top-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.top-btn:disabled { opacity: 0.6; cursor: wait; }

.top-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-btn { grid-column: 1; justify-self: start; }

/* --- Settings page ------------------------------------------------------------ */

.settings-page { max-width: 640px; }

.details { margin: 0; display: grid; gap: 12px; }
.details div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.details dt { color: var(--muted); font-size: 14px; }
.details dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.panel .notice { margin: 14px 0 0; }

/* --- Layout of the two views ------------------------------------------ */

.views {
  flex: 1;
  min-height: 0;
  display: grid;
}

.views[data-view="map"] {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.views[data-view="map"] .halo { margin: 0 16px 16px 0; }
.views[data-view="map"] .dashboard { display: none; }

.views[data-view="dashboard"] { grid-template-columns: minmax(0, 1fr); }
.views[data-view="dashboard"] .stage { display: none; }

/* --- Customisable dashboard (GridStack) --------------------------------------------- */

.dashboard {
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.dash-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 8px 4px;
}

.dash-hint { flex: 1; margin: 0; font-size: 13px; color: var(--muted); }
.dash-actions { display: flex; gap: 8px; }

.grid-stack { min-height: 200px; }

.grid-stack-item-content {
  box-sizing: border-box;
  border-radius: 20px;
  overflow: hidden;
}

/* Halo fills its grid spot */
.halo-item .grid-stack-item-content { overflow: visible; }
.halo-item .halo { height: 100%; margin: 0; }
.halo-item .halo .avatar-orb { width: min(230px, 60%); }

/* Widgets share the panel look */
.widget {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.widget-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.widget-head small { color: var(--muted); font-size: 12px; }

/* Widgets that are cards of their own (weather, tasks) fill the widget instead */
.widget-weather,
.widget-tasks { padding: 0; background: none; border: 0; box-shadow: none; }
.widget > .weather,
.widget > .tasks-card { width: 100%; height: 100%; max-height: none; box-sizing: border-box; overflow: auto; }

/* Edit mode: dashed outlines, drag anywhere, remove buttons */
.dashboard.is-editing .grid-stack-item-content { outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -2px; }
.dashboard.is-editing .grid-stack-item:not(.halo-item) .grid-stack-item-content::after {
  content: "";
  position: absolute;
  inset: 0;
  cursor: move;
}

.widget-remove {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.dashboard.is-editing .widget-remove { display: block; }
.grid-stack-item.halo-item .widget-remove { display: none !important; }

/* GridStack resize handles in brand colours */
.dashboard .ui-resizable-handle { opacity: 0; }
.dashboard.is-editing .ui-resizable-handle { opacity: 1; }
.dashboard .ui-resizable-se { background: none; border-right: 3px solid var(--accent); border-bottom: 3px solid var(--accent); width: 14px; height: 14px; right: 6px; bottom: 6px; transform: none; }
.grid-stack-placeholder > .placeholder-content { border-radius: 20px; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 2px dashed var(--accent); }

/* Widget library */
.widget-library { width: min(640px, calc(100vw - 32px)); }
.library-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.library-head h2 { margin: 0; }
.library-head .icon-btn svg [fill="none"] { fill: none; }
.library-cat h3 { margin: 16px 0 8px; font-size: 13px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }

.library-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.library-item:hover:not(:disabled) { border-color: var(--accent); }
.library-item:disabled { opacity: 0.5; cursor: default; }
.library-item strong { font-weight: 500; font-size: 14px; }
.library-item small { font-size: 12px; color: var(--muted); line-height: 1.35; }
.library-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Small widgets */
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }

.whiteboard {
  flex: 1;
  min-height: 0;
  resize: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.timer-display { font-size: 44px; font-weight: 300; text-align: center; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.timer-display.is-done { color: var(--accent); animation: pulse 1s ease-in-out 3; }
.timer-presets { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.timer-custom { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.timer-custom input { width: 54px; padding: 5px 6px; border-radius: 8px; border: 1px solid var(--surface-border); background: var(--input-bg); color: var(--text); font: inherit; }
.timer-controls { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.inspiration { margin: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.inspiration p { margin: 0; font-size: 17px; line-height: 1.45; font-style: italic; }
.inspiration footer { margin-top: 8px; font-size: 13px; color: var(--accent); }

.voice-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.voice-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--teal); color: #fff; cursor: pointer; display: grid; place-items: center; }
.voice-btn svg { width: 28px; height: 28px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.voice-btn svg [fill="none"] { fill: none; }
.voice-btn[aria-pressed="true"] { background: var(--danger); animation: ring 1.6s ease-out infinite; }
.voice-btn:disabled { opacity: 0.5; cursor: wait; }
.voice-status { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }

.notes-list, .widget-notices { margin: 0; padding: 0; list-style: none; overflow-y: auto; min-height: 0; flex: 1; }

.note-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 6px;
  border: 0;
  border-top: 1px solid var(--surface-border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

li:first-child > .note-item { border-top: 0; }
.note-item:hover { background: var(--surface); }
.note-item strong { font-size: 14px; font-weight: 500; }
.note-item span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item small { font-size: 11px; color: var(--muted); }
.note-item small.is-soon { color: var(--danger); }

.game-canvas { flex: 1; min-height: 0; width: 100%; border-radius: 12px; background: var(--surface); outline: none; touch-action: none; cursor: pointer; }
.game-canvas:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
.game-top { margin: 8px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Note editor ---------------------------------------------------------------------- */

.note-dialog { width: min(640px, calc(100vw - 32px)); }
.note-dialog form { display: flex; flex-direction: column; gap: 10px; }
.note-dialog .note-title { font-size: 20px; font-weight: 500; }
.note-dialog .note-body { min-height: 240px; line-height: 1.5; }
.note-expiry { margin: 0; font-size: 13px; color: var(--muted); }
.note-actions { align-items: center; }
.note-actions .spacer { flex: 1; }

/* --- Top bar menus: notifications bell and profile ---------------------------------------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  top: 50px;
  right: 0;
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  padding: 8px;
  border-radius: 16px;
  background: var(--raised);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.menu-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 8px; }
.menu-label { margin: 8px 8px 4px; font-size: 12px; color: var(--muted); }

.menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover { background: var(--surface); }
.bell-btn { position: relative; }
.notice-list { margin: 0; padding: 0; list-style: none; max-height: 60vh; overflow-y: auto; }

.notice {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.notice:hover { background: var(--surface); }
.notice.is-unread { background: color-mix(in srgb, var(--teal) 10%, transparent); }
.notice-icon svg { width: 20px; height: 20px; margin-top: 2px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.notice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notice-text strong { font-size: 14px; font-weight: 500; }
.notice-text span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.notice-text small { font-size: 11px; color: var(--muted); }
.notice-count { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--teal); color: #fff; font-size: 11px; }
.notice-empty { padding: 16px 8px; font-size: 14px; color: var(--muted); text-align: center; }

.profile-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: color-mix(in srgb, var(--teal) 22%, transparent);
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.profile-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 4px; }
.profile-head strong { font-size: 15px; font-weight: 500; }
.profile-head span { font-size: 13px; color: var(--muted); }
.status-options { display: flex; flex-direction: column; padding: 0 2px 6px; border-bottom: 1px solid var(--surface-border); margin-bottom: 6px; }

.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.status-option:hover { background: var(--surface); }
.status-option[aria-checked="true"] { background: var(--surface); font-weight: 500; }

/* Status colours (also used for the online dot in Messages) */
.status-dot-mini, .msgr-online { background: #4caf7d; }
.status-dot-mini { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
[data-status="busy"], [data-status="dnd"] { --status-colour: #d0634f; }
[data-status="meeting"] { --status-colour: #9d7bd8; }
[data-status="away"] { --status-colour: #d9a441; }
.status-dot-mini[data-status], .msgr-online[data-status] { background: var(--status-colour, #4caf7d); }
.profile-btn .status-dot-mini { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--bg); }

/* --- Mind map side buttons and pop-ups ---------------------------------------------------- */

.map-side { position: absolute; top: 4px; left: 16px; z-index: 5; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.map-side .map-add { position: relative; top: auto; left: auto; }

.tasks-pop {
  position: fixed;
  top: 70px;
  left: 16px;
  z-index: 25;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  animation: slide-in 0.25s ease-out;
}

.tasks-pop .tasks-card { max-height: none; }
.tasks-pop-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.tasks-pop-close svg [fill="none"] { fill: none; }
.tasks-pop .tasks-head { padding-right: 44px; }
.trash-pop { padding: 20px 18px 14px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 24px; box-shadow: var(--shadow); box-sizing: border-box; }
.trash-pop .card-title { margin-right: 44px; }

.tasks-card.is-flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } }

/* Complete / Undo on tasks */
.task-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.task-complete { padding: 4px 12px; border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); }
.task-complete:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.task-done-label { font-size: 12px; color: var(--accent); }

/* Admin: awaiting approval */
.approvals h2 { display: flex; align-items: center; gap: 8px; }
.approvals-count { padding: 0 8px; border-radius: 999px; background: var(--teal); color: #fff; font-size: 13px; }
.approvals-intro { margin: -8px 0 12px; }
.approvals-list { margin: 0; padding: 0; list-style: none; }
.approval { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--surface-border); }
.approval:first-child { border-top: 0; }
.approval-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 260px; }
.approval-text strong { font-weight: 500; }
.approval-text span, .approval-text small { font-size: 13px; color: var(--muted); }
.approval-reason { font-style: italic; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Mind map: labels, Add button, website card ------------------------------ */

.map-labels {
  position: absolute;
  inset: 0;
  z-index: 1; /* keeps the labels' own ordering underneath the Add menu and website card */
  pointer-events: none;
}

.map-label {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  text-shadow: 0 1px 3px var(--bg);
  transition: color 0.15s;
}

.map-label-category { font-size: 12px; font-weight: 600; color: var(--text); }
.map-label-center { margin-top: 0; font-size: 16px; font-weight: 500; letter-spacing: 0.42em; color: var(--text); }
.map-label.is-hover { color: var(--accent); }

.map-add {
  position: absolute;
  top: 4px;
  left: 16px;
  z-index: 5;
}

.map-add-btn svg { stroke-width: 2; }

.map-add-menu {
  position: absolute;
  top: 50px;
  left: 0;
  min-width: 180px;
  padding: 6px;
  border-radius: 14px;
  background: var(--raised);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.map-add-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.map-add-item:hover { background: var(--surface); }

.map-add-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
}

.node-card {
  position: absolute;
  z-index: 6;
  min-width: 200px;
  max-width: 280px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--raised);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.node-card-name { margin: 0; font-size: 15px; font-weight: 500; }
.node-card-url { margin: 2px 0 12px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.node-card-actions { display: flex; gap: 8px; }

/* Links in Halo's chat (search sources, blocked tabs) */
.msg-links { max-width: 100%; text-align: center; line-height: 1.6; }
.msg-links a { color: var(--accent); }

/* Something Halo will say out loud as soon as it can */
.msg-queued { opacity: 0.75; }

/* "Hey Halo" switch in Halo's header */
.wake-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.wake-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.wake-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-border); }
.wake-btn[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.wake-btn[aria-pressed="true"] .wake-dot { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }

/* Unread count on the Messages button */
.top-btn { position: relative; }
.top-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* --- Tasks card (dashboard, left of Halo) ------------------------------------ */

.tasks-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
  padding: 20px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.tasks-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tasks-count { margin-left: 4px; font-size: 13px; color: var(--accent); }

.tasks-tabs {
  display: flex;
  gap: 4px;
  margin: 14px 0 8px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}

.tasks-tabs button {
  flex: 1;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.tasks-tabs button[aria-selected="true"] { background: var(--selected-bg); color: var(--selected-text); }

.tasks-list { margin: 0; padding: 0; list-style: none; overflow-y: auto; min-height: 0; }

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 4px;
  border-top: 1px solid var(--surface-border);
}

.task:first-child { border-top: 0; }
.task-check { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--teal); cursor: pointer; }
.task-dot { width: 8px; height: 8px; margin: 6px 5px 0; border-radius: 50%; background: var(--accent); }
.task-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-title { font-size: 14px; overflow-wrap: anywhere; }
.task-meta, .task-notes { font-size: 12px; color: var(--muted); }
.task-notes { font-style: italic; }
.task-overdue { color: var(--danger); }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task.is-done .task-dot { background: var(--muted); }

.task-delete {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.task-delete:hover { color: var(--danger); }
.tasks-empty { padding: 16px 4px; color: var(--muted); font-size: 14px; text-align: center; }

/* --- Messenger (slides in from the left) ------------------------------------- */

.messenger {
  position: fixed;
  top: 70px;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  width: min(380px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: slide-in 0.25s ease-out;
}

@keyframes slide-in { from { opacity: 0; transform: translateX(-16px); } }

.msgr-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--surface-border); }
.msgr-title { flex: 1; margin: 0; font-size: 18px; font-weight: 500; display: flex; flex-direction: column; min-width: 0; }
.msgr-title small { font-size: 12px; font-weight: 400; color: var(--accent); }
.msgr-call-btns { display: flex; gap: 6px; }
.msgr-head .icon-btn svg [fill="none"] { fill: none; }

.msgr-people { flex: 1; overflow-y: auto; padding: 6px; }

.msgr-person {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.msgr-person:hover { background: var(--surface); }

.msgr-avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--teal) 22%, transparent);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.msgr-online {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4caf7d;
  border: 2px solid var(--panel);
}

.msgr-person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msgr-person-text strong { font-weight: 500; font-size: 15px; }
.msgr-person-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgr-person-text span.is-unread { color: var(--text); font-weight: 500; }
.msgr-person-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--muted); }

.msgr-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.msgr-empty { padding: 24px 16px; color: var(--muted); font-size: 14px; text-align: center; line-height: 1.5; }

.msgr-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 14px; }

.chat-msg {
  align-self: flex-start;
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 16px 16px 16px 6px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg.is-mine { align-self: flex-end; border-radius: 16px 16px 6px 16px; background: var(--user-bubble); border-color: var(--user-bubble-border); }
.chat-msg small { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); text-align: right; }
.chat-call { align-self: center; margin: 4px 0; font-size: 12px; color: var(--muted); }

.msgr-composer { margin: 0 12px 12px; align-items: flex-end; border-radius: 22px; }

.msgr-composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 10px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.msgr-composer .mic-btn { width: 40px; height: 40px; }

/* --- Call screen ----------------------------------------------------------------- */

.call {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #121110;
  color: #f3efe9;
}

#call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #121110; }

#call-local {
  position: absolute;
  right: 16px;
  bottom: 110px;
  width: min(220px, 30vw);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transform: scaleX(-1); /* mirror, like looking in a mirror */
}

/* Voice calls (and video calls before they connect) show a name card instead of video */
.call[data-video="off"] video,
.call:not([data-state="connected"]) #call-remote { opacity: 0; pointer-events: none; }
.call[data-video="off"] #call-local { display: none; }

.call-info { position: relative; text-align: center; }
.call[data-video="on"][data-state="connected"] .call-info { position: absolute; top: 24px; left: 24px; text-align: left; }
.call[data-video="on"][data-state="connected"] .call-avatar { display: none; }

.call-avatar {
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #378797;
  font-size: 40px;
  font-weight: 600;
}

.call[data-state="incoming"] .call-avatar,
.call[data-state="calling"] .call-avatar { animation: ring-pulse 1.6s ease-out infinite; }

@keyframes ring-pulse {
  0% { box-shadow: 0 0 0 0 rgba(55, 135, 151, 0.6); }
  100% { box-shadow: 0 0 0 28px rgba(55, 135, 151, 0); }
}

.call-name { margin: 0; font-size: 26px; font-weight: 500; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.call-status { margin: 6px 0 0; font-size: 15px; color: #d3cbbe; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }

.call-actions { position: absolute; bottom: 32px; display: flex; gap: 12px; }

.call-btn {
  min-width: 96px;
  height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.call-btn[aria-pressed="true"] { background: #d3cbbe; color: #1b1918; }
.call-accept { background: #3f9b6d; }
.call-decline { background: #c0533f; }

/* Which buttons show at each stage of a call */
.call[data-state="incoming"] #call-mute,
.call[data-state="incoming"] #call-camera,
.call[data-state="incoming"] #call-hangup,
.call:not([data-state="incoming"]) #call-accept,
.call:not([data-state="incoming"]) #call-decline,
.call[data-video="off"] #call-camera { display: none; }

/* --- Pop-up notices ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 14px;
  text-align: left;
  animation: pop 0.25s ease-out;
}

button.toast { cursor: pointer; }
.toast strong { font-weight: 500; }
.toast span { color: var(--muted); font-size: 13px; }

/* --- Settings: Halo preferences and Recently deleted ----------------------------------- */

.prefs-intro { margin: -8px 0 14px; }
.prefs { display: flex; flex-direction: column; gap: 4px; }

.pref {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 12px !important;
  padding: 10px 0;
  cursor: pointer;
}

.pref .switch { margin-top: 2px; }
.pref-text { display: flex; flex-direction: column; gap: 2px; }
.pref-text strong { font-size: 15px; font-weight: 400; color: var(--text); }
.pref-text small { font-size: 12px; color: var(--muted); line-height: 1.4; }

.trash-list { margin: 0; padding: 0; list-style: none; }

.trash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--surface-border);
}

.trash-item:first-child { border-top: 0; }
.trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trash-text strong { font-weight: 400; font-size: 15px; overflow-wrap: anywhere; }
.trash-text small { font-size: 12px; color: var(--muted); }
.trash-empty { padding: 8px 0; color: var(--muted); font-size: 14px; }

/* What each user is allowed to see */
.views[data-halo="off"] .halo { display: none; }
.views[data-view="map"][data-halo="off"] { grid-template-columns: minmax(0, 1fr); }

.no-access {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

/* --- Map ------------------------------------------------------------- */

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#map:active {
  cursor: grabbing;
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

/* --- Halo panel ------------------------------------------------------ */

.halo {
  min-height: 0;
  padding: 22px 20px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.halo-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.settings {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 5;
  width: 220px;
  padding: 14px;
  border-radius: 16px;
  background: var(--raised);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.settings[hidden] { display: none; }

.settings label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.settings select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.settings-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.msg-note {
  align-self: center;
  max-width: none;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
}

.halo-name {
  margin: 0;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.16em;
}

.halo-tagline {
  margin: 2px 0 10px;
  font-size: 14px;
  color: var(--muted);
}

.status {
  --status: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--status);
  background: color-mix(in srgb, var(--status) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status) 32%, transparent);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.halo[data-state="thinking"] .status,
.halo[data-state="connecting"] .status { --status: var(--thinking); }
.halo[data-state="error"] .status { --status: var(--danger); }

.halo[data-state="listening"] .status-dot,
.halo[data-state="thinking"] .status-dot,
.halo[data-state="speaking"] .status-dot,
.halo[data-state="connecting"] .status-dot {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.3; }
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.icon-btn svg [fill="none"],
.mic-btn svg [fill="none"] { fill: none; }

.icon-btn .icon-off { display: none; }
.icon-btn[aria-pressed="false"] .icon-on { display: none; }
.icon-btn[aria-pressed="false"] .icon-off { display: block; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }

/* Halo's robot lives in a circle */
.avatar-orb {
  position: relative;
  width: 230px;
  aspect-ratio: 1;
  margin: 12px auto 16px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--orb-bg);
  box-shadow:
    inset 0 0 0 1px var(--orb-ring),
    0 0 40px var(--orb-glow);
}

.avatar-orb canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Messages */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 12px;
}

.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-halo {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-bottom-left-radius: 6px;
}

.msg-user {
  align-self: flex-end;
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  border-bottom-right-radius: 6px;
}

.msg-pending { color: var(--muted); font-style: italic; }
.msg-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* Composer */
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.composer input::placeholder { color: var(--muted); }

.mic-btn {
  width: 48px;
  height: 48px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.mic-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.mic-btn[aria-pressed="true"] {
  background: var(--selected-bg);
  color: var(--selected-text);
  box-shadow: 0 0 0 0 rgba(55, 135, 151, 0.55);
  animation: ring 1.6s ease-out infinite;
}

@keyframes ring {
  to { box-shadow: 0 0 0 14px rgba(55, 135, 151, 0); }
}

.composer-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.8;
}

button:focus-visible,
.weather:focus-visible,
.composer:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Weather card (dashboard) ----------------------------------------- */

.weather {
  box-sizing: border-box;
  padding: 22px 22px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.weather:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.weather-place {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.weather-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weather-temp {
  font-size: 64px;
  font-weight: 300;
  line-height: 1.1;
}

.wx-icon {
  fill: none;
  stroke: var(--icon);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.weather-icon .wx-icon { width: 72px; height: 72px; }

.weather-summary {
  margin: 4px 0 0;
  font-size: 16px;
}

.weather-feels {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin: 16px 0 0;
  padding: 12px 4px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  list-style: none;
}

.week li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.week .day-name { color: var(--muted); }
.week .wx-icon { width: 26px; height: 26px; stroke-width: 3.2; }
.week .hi { font-size: 14px; }
.week .lo { color: var(--muted); }
.week .rain { color: var(--accent); font-size: 11px; }

.weather-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.weather-more {
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

/* --- Long-range forecast box -------------------------------------------- */

.forecast-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.forecast-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(4px);
}

.forecast-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.forecast-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 12px;
}

.forecast-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}

.forecast-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.forecast-list {
  margin: 0;
  padding: 0 14px 10px;
  overflow-y: auto;
  list-style: none;
}

.forecast-list li {
  display: grid;
  grid-template-columns: 92px 34px minmax(0, 1fr) 48px 44px 110px 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-top: 1px solid var(--surface-border);
  font-size: 14px;
}

.forecast-list li:first-child { border-top: 0; }

.forecast-list .fc-day strong { display: block; font-weight: 500; }
.forecast-list .fc-day span { font-size: 12px; color: var(--muted); }
.forecast-list .wx-icon { width: 30px; height: 30px; stroke-width: 3; }
.forecast-list .fc-words { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forecast-list .fc-rain { color: var(--accent); text-align: right; }
.forecast-list .fc-lo { color: var(--muted); text-align: right; }
.forecast-list .fc-hi { text-align: left; }

.range {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-border);
}

.range span {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--teal), var(--beige));
}

.forecast-note {
  margin: 0;
  padding: 10px 22px 18px;
  font-size: 12px;
  color: var(--muted);
}

/* --- Shared form bits ---------------------------------------------------- */

.btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #ffffff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-small { padding: 6px 12px; font-size: 13px; }

.auth-form label,
.panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.auth-form input,
.panel input:not([type="checkbox"]),
.panel select,
.panel textarea {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.panel textarea { resize: vertical; }
.panel select:disabled { opacity: 0.5; }

.auth-form input:focus,
.panel input:focus,
.panel select:focus,
.panel textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* --- Sign-in page ----------------------------------------------------------- */

body.auth-page {
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

.auth-theme {
  position: fixed;
  top: 14px;
  right: 16px;
}

.auth-card {
  width: min(400px, 100%);
  margin: auto;
  padding: 32px 28px 26px;
  box-sizing: border-box;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}

.auth-title {
  margin: 14px 0 4px;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.auth-sub {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-hint {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-submit {
  margin-top: 4px;
  padding: 13px;
  border: 0;
  border-radius: 999px;
  background: var(--teal);
  color: #ffffff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.auth-submit:disabled { opacity: 0.6; cursor: wait; }

.auth-link {
  align-self: center;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.auth-message,
.notice {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.auth-message[data-kind="ok"],
.notice[data-kind="ok"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--teal) 12%, transparent);
}

/* --- Admin: Users page ----------------------------------------------------- */

body.admin-page {
  display: block;
  overflow-y: auto;
}

.brand {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.brand img { border-radius: 50%; }
.brand-sub { color: var(--muted); margin-left: 4px; }

.admin {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 12px 0 20px;
}

.admin-head h1 { margin: 0; font-size: 28px; font-weight: 400; }
.admin-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.notice { margin: 0 0 16px; }

.panel {
  padding: 22px;
  margin: 0 0 20px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 16px; font-size: 18px; font-weight: 500; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

.perm-set {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.perm-set legend { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.perm-set > div { display: flex; flex-wrap: wrap; gap: 8px 20px; }

.form-hint { margin: 14px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* On/off switches for permissions */
.switch {
  display: inline-flex;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 14px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-border);
  transition: background 0.2s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s;
}

.switch input:checked + .switch-track { background: var(--teal); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #ffffff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* User list */
.user-list { display: flex; flex-direction: column; gap: 10px; }

.user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(0, 1.5fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
}

.user-row.is-admin { grid-template-columns: 1fr; opacity: 0.85; }

.user-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.user-main strong { font-weight: 500; font-size: 15px; }
.user-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.user-role { font-size: 13px; color: var(--text); }
.user-alias { font-size: 13px; color: var(--muted); }
.user-alias strong { font-size: 13px; color: var(--accent); }

.user-perms { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.user-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.badge {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--surface-border);
}

.badge-on { color: var(--accent); border-color: color-mix(in srgb, var(--teal) 35%, transparent); }
.badge-wait { color: var(--thinking); }
.badge-off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.temp-dialog {
  width: min(440px, calc(100vw - 32px));
  margin: auto;
  color: var(--text);
}

.temp-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.temp-dialog form > label { margin-top: 14px; }
.temp-dialog .form-hint + .stack { margin-top: 14px; }
.temp-dialog h2 + .form-hint { margin-top: -8px; }

@media (max-width: 860px) {
  .user-row { grid-template-columns: 1fr; }
  .user-actions { justify-content: flex-start; }
}

/* Narrow screens: stack everything in one column */
@media (max-width: 760px) {
  .topbar { padding: 10px 16px 8px; grid-template-columns: 1fr auto; row-gap: 10px; }
  .topbar .view-switch { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .top-btn { width: 42px; padding: 0; justify-content: center; }
  .top-btn span { display: none; }
  .details div { grid-template-columns: 1fr; gap: 2px; }
  .views[data-view] {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 16px;
  }
  .views[data-view="map"] .halo { flex: 1; margin: 0; }
  .views[data-view="dashboard"] { padding: 0 8px 8px; }
  .dashboard { flex: 1; padding: 0; }
  .dash-hint { font-size: 12px; }
  .stage { flex: none; height: 30vh; margin: 0 -16px; }
  .map-side .top-btn span { display: none; }
  .tasks-pop { top: 110px; left: 8px; right: 8px; width: auto; }
  .messenger { top: 60px; left: 8px; right: 8px; bottom: 8px; width: auto; }
  .wake-btn { padding: 0 10px; }
  .call-btn { min-width: 0; padding: 0 16px; }
  .weather .card-title, .weather-feels, .weather-footer { display: none; }
  .weather-place { margin: 0; }
  .weather-temp { font-size: 40px; }
  .weather-icon .wx-icon { width: 48px; height: 48px; }
  .week { margin-top: 8px; padding: 8px 2px; }
  .week .rain { display: none; }
  .halo .avatar-orb { width: 120px; margin: 4px auto 8px; }
  .hint { display: none; }
  .forecast-list li { grid-template-columns: 70px 30px 40px 36px minmax(40px, 1fr) 36px; }
  .forecast-list .fc-words { display: none; }
}

/* Two-step sign-in: the emailed 6-digit code */
.auth-form .code-input {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- Left bar: icon-only bin ------------------------------------------------------------- */
.top-btn.icon-only { width: 42px; padding: 0; justify-content: center; }

/* --- Email ---------------------------------------------------------------------------------- */
.mail-pop .widget-head { padding-right: 44px; }
.mail-pop .form-hint { margin: -4px 0 8px; }
.mail-list, .away-list, .mailbox-list { list-style: none; margin: 0; padding: 0; }
.mail-item, .away-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 9px 6px;
  border: 0;
  border-top: 1px solid var(--surface-border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}
li:first-child > .mail-item, li:first-child > .away-item { border-top: 0; }
.mail-item:hover, .away-item:hover { background: var(--surface); }
.mail-item strong, .away-item strong { font-size: 14px; font-weight: 500; }
.mail-item span, .away-item span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item small { font-size: 11px; color: var(--muted); }
.mail-error { margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.mail-list .tasks-empty a { color: var(--accent); }
.mail-webmail-link { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent); text-decoration: none; }
.mail-webmail-link:hover { text-decoration: underline; }

.mail-reader { width: min(760px, calc(100vw - 32px)); }
.mail-reader .library-head h2 { font-size: 19px; line-height: 1.3; margin-right: 12px; }
.mail-meta { margin: 0 0 2px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.mail-body { margin: 12px 0 8px; }
.mail-text { max-height: 60vh; overflow-y: auto; padding: 12px 14px; border-radius: 12px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.mail-frame { display: block; width: 100%; height: 60vh; border: 0; border-radius: 12px; background: #fff; }
.mail-reader .form-actions a.btn { text-decoration: none; }

.mail-compose { width: min(640px, calc(100vw - 32px)); }
.mail-compose textarea { min-height: 200px; resize: vertical; }
.mail-compose .notice a { color: inherit; }

/* Settings: connected mailboxes */
.mailbox-list { margin-bottom: 12px; }
.mailbox-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--surface-border); }
.mailbox-list li:first-child { border-top: 0; }
.mailbox-list li span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.mailbox-list small { color: var(--muted); font-size: 12px; }
.mailbox-empty { color: var(--muted); font-size: 14px; }

/* --- While you were away ---------------------------------------------------------------- */
.away-dialog { width: min(560px, calc(100vw - 32px)); }
.away-dialog .form-hint { margin: 4px 0 0; }
#away-body { max-height: 60vh; overflow-y: auto; }
.away-section h3 { margin: 14px 0 4px; font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* --- "Still busy?" ------------------------------------------------------------------------ */
.status-nudge {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  width: min(340px, calc(100vw - 32px));
  padding: 14px 16px;
  box-sizing: border-box;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease-out;
}
.status-nudge p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.status-nudge-actions { display: flex; gap: 8px; justify-content: flex-end; }
