/* ============================================================
   HippoOS 2.0 – Core Styles
   ============================================================ */
:root {
  --accent: #4f46e5;
  --accent-rgb: 79, 70, 229;
  --radius: 18px;
  --font-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --status-h: 28px;
  --dock-h: 64px;

  /* Light */
  --bg: #f0f2f5;
  --bg-elev: #ffffff;
  --bg-widget: #ffffff;
  --text: #1a1a1e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --glass: rgba(255, 255, 255, 0.72);
  --dock-bg: rgba(255, 255, 255, 0.85);
}

body.dark-mode,
[data-theme="dark"] {
  --bg: #0c0c0e;
  --bg-elev: #16161a;
  --bg-widget: #1c1c20;
  --text: #f2f2f7;
  --text-secondary: #9898a0;
  --border: #2a2a2e;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --glass: rgba(22, 22, 26, 0.78);
  --dock-bg: rgba(22, 22, 26, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    system-ui, sans-serif;
  font-size: calc(16px * var(--font-scale));
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

body.has-wallpaper {
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.hidden {
  display: none !important;
}

/* ---------- Boot ---------- */
#boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity 0.4s ease, visibility 0.4s;
}
#boot-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.boot-logo img {
  height: 40px;
  filter: brightness(0) invert(1);
}

/* ---------- Status Bar ---------- */
#status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--status-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 12px;
  padding-right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}
.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
#status-app-title {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}
#status-battery.charging {
  color: #10b981;
}

/* ---------- Home / Widgets ---------- */
#home-view {
  position: absolute;
  top: calc(var(--status-h) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 20px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 20px;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.widgets-containers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.widget-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 100%;
}
.widget-container {
  background: var(--bg-widget);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  gap: 8px;
  min-height: 0;
  min-width: 0; /* critical: allow grid item shrink */
  max-width: 100%;
  overflow: hidden;
}
.widget-container.full {
  grid-column: 1 / -1;
}
.widget-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.widget-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.widget-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clock-widget {
  font-size: clamp(20px, 7vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.date-widget {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  margin-top: 2px;
  min-width: 0;
}
.widget-item > span:first-child {
  flex-shrink: 0;
  color: var(--text-secondary);
}
.widget-item .dynamic-status,
.dynamic-status {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.dynamic-status.offline {
  color: #ef4444;
}
.error-message {
  font-size: 11px;
  color: #ef4444;
  margin-top: 4px;
}

/* Speed meter – compact, no overflow */
.speed-meter-container {
  position: relative;
  width: min(64px, 100%);
  height: 36px;
  margin: 4px auto 0;
  max-width: 100%;
  overflow: hidden;
}
.speed-meter-gauge {
  position: absolute;
  inset: 0;
  border: 5px solid var(--border);
  border-bottom: none;
  border-radius: 64px 64px 0 0;
}
.speed-meter-needle {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 24px;
  margin-left: -1px;
  background: var(--accent);
  transform-origin: bottom center;
  transform: rotate(-90deg);
  transition: transform 0.4s ease;
}
.speed-display {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.2;
  overflow: hidden;
}
.speed-display span {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Battery visual */
.battery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.battery-header > div {
  min-width: 0;
  flex-shrink: 1;
}
.battery-visual {
  position: relative;
  width: 28px;
  height: 14px;
  border: 2px solid var(--text-secondary);
  border-radius: 3px;
  margin-right: 6px;
}
.battery-visual::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 3px;
  width: 3px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 0 2px 2px 0;
}
.battery-level-indicator {
  height: 100%;
  width: 70%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.3s;
}
.battery-charging-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fbbf24;
  opacity: 0;
}

/* Action buttons in widget */
.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.action-buttons button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}

/* ---------- Launcher (Desktop) ---------- */
#desktop {
  position: absolute;
  top: calc(var(--status-h) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column; 
  z-index: 50;
}
.desktop-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.searchbar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}
.searchbar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
  user-select: text;
}
.desktop-controls {
  display: flex;
  gap: 6px;
}
.control-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
}
.app-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.app-list.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px 8px;
  align-content: start;
}
.app-list.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.app:active {
  background: rgba(var(--accent-rgb), 0.12);
}
.app-list.list .app {
  flex-direction: row;
  padding: 10px 12px;
  gap: 14px;
}
.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(var(--accent-rgb), 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  overflow: hidden;
}
.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-icon i {
  font-size: 22px;
}
.app-name {
  font-size: 12px;
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-list.list .app-name {
  max-width: none;
  text-align: left;
  font-size: 15px;
}
.alphabet-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  padding: 8px 4px 4px;
  position: sticky;
  top: 0; 
  z-index: 2;
}

/* ---------- Dock — floating action bar (premium) ---------- */
.bottom-dock {
  position: fixed;
  bottom: calc(12px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  max-width: min(400px, calc(100vw - 24px));
  height: auto;
  min-height: var(--dock-h);
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  background: transparent;
  border: none;
  z-index: 900;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none; /* bar itself; children re-enable */
}
.bottom-dock > * {
  pointer-events: auto;
}
.bottom-dock.expanded {
  /* extra row stacks above main pill */
}
.dock-main-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 64px;
  padding: 8px 10px;
  flex-shrink: 0;
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: var(--dock-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
body.dark-mode .dock-main-row {
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  background: rgba(28, 28, 32, 0.88);
}
.dock-sys {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(
    145deg,
    rgba(var(--accent-rgb), 0.22) 0%,
    rgba(var(--accent-rgb), 0.1) 100%
  );
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease;
}
body.dark-mode .dock-sys {
  background: linear-gradient(
    145deg,
    rgba(var(--accent-rgb), 0.35) 0%,
    rgba(var(--accent-rgb), 0.15) 100%
  );
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.dock-sys:active {
  transform: scale(0.9);
}
.dock-expand-fab {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 22px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: var(--dock-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.dock-expand-fab.hidden { display: none; }
.dock-expand-fab[aria-expanded="true"] {
  color: var(--accent);
}
.dock-extra-row {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 56px;
  margin: 0 0 8px;
  padding: 8px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--dock-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
.dock-extra-row::-webkit-scrollbar { display: none; }
.dock-extra-row.open {
  display: flex;
}
.dock-apps {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  align-items: center;
  min-width: 0;
  max-width: min(180px, 48vw);
}
.dock-apps-extra {
  max-width: none;
  flex: none;
  gap: 6px;
  padding: 0 4px;
}
.dock-app {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: 0;
}
.dock-icon-tile {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Same as launcher .app-icon */
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  box-shadow: none;
  font-size: 20px;
  overflow: hidden;
  transition: transform 0.15s ease, background 0.15s ease;
}
body.dark-mode .dock-icon-tile {
  background: rgba(var(--accent-rgb), 0.18);
  box-shadow: none;
}
.dock-icon-tile i {
  filter: none;
}
.dock-icon-tile.has-img {
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: 0;
}
.dock-icon-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  pointer-events: none;
}
.dock-app:active .dock-icon-tile {
  transform: scale(0.92);
  background: rgba(var(--accent-rgb), 0.2);
}
.dock-app.dock-slot-empty,
button.dock-slot-empty {
  width: 52px;
  height: 52px;
  min-width: 52px;
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.dock-app.dock-slot-empty .dock-icon-tile,
button.dock-slot-empty .dock-icon-tile,
button.dock-slot-empty {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 13px;
  border: 1.5px dashed var(--border) !important;
  background: rgba(var(--accent-rgb), 0.04) !important;
  color: var(--text-secondary) !important;
  box-shadow: none !important;
  font-size: 15px !important;
}
.dock-app.dock-slot-empty:active .dock-icon-tile,
button.dock-slot-empty:active {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: rgba(var(--accent-rgb), 0.1) !important;
}
.dock-nav {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.dock-nav button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  border-radius: 11px;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dock-nav button:active {
  transform: scale(0.9);
  background: rgba(var(--accent-rgb), 0.22);
}
#dock-expand {
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}
#dock-expand[aria-expanded="true"] {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}

/* Slightly larger targets on very small phones still fit 4 icons */
@media (max-width: 360px) {
  .dock-app { width: 48px; height: 48px; min-width: 48px; }
  .dock-icon-tile { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
  .dock-sys { width: 48px; height: 48px; min-width: 48px; font-size: 16px; border-radius: 12px; }
  .dock-apps { max-width: min(150px, 46vw); gap: 4px; }
}
@media (min-width: 480px) {
  .dock-app { width: 56px; height: 56px; min-width: 56px; }
  .dock-icon-tile { width: 50px; height: 50px; border-radius: 14px; font-size: 20px; }
  .dock-sys { width: 56px; height: 56px; min-width: 56px; font-size: 20px; border-radius: 14px; }
  .dock-apps { max-width: 220px; gap: 10px; }
  .dock-main-row { padding: 0 16px; max-width: 480px; }
}

/* ---------- App Runtime ---------- */
#app-runtime {
  position: absolute;
  top: calc(var(--status-h) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 20px);
  z-index: 100;
  background: var(--bg);
}
.app-frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  min-height: 0;
  overflow: hidden;
}
.app-frame-header {
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.app-frame-header .app-title {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-frame-header button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
}
.app-frame-header .btn-close:active {
  color: #ef4444;
}
.app-frame iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  background: #fff;
  display: block;
}
body.dark-mode .app-frame iframe {
  background: #111;
}
.iframe-loader {
  position: absolute;
  inset: 44px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 5;
  color: var(--accent);
}
.iframe-loader.hidden {
  display: none;
}

/* ---------- Task Switcher ---------- */
#task-switcher {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
#task-switcher.visible {
  pointer-events: auto;
  opacity: 1;
}
#task-switcher-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.task-panel {
  position: relative;
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  padding: 16px 12px calc(20px + var(--safe-bottom));
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.task-panel h3 {
  font-size: 15px;
  margin-bottom: 12px;
  padding: 0 8px;
  color: var(--text-secondary);
}
.task-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
.task-card {
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  border: 2px solid transparent;
  position: relative;
  cursor: pointer;
}
.task-card.active {
  border-color: var(--accent);
}
.task-preview {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 6px;
}
.task-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
}
.task-list .empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}

/* ---------- Notification Center ---------- */
#notification-center {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
#notification-center.visible {
  pointer-events: auto;
  opacity: 1;
}
#notification-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.notif-panel {
  position: relative;
  margin-top: calc(var(--status-h) + var(--safe-top) + 8px);
  margin-left: 12px;
  margin-right: 12px;
  background: var(--bg-elev);
  border-radius: 18px;
  max-height: 60vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-header h3 {
  font-size: 16px;
}
#notif-clear {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#notif-list {
  overflow-y: auto;
  padding: 8px;
}
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 4px;
}
.notif-item:active {
  background: rgba(var(--accent-rgb), 0.08);
}
.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-body {
  flex: 1;
  min-width: 0;
}
.notif-title {
  font-weight: 600;
  font-size: 14px;
}
.notif-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.notif-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.notif-dismiss {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.empty-state i {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.5;
}
#notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Quick Settings ---------- */
#quick-settings {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
#quick-settings.visible {
  pointer-events: auto;
  opacity: 1;
}
#qs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.qs-panel {
  position: relative;
  margin: calc(var(--status-h) + var(--safe-top) + 8px) 12px 0;
  background: var(--bg-elev);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
}
.qs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.qs-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border-radius: 14px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.qs-tile i {
  font-size: 20px;
  color: var(--text-secondary);
}
.qs-tile.active {
  background: rgba(var(--accent-rgb), 0.15);
}
.qs-tile.active i {
  color: var(--accent);
}
.qs-slider {
  margin-top: 14px;
}
.qs-slider label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}
.qs-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* ---------- Global Search ---------- */
#global-search {
  position: relative;
  margin-bottom: 12px;
}
#global-search input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-widget);
  color: var(--text);
  font-size: 15px;
  outline: none;
  user-select: text;
}
#global-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}
#global-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg-elev);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
}
.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.search-result:active {
  background: rgba(var(--accent-rgb), 0.1);
}
.search-result i {
  color: var(--accent);
  width: 20px;
  text-align: center;
}

/* ---------- Density ---------- */
[data-density="compact"] .widget-container {
  padding: 10px;
  min-height: 70px;
}
[data-density="spacious"] .widget-container {
  padding: 18px;
  min-height: 110px;
}

/* ---------- Reduce motion ---------- */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

/* ---------- View transitions ---------- */
@supports (view-transition-name: none) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.25s;
  }
}


/* ---------- Mobile-first refinements ---------- */
@media (max-width: 400px) {
  #home-view { padding: 8px 8px 16px; }
  .widget-grid { gap: 8px; }
  .widget-container { padding: 10px; border-radius: 14px; }
  .clock-widget { font-size: 22px; }
  .widget-icon { width: 28px; height: 28px; font-size: 12px; }
  .app-list.grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 10px 4px; }
  .app-icon { width: 44px; height: 44px; border-radius: 12px; }
  .app-name { font-size: 11px; max-width: 64px; }
  #status-bar { font-size: 11px; padding-left: 10px; padding-right: 8px; }
  #status-app-title { max-width: 100px; }
  .qs-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .qs-tile { padding: 10px 2px; font-size: 10px; }
  .task-list { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
}

/* Prevent overscroll bounce on iOS when panels open */
body.task-switcher-open,
body.panel-open,
body.qs-open {
  overflow: hidden;
  touch-action: none;
}

/* Wallpaper overlay so widgets stay readable */
body.has-wallpaper #home-view .widget-container,
body.has-wallpaper #global-search input {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}


/* Dock handle (not counted in the 5 icons) */
.dock-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 16px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 4px;
}
.dock-handle.hidden { display: none; }
.dock-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--text-secondary);
  opacity: 0.45;
}
.dock-handle:active .dock-handle-bar {
  opacity: 0.9;
  background: var(--accent);
}
.dock-expand-inline {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Keep main row as 5 equal visual slots: Home | 3 pins | Launcher */
.dock-main-row {
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.dock-apps {
  display: flex;
  justify-content: space-evenly;
  flex: 1;
  max-width: none;
  gap: 0;
}

/* ---------- System Dialog ---------- */
.hippo-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.hippo-dialog.hidden {
  display: none !important;
}
.hippo-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.hippo-dialog-sheet {
  position: relative;
  width: min(340px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 22px 20px 16px;
  text-align: center;
  animation: hippoDialogIn 0.22s ease;
}
@keyframes hippoDialogIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.hippo-dialog-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.hippo-dialog-icon.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}
.hippo-dialog-icon.success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}
.hippo-dialog-icon.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}
.hippo-dialog-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 8px;
}
.hippo-dialog-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.hippo-dialog-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.hippo-dialog-input:focus {
  border-color: var(--accent);
}
.hippo-dialog-input.hidden {
  display: none !important;
}
.hippo-dialog-actions {
  display: flex;
  gap: 10px;
}
.hippo-dialog-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.hippo-dialog-btn.primary {
  background: var(--accent);
  color: #fff;
}
.hippo-dialog-btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.hippo-dialog-btn.secondary.hidden {
  display: none !important;
}
.hippo-dialog-btn:active {
  transform: scale(0.98);
}


/* Hide dock while an app is open — more screen for the app */
body.app-open .bottom-dock {
  display: none !important;
}
body.app-open #app-runtime {
  bottom: 0;
}
body.app-open #home-view,
body.app-open #desktop {
  /* not visible */
}
body.app-open #status-bar {
  /* keep status visible */
}


/* App header ⋯ menu */
.app-context-menu {
  position: fixed;
  z-index: 5000;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: hippoDialogIn 0.15s ease;
}
.app-context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.app-context-menu button i {
  width: 18px;
  color: var(--text-secondary);
  text-align: center;
}
.app-context-menu button:active {
  background: rgba(var(--accent-rgb), 0.12);
}
.app-context-menu button.danger {
  color: #ef4444;
}
.app-context-menu button.danger i {
  color: #ef4444;
}
