:root {
  --bg: #0b0f14;
  --text: #e5ecf3;
  --muted: #aab3bd;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-brd: rgba(255, 255, 255, 0.12);
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%; /* stop iOS auto-zooming text */
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% 10%, #0a0f1d, #070b12 60%, #05080d);
  overflow: hidden;               /* dashboard canvas manages scroll */
  overscroll-behavior: none;      /* prevent rubber-band scrolling on mobile */
}

a, button {
  touch-action: manipulation;     /* quicker taps; avoids double-delay */
}

#app {
  height: 100%;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--glass-brd);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* genie-style add/remove hooks (subtle) */
@keyframes genie-in {
  0% { transform: scale(.96) translateY(4px); opacity: 0; }
  40% { transform: scale(1.02) translateY(-1px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes genie-out {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.96) translateY(4px); opacity: 0; }
}
.widget.enter { animation: genie-in .28s ease; }
.widget.exit  { animation: genie-out .22s ease; }

/* ======================
   Top bar (desktop-like)
   ====================== */
.topbar {
  position: fixed;
  top: 12px; left: 12px; right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  z-index: 50;
  flex-wrap: nowrap;              /* keep everything in one row */
  white-space: nowrap;            /* prevent line breaks on buttons */
}

.tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;              /* don't stack tabs on mobile */
  max-width: 55%;
  overflow: hidden;               /* avoid pushing buttons to next line */
}

.tab {
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid var(--glass-brd);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.06);
  user-select: none;
  flex: 0 0 auto;                 /* remain compact */
}

.tab.active {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.25), rgba(167, 139, 250, 0.25));
}

.spacer { flex: 1; }

.divider {
  width: 1px; height: 28px;
  background: rgba(255, 255, 255, 0.15);
}

.btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--glass-brd);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform .15s ease;
  white-space: nowrap;            /* keep buttons single-line */
  flex: 0 0 auto;
}
.btn:hover { transform: translateY(-1px); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.accent { background: linear-gradient(135deg, rgba(125, 211, 252, 0.25), rgba(167, 139, 250, 0.25)); }

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ==============
   Canvas/Widgets
   ============== */
.canvas {
  position: absolute;
  inset: 0;
  padding-top: 64px;
}

.widget {
  position: absolute;
  min-width: 180px;
  min-height: 120px;
  border-radius: 16px;
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.widget .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
}

.widget .body {
  padding: 12px;
  font-size: 14px;
  flex: 1;
  min-height: 0;                 /* allow inner content to flex correctly */
}

/* Drag handles: ensure touch drag works (don’t scroll the page) */
.widget .grab,
.widget .resize {
  touch-action: none;            /* critical for pointer-based dragging on mobile */
}

.widget .grab { cursor: grab; }
.widget .grab:active { cursor: grabbing; }

.widget .resize {
  position: absolute;
  right: 8px; bottom: 8px;
  width: 12px; height: 12px;
  border-right: 2px solid rgba(255, 255, 255, 0.6);
  border-bottom: 2px solid rgba(255, 255, 255, 0.6);
  cursor: nwse-resize;
}

.widget .actions { display: flex; gap: 6px; }

.iconbtn {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--glass-brd);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.iconbtn.ghost {
  background: transparent;
}

/* Widget content helpers */
.widget .searchbar {
  display: flex;
  gap: 6px;
  align-items: center;
  border-radius: 10px;
  border: 1px solid var(--glass-brd);
  background: rgba(255, 255, 255, 0.06);
  padding: 6px;
}
.widget .searchbar input.input {
  background: transparent; border: none; flex: 1;
}

/* Make embedded content fully interactive (e.g., Google Maps) */
.widget .body,
.widget .body * { pointer-events: auto; }

/* Iframe defaults */
.widget iframe.full {
  width: 100%; height: 100%;
  border: 0;
  border-radius: 12px;
  display: block;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

/* Map widget: no inner padding; iframe fills area */
.widget[data-type="map"] .body { padding: 0; }
.map-wrap { width: 100%; height: 100%; }
.map-frame {
  width: 100%; height: 100%;
  border: 0; display: block; pointer-events: auto;
}

.widget[data-type="lofi"] {
  overflow: visible;
  position: relative;
}

.lofi-wrap {
  position: relative;
  height: 100%;
  padding: 24px 20px;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  --lofi-glow: rgba(167, 139, 250, 0.4);
}

.lofi-wrap::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.1), transparent 55%),
              linear-gradient(135deg, var(--lofi-glow), rgba(125,211,252,0.18));
  opacity: 0.35;
  filter: blur(10px);
  transition: opacity 0.45s ease;
  animation: lofiGradient 45s linear infinite;
  z-index: 0;
}

.lofi-wrap.playing {
  box-shadow: 0 0 18px var(--lofi-glow);
}

.lofi-wrap.playing::before {
  opacity: 0.6;
}

@keyframes lofiGradient {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1); }
}

.lofi-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.lofi-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lofi-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.lofi-meta,
.lofi-status {
  font-size: 13px;
  color: var(--muted);
}

.lofi-status {
  min-height: 16px;
}

.lofi-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.lofi-volume {
  width: 80%;
  accent-color: var(--accent);
}

.lofi-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text, #fff);
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
  transition: background 0.3s ease, transform 0.18s ease;
}

.lofi-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.lofi-btn:active {
  transform: scale(0.95);
}

.lofi-btn.accent {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.35), rgba(167, 139, 250, 0.35));
  border-color: rgba(255, 255, 255, 0.22);
}

.lofi-btn.accent:hover {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.45), rgba(167, 139, 250, 0.45));
}

.widget img.cover {
  width: 100%; height: 100%;
  object-fit: cover; display: block; border-radius: 12px;
}

.widget.clickable { cursor: pointer; }

.weather-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.weather-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.weather-temp {
  font-size: 32px;
  font-weight: 800;
}

.weather-meta {
  font-size: 13px;
  color: var(--muted);
}

.weather-forecast {
  max-height: 160px;
  overflow-y: auto;
}

.weather-table th,
.weather-table td {
  padding: 6px 8px;
  text-align: left;
}




/* ===== Calculator Widget ===== */
.widget[data-type="calc"] .body { padding: 10px; }

.calc-wrap {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  height: 100%;
  min-height: 0;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calc-title {
  font-weight: 700;
  letter-spacing: .2px;
}

.calc-actions { display: flex; gap: 6px; }

.calc-io {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.calc-input {
  width: 100%;
  height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.4;
}

.calc-results {
  border: 1px solid var(--glass-brd);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255,255,255,0.06);
  overflow: auto;
  min-height: 0;
  max-height: 120px;
}

.calc-tools {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.calc-quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.calc-quick button {
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.calc-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-help {
  display: none;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  padding: 8px 10px;
}
.calc-help.open { display: block; }
.calc-help ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.calc-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.calc-row:last-child { border-bottom: 0; }

.calc-lno { color: var(--muted); font-size: 12px; }

/* ===== Photo widget ===== */
.photo-plain {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-plain img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s ease, filter .2s ease;
}

.photo-plain.is-rounded {
  border-radius: 50%;
}

.photo-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

/* ===== Gradient builder ===== */
.gradient-builder {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.04);
}

.gradient-preview {
  height: 64px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}

.gradient-timeline {
  height: 26px;
  border-radius: 30px;
  position: relative;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.04);
  overflow: hidden;
  cursor: crosshair;
}
.gradient-timeline::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 30px;
  background-image: var(--grad-preview, linear-gradient(90deg,#fff,#000));
  opacity: 0.85;
  pointer-events: none;
}

.gradient-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.4);
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
  background: #fff;
  cursor: pointer;
  transition: transform .15s ease;
}
.gradient-handle:focus-visible,
.gradient-handle:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.gradient-mode {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.stacked {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.gradient-angle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gradient-angle input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.gradient-stops {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gradient-stop {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
}

.gradient-stop input[type="color"] {
  width: 36px;
  height: 32px;
  border: none;
  background: transparent;
  padding: 0;
}

.gradient-stop input[type="range"] {
  width: 100%;
}

.gradient-stop input[type="number"] {
  width: 64px;
}

.gradient-stop button {
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
}

.gradient-stop-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gradient-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gradient-presets button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  background-size: 200% 200%;
  transition: transform .15s ease, border-color .2s;
}

.gradient-presets button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(125,211,252,0.4);
}

.gradient-presets button:focus-visible,
.gradient-presets button:hover {
  transform: translateY(-1px) scale(1.02);
  border-color: rgba(255,255,255,0.5);
}

.bg-upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.bg-upload-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bg-upload-meta {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.bg-upload input.input {
  background: rgba(255,255,255,0.06);
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.2);
}

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

.starfield-row {
  gap: 6px;
  flex-direction: column;
  align-items: flex-start;
}
.starfield-row .switch {
  font-size: 14px;
}
.starfield-row.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.input.compact {
  padding: 8px 10px;
  font-size: 13px;
}

/* ===== Camera widget ===== */
.camera-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}

.camera-preview {
  width: 100%;
  border-radius: 16px;
  background: rgba(0,0,0,0.4);
  min-height: 140px;
  object-fit: cover;
}

.camera-preview.mirrored {
  transform: scaleX(-1);
}

.camera-controls,
.camera-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.camera-action {
  display: flex;
  gap: 6px;
  align-items: center;
}

.camera-action select.input {
  width: 120px;
}

.camera-status {
  font-size: 13px;
}

.camera-gallery {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.camera-chip {
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

.file-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== Speedtest ===== */
.speedtest-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.speed-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
}

.speed-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.speed-val {
  font-size: 24px;
  font-weight: 700;
  margin-top: 2px;
}

.speed-val.small {
  font-size: 18px;
}

.speed-progress {
  margin-top: 10px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.speed-meter {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(125,211,252,0.7), rgba(167,139,250,0.8));
  transition: width .2s ease;
}

.speed-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.speed-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

/* ===== Games ===== */
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.game-card:focus-visible,
.game-card:focus-within {
  outline: 2px solid rgba(125,211,252,0.45);
  outline-offset: 2px;
}

.game-canvas {
  width: 100%;
  border-radius: 12px;
  background: rgba(5,9,15,0.6);
  display: block;
  touch-action: none;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.game-overlay {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(9,12,20,0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  backdrop-filter: blur(6px);
}

.game-overlay.hidden { display: none; }

.game-overlay-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* 2048 tiles */
.game-2048 .grid {
  display: grid;
  gap: 6px;
  margin-top: 4px;
  grid-template-columns: repeat(var(--grid-size, 4), minmax(0, 1fr));
}

.game-2048 .tile {
  border-radius: 10px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  background: rgba(255,255,255,0.04);
  transition: transform .15s ease;
}

.game-2048 .tile[data-value="0"] { opacity: 0.2; }
.game-2048 .tile[data-value="2"] { background: rgba(255,255,255,0.08); }
.game-2048 .tile[data-value="4"] { background: rgba(167,139,250,0.2); }
.game-2048 .tile[data-value="8"] { background: rgba(125,211,252,0.25); }
.game-2048 .tile[data-value="16"] { background: rgba(248,113,113,0.35); }
.game-2048 .tile[data-value="32"] { background: rgba(251,146,60,0.4); }
.game-2048 .tile[data-value="64"] { background: rgba(234,179,8,0.5); }
.game-2048 .tile[data-value="128"] { background: rgba(129,199,132,0.5); }
.game-2048 .tile[data-value="256"] { background: rgba(14,165,233,0.5); }
.game-2048 .tile[data-value="512"] { background: rgba(126,34,206,0.5); }
.game-2048 .tile[data-value="1024"] { background: rgba(236,72,153,0.55); }
.game-2048 .tile[data-value="2048"] { background: linear-gradient(135deg,#f97316,#facc15); color: #111; }

/* Wordle */
.wordle-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  position: relative;
}

.wordle-grid {
  display: grid;
  gap: 6px;
  justify-items: stretch;
}

.wordle-cell {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  text-transform: uppercase;
  transition: transform .15s ease, background .2s ease;
}

.wordle-cell.active {
  border-color: rgba(125,211,252,0.6);
}

.wordle-cell.revealed { color: #0a0d16; }
.wordle-cell.correct { background: #4ade80; }
.wordle-cell.present { background: #fde047; }
.wordle-cell.absent { background: rgba(148,163,184,0.8); }

.wordle-keyboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wordle-key-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.wordle-keyboard button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 8px 6px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 12px;
}

.wordle-keyboard button[data-state="correct"] { background: #4ade80; color: #0a0d16; }
.wordle-keyboard button[data-state="present"] { background: #fde047; color: #0a0d16; }
.wordle-keyboard button[data-state="absent"] { background: rgba(148,163,184,0.6); }

/* Minesweeper */
.mine-board {
  width: 100%;
  border-collapse: collapse;
  user-select: none;
}

.mine-cell {
  width: 28px;
  height: 28px;
  text-align: center;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
}

.mine-cell.open { background: rgba(255,255,255,0.08); cursor: default; }
.mine-cell.mine { background: rgba(248,113,113,0.4); }

.mine-cell[data-count="1"] { color: #93c5fd; }
.mine-cell[data-count="2"] { color: #6ee7b7; }
.mine-cell[data-count="3"] { color: #fca5a5; }
.mine-cell[data-count="4"] { color: #c4b5fd; }
.mine-cell[data-count="5"] { color: #f97316; }
.mine-cell[data-count="6"] { color: #38bdf8; }
.mine-cell[data-count="7"] { color: #f472b6; }
.mine-cell[data-count="8"] { color: #fde047; }

/* Visualizer */
.visualizer-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 6px;
}

.visualizer-canvas {
  width: 100%;
  height: 140px;
  border-radius: 12px;
  background: rgba(5,9,15,0.5);
}

/* Analog clock */
.clock-analog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.calc-val  {
  text-align: right;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-word;
}

.calc-row.err .calc-val { color: #f59e0b; }

.calc-graph {
  height: 100%;
  min-height: 90px;
  padding: 8px;
  border-radius: 12px;
  display: grid;
}
.calc-graph canvas { width: 100% !important; height: 100% !important; }

/* ===== Countdown widget ===== */
.widget[data-type="countdown"] .body { padding: 12px; }

.countdown-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.countdown-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.countdown-label-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.countdown-label-input:focus {
  outline: none;
  border-bottom: 1px solid rgba(255,255,255,0.3);
}

.countdown-summary {
  font-size: 13px;
  color: var(--muted);
}

.countdown-display {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.countdown-segment {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.06);
}

.countdown-value {
  font-size: 26px;
  font-weight: 700;
}

.countdown-unit {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.countdown-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.countdown-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.countdown-inline input[type="datetime-local"] {
  flex: 1;
  min-width: 160px;
}

.countdown-buttons {
  display: flex;
  gap: 6px;
}

.countdown-hint {
  font-size: 12px;
  color: var(--muted);
}
.countdown-hint.error {
  color: #f87171;
}


/* ===========
   Side panels
   =========== */
.sidepanel {
  position: fixed;
  top: 70px;
  right: -380px;
  width: 360px;
  bottom: 12px;
  padding: 12px;
  z-index: 5000;
  transition: right .25s ease;
}
.sidepanel.open { right: 12px; }

.sidepanel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}

.input {
  width: 100%; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--glass-brd);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.widget-list {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  margin-top: 8px;
  max-height: calc(100% - 90px);
  overflow: auto;
}

.widget-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px; border-radius: 12px;
}
.widget-item .name { font-weight: 600; }
.widget-item .desc { color: var(--muted); font-size: 12px; }

/* Background video + starfield */
.bg-video {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: -2; display: none; pointer-events: none;
}
.bg-starfield {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: -1; display: none;
  pointer-events: none;
}

/* Light theme support */
.light {
  --bg: #f7f8fb;
  --text: #0e1524;
  --muted: #536175;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-brd: rgba(0, 0, 0, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  background: radial-gradient(1000px 700px at 10% 10%, #ffffff, #f0f3f9 60%, #e9eef7);
}

/* Simple elements used by widgets */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.table th { text-align: left; font-size: 12px; color: var(--muted); }

.link { color: var(--accent); text-decoration: none; }

.tag {
  padding: 2px 6px; border-radius: 6px; font-size: 12px;
  background: rgba(125, 211, 252, 0.2);
}

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.switch input { width: 36px; }

/* Context menu */
.ctxmenu {
  position: fixed; z-index: 9999; min-width: 180px;
  padding: 8px; border-radius: 12px;
  border: 1px solid var(--glass-brd);
  background: var(--glass-bg);
  box-shadow: var(--shadow);
}
.ctxmenu .btn.small { width: 100%; text-align: left; }

/* ================================
   SETTINGS MODAL
   ================================ */
#settingsModal {
  position: fixed; inset: 0; z-index: 10000; /* above everything */
  display: none; /* JS sets to flex to show */
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.35);
}
#settingsModal.show { display: flex; }

.settings-window {
  width: min(720px, calc(100% - 32px));
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  animation: modal-pop 0.25s ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
@keyframes modal-pop {
  0% { transform: scale(0.96) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-brd);
  cursor: move; /* draggable via JS */
}
.settings-heading {
  font-weight: 700;
  font-size: 18px;
}
.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-content {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  padding: 20px;
}
.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-widget-label {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  border-radius: 12px;
  padding: 10px 12px;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-nav .btn.small {
  width: 100%;
  text-align: left;
}
.settings-body {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-row label { font-size: 14px; font-weight: 500; color: var(--muted); }
.settings-row input,
.settings-row select,
.settings-row textarea {
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--glass-brd);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text); font-size: 14px;
}
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--glass-brd);
  gap: 10px;
}
.settings-footer .btn { min-width: 90px; }
#settingsReset { background: rgba(255, 255, 255, 0.08); }
#settingsSave  { background: linear-gradient(135deg, rgba(125, 211, 252, 0.25), rgba(167, 139, 250, 0.25)); }

/* ==================
   Assistant widget
   ================== */
.assistant-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  height: 100%;
  text-align: center;
  padding: 8px 12px;
}
.assistant-placeholder__title {
  font-size: 18px;
  font-weight: 700;
}
.assistant-placeholder__copy {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.assistant-ui {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  pointer-events: none;
}
.assistant-ui .assistant-bubble {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.85), rgba(167, 139, 250, 0.85));
  color: #0f172a;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: relative;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.45);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
}
.assistant-bubble__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(rgba(255, 255, 255, 0.25), transparent 70%);
  animation: assistant-breath 3.2s ease-in-out infinite;
}
.assistant-bubble__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.65));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  position: relative;
}
.assistant-bubble__avatar::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.7);
}
.assistant-bubble__label {
  position: absolute;
  bottom: -24px;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.8;
  color: rgba(255, 255, 255, 0.9);
}
.assistant-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.5);
}
.assistant-bubble.is-busy::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  animation: assistant-spin 1.4s linear infinite;
}
.assistant-ui[data-open="true"] .assistant-bubble {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
.assistant-panel {
  pointer-events: none;
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 340px;
  max-height: calc(80vh);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.28s ease, transform 0.26s ease;
}
.assistant-ui[data-open="true"] .assistant-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.assistant-panel[data-mode="drawer"] {
  bottom: 24px;
  height: calc(100vh - 96px);
  width: 380px;
  max-height: none;
}
.assistant-panel[data-mode="drawer"] .assistant-panel__messages {
  flex: 1;
}
.assistant-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.assistant-panel__meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.assistant-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  position: relative;
}
.assistant-avatar__glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(rgba(125, 211, 252, 0.55), rgba(167, 139, 250, 0.3));
  filter: blur(4px);
  animation: assistant-breath 4.5s ease-in-out infinite;
}
.assistant-avatar__dot {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7dd3fc, #a78bfa);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.6);
}
.assistant-panel__title {
  font-size: 18px;
  font-weight: 700;
}
.assistant-panel__status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
}
.assistant-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}
.assistant-icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
}
.assistant-panel__messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(70vh);
  overflow-y: auto;
  padding-right: 6px;
}
.assistant-panel__messages::-webkit-scrollbar {
  width: 6px;
}
.assistant-panel__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.assistant-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assistant-msg--user {
  align-items: flex-end;
}
.assistant-msg__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.35);
}
.assistant-msg--user .assistant-msg__bubble {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.85), rgba(167, 139, 250, 0.85));
  color: #0f172a;
}
.assistant-msg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.assistant-link {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.assistant-link:hover { text-decoration: underline; }
.assistant-msg--enter {
  animation: assistant-pop 0.22s ease;
}
.assistant-msg__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.assistant-chip {
  background: rgba(125, 211, 252, 0.12);
  border: 1px solid rgba(125, 211, 252, 0.35);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.assistant-chip:hover {
  background: rgba(125, 211, 252, 0.25);
  transform: translateY(-1px);
}
.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.assistant-panel__composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-panel__composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.35);
  color: var(--text);
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  transition: border 0.18s ease, background 0.18s ease;
}
.assistant-panel__composer textarea:focus {
  border-color: rgba(125, 211, 252, 0.6);
  outline: none;
  background: rgba(15, 23, 42, 0.5);
}
.assistant-composer__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.assistant-send {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.8), rgba(167, 139, 250, 0.8));
  color: #0f172a;
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.assistant-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
}
.assistant-toast-stack {
  position: absolute;
  bottom: 80px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.assistant-toast {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.assistant-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.assistant-toast--success {
  border: 1px solid rgba(74, 222, 128, 0.6);
}
.assistant-toast--warn {
  border: 1px solid rgba(248, 113, 113, 0.6);
}
@keyframes assistant-breath {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes assistant-spin {
  0% { transform: rotate(0deg); opacity: 0.6; }
  50% { opacity: 1; }
  100% { transform: rotate(360deg); opacity: 0.6; }
}
@keyframes assistant-pop {
  0% { transform: translateY(4px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 720px) {
  .settings-content {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .settings-sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .settings-nav .btn.small {
    flex: 1 1 auto;
  }
}

/* (Optional) Slightly smaller chrome on very narrow screens,
   but layout still stays "desktop" because of the meta viewport */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .tab { padding: 6px 10px; }
  .btn.small { padding: 5px 8px; }
}
