/* Kai Dial v0.9 — glassmorphism+, dark theme, widgets, adaptive sizes */

:root {
  color-scheme: light;
  --fg: #1c1c1e;
  --fg-muted: #6c6c70;
  --fg-faint: #8e8e93;
  --accent: #007aff;
  --danger: #ff3b30;
  --tile-bg: rgba(255,255,255,0.45);
  --tile-bg-hover: rgba(255,255,255,0.65);
  --tile-border: rgba(255,255,255,0.7);
  --tile-shadow: 0 8px 32px rgba(0,0,0,0.10), 0 1px 0 rgba(255,255,255,0.6) inset, 0 0 0 1px rgba(255,255,255,0.4) inset;
  --tile-shadow-hover: 0 16px 48px rgba(0,0,0,0.18), 0 1px 0 rgba(255,255,255,0.8) inset, 0 0 0 1px rgba(255,255,255,0.5) inset;
  --group-bg: rgba(255,255,255,0.55);
  --group-bg-hover: rgba(255,255,255,0.78);
  --group-active-bg: rgba(28,28,30,0.92);
  --group-active-fg: #fff;
  --search-bg: rgba(255,255,255,0.6);
  --search-bg-focus: rgba(255,255,255,0.95);
  --menu-bg: rgba(255,255,255,0.92);
  --dialog-bg: rgba(255,255,255,0.96);
  --input-bg: rgba(0,0,0,0.04);
  --hover-bg: rgba(0,0,0,0.05);
  --divider: rgba(0,0,0,0.08);
  --widget-bg: rgba(255,255,255,0.4);
  --widget-fg: #1c1c1e;
  --scrim: rgba(255,255,255,0.05);
  --tile-text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --fg: #f5f5f7;
  --fg-muted: #a1a1a6;
  --fg-faint: #6e6e73;
  --accent: #0a84ff;
  --danger: #ff453a;
  --tile-bg: rgba(40,40,42,0.45);
  --tile-bg-hover: rgba(60,60,62,0.65);
  --tile-border: rgba(255,255,255,0.12);
  --tile-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.08) inset, 0 0 0 1px rgba(255,255,255,0.06) inset;
  --tile-shadow-hover: 0 16px 48px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.12) inset, 0 0 0 1px rgba(255,255,255,0.1) inset;
  --group-bg: rgba(40,40,42,0.5);
  --group-bg-hover: rgba(60,60,62,0.75);
  --group-active-bg: rgba(245,245,247,0.92);
  --group-active-fg: #1c1c1e;
  --search-bg: rgba(40,40,42,0.5);
  --search-bg-focus: rgba(40,40,42,0.85);
  --menu-bg: rgba(28,28,30,0.95);
  --dialog-bg: rgba(28,28,30,0.97);
  --input-bg: rgba(255,255,255,0.06);
  --hover-bg: rgba(255,255,255,0.06);
  --divider: rgba(255,255,255,0.1);
  --widget-bg: rgba(40,40,42,0.4);
  --widget-fg: #f5f5f7;
  --scrim: rgba(0,0,0,0.15);
  --tile-text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  color: var(--fg);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

canvas.wallpaper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  display: block;
  pointer-events: none;
  /* Pre-paint baseline на случай если JS медленно стартует */
  background-color: #f4ecff;
  background-image:
    radial-gradient(ellipse 80% 60% at 12% 18%, rgba(149, 92, 255, 0.55) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 88% 14%, rgba(72, 184, 255, 0.50) 0%, transparent 60%),
    radial-gradient(ellipse 75% 60% at 78% 82%, rgba(255, 102, 178, 0.48) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 18% 88%, rgba(255, 184, 96, 0.42) 0%, transparent 60%),
    linear-gradient(135deg, #fff5fb 0%, #f4e4ff 40%, #e0e8ff 75%, #d4f1ff 100%);
}

:root[data-theme="dark"] canvas.wallpaper {
  background-color: #0a0e1a;
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(124, 58, 237, 0.50) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 85% 15%, rgba(30, 64, 175, 0.50) 0%, transparent 60%),
    radial-gradient(ellipse 75% 60% at 75% 80%, rgba(190, 24, 93, 0.45) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 20% 85%, rgba(14, 116, 144, 0.45) 0%, transparent 60%),
    linear-gradient(135deg, #0a0e1a 0%, #1a0a2e 40%, #0a1a2e 75%, #0a0014 100%);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--scrim);
  backdrop-filter: blur(0.5px);
  -webkit-backdrop-filter: blur(0.5px);
}

/* ───── Widgets (clock + weather) — встроены в title-bar ───── */
.title-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
}
.widgets {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.widget {
  background: var(--widget-bg);
  backdrop-filter: blur(28px) saturate(1.8);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  border: 1px solid var(--tile-border);
  border-radius: 14px;
  padding: 8px 14px;
  color: var(--widget-fg);
  box-shadow: var(--tile-shadow);
  text-align: center;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.clock { min-width: 96px; }
.clock .clock-time {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-feature-settings: 'tnum';
  line-height: 1;
}
.clock .clock-date {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 3px;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.weather {
  min-width: auto;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}
.weather .weather-icon { font-size: 22px; line-height: 1; }
.weather .weather-temp {
  font-size: 18px;
  font-weight: 600;
  font-feature-settings: 'tnum';
}
.weather .weather-city {
  font-size: 10px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

/* ───── App ───── */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 40px 120px;
  position: relative;
  z-index: 1;
}

header { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.header-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.header-spacer { flex: 1 1 16px; min-width: 16px; }
.header-actions { display: flex; gap: 10px; }
.title-bar h1, .title-bar { display: none !important; } /* legacy, удалено из HTML */

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--widget-bg);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--tile-border);
  color: var(--fg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10), 0 1px 0 rgba(255,255,255,0.4) inset;
}
.icon-btn:hover { transform: scale(1.06); background: var(--tile-bg-hover); }
.icon-btn:active { transform: scale(0.95); }

/* ───── Groups bar — single row, horizontal scroll, fade edges ───── */
.groups-wrap {
  position: relative;
}
.groups-bar {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 32px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 28px, black calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 28px, black calc(100% - 28px), transparent 100%);
}
.groups-bar::-webkit-scrollbar { display: none; }
.groups-bar > * { flex: 0 0 auto; }
.group-btn {
  padding: 10px 20px;
  border-radius: 16px;
  background: var(--group-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--tile-border);
  color: var(--fg);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 1px 0 rgba(255,255,255,0.4) inset;
  white-space: nowrap;
}
.group-btn:hover { background: var(--group-bg-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.group-btn.active {
  background: var(--group-active-bg);
  color: var(--group-active-fg);
  border-color: var(--group-active-bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.group-btn.add { color: var(--accent); font-weight: 600; }
.group-btn.dragging { opacity: 0.4; cursor: grabbing; transform: scale(0.95); }
.group-btn.drag-over { background: rgba(0, 122, 255, 0.28); border-color: var(--accent); transform: scale(1.08); box-shadow: 0 0 0 4px rgba(0,122,255,0.15); }
.group-btn.drag-tile-over {
  background: rgba(255, 184, 0, 0.32);
  border-color: #ffb800;
  transform: scale(1.10);
  box-shadow: 0 0 0 4px rgba(255,184,0,0.25), 0 8px 24px rgba(255,184,0,0.4);
  animation: pulse-glow 1.2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,184,0,0.25), 0 8px 24px rgba(255,184,0,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,184,0,0.15), 0 12px 32px rgba(255,184,0,0.55); }
}

/* ───── Search ───── */
.search-wrap {
  position: relative;
  max-width: 420px;
  flex: 0 1 420px;
  min-width: 240px;
}
.search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 14px 64px 14px 44px;
  border-radius: 16px;
  background: var(--search-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--tile-border);
  color: var(--fg);
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 0 rgba(255,255,255,0.4) inset;
}
#search::placeholder { color: var(--fg-faint); }
#search:focus { background: var(--search-bg-focus); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,122,255,0.15); }

.ai-badge {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 6px;
  background: linear-gradient(135deg, #a78bfa, #ec4899);
  color: white;
  pointer-events: none;
}

.search-engine-btn {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: linear-gradient(135deg, #4285f4, #1a73e8);
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search-engine-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.4);
}
.search-engine-btn:active { transform: translateY(-50%) scale(0.95); }
.search-engine-btn[data-engine="perplexity"] {
  background: linear-gradient(135deg, #20808d, #1a6e7a);
}
.search-engine-btn[data-engine="perplexity"]:hover {
  box-shadow: 0 2px 8px rgba(32, 128, 141, 0.4);
}

/* ───── Grid ───── */
/* Crossfade при смене группы — оптимизирован: быстрее + GPU acceleration */
.grid {
  transition: opacity 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
  contain: layout style;
}
.grid.transitioning, .grid.transitioning .tile {
  will-change: transform, opacity;
}
.grid.fading-out { opacity: 0; transform: translateY(6px); transition-duration: 0.09s; transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
.grid.fading-in  { opacity: 0; transform: translateY(6px); }
.grid.no-transition { transition: none !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(170px, 13vw, 220px), 1fr));
  gap: clamp(16px, 1.6vw, 28px);
}
.grid.size-medium { grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 11vw, 180px), 1fr)); gap: clamp(14px, 1.3vw, 22px); }
.grid.size-small  { grid-template-columns: repeat(auto-fill, minmax(clamp(118px, 9vw, 150px), 1fr));  gap: clamp(12px, 1vw, 18px); }

.empty-hint {
  text-align: center;
  color: var(--fg-faint);
  margin-top: 60px;
  font-size: 16px;
}

/* ───── Tile ───── */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 20px;
  aspect-ratio: 1.05;
  background: var(--tile-bg);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--tile-border);
  border-radius: 24px;
  text-decoration: none;
  color: var(--fg);
  cursor: pointer;
  /* Только transform — GPU-only, без paint */
  transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  transform: translateZ(0); /* форсим GPU layer */
  overflow: hidden;
  box-shadow: var(--tile-shadow);
  user-select: none;
  contain: layout style;
  isolation: isolate;
}
/* hover overlay через ::before — отдельный compositor layer, НЕ trigger paint */
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,255,255,0.10);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  z-index: 0;
}
:root[data-theme="dark"] .tile::before { background: rgba(255,255,255,0.05); }
.tile > * { position: relative; z-index: 1; }
.grid.size-medium .tile { padding: 22px 16px; gap: 10px; border-radius: 20px; }
.grid.size-small .tile  { padding: 18px 12px; gap: 8px; border-radius: 18px; }

@media (hover: hover) {
  .tile { will-change: transform; }
}
.tile:hover {
  transform: translateZ(0) translateY(-4px) scale(1.025);
}
.tile:hover::before { opacity: 1; }
.tile:active { transform: translateZ(0) translateY(-1px) scale(0.99); transition-duration: 0.08s; }

.tile.dragging {
  opacity: 0.35;
  transform: scale(0.94) rotate(-2deg);
  cursor: grabbing;
  box-shadow: var(--tile-shadow);
}
.tile.drag-target {
  transform: scale(1.06);
  background: rgba(0, 122, 255, 0.22);
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(0,122,255,0.4),
    0 16px 40px rgba(0,122,255,0.35),
    0 1px 0 rgba(255,255,255,0.6) inset;
}
.tile.drag-target::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(0,122,255,0.18), transparent 70%);
  pointer-events: none;
}

.tile.pinned::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,200,0,0.08), transparent 50%);
}

.pin-icon {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 14px;
  opacity: 0.7;
  z-index: 2;
}

.tile img.favi {
  width: clamp(64px, 6.4vw, 100px);
  height: clamp(64px, 6.4vw, 100px);
  border-radius: 22%;
  object-fit: contain;
  background: transparent;
  padding: 0;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.18)) drop-shadow(0 2px 4px rgba(0,0,0,0.12));
}
.grid.size-medium .tile img.favi { width: clamp(52px, 5vw, 80px); height: clamp(52px, 5vw, 80px); }
.grid.size-small .tile img.favi  { width: clamp(40px, 3.8vw, 60px); height: clamp(40px, 3.8vw, 60px); }

.tile .favi-fallback {
  width: clamp(64px, 6.4vw, 100px);
  height: clamp(64px, 6.4vw, 100px);
  border-radius: 22%;
  background: linear-gradient(135deg, #007aff, #5ac8fa);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: clamp(28px, 2.8vw, 44px);
  filter: drop-shadow(0 6px 16px rgba(0,122,255,0.35));
}
.grid.size-medium .tile .favi-fallback { width: clamp(52px, 5vw, 80px); height: clamp(52px, 5vw, 80px); font-size: clamp(22px, 2.2vw, 34px); }
.grid.size-small .tile .favi-fallback  { width: clamp(40px, 3.8vw, 60px); height: clamp(40px, 3.8vw, 60px); font-size: clamp(18px, 1.8vw, 26px); }

.tile .title {
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  color: var(--fg);
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-shadow: var(--tile-text-shadow);
}
.grid.size-medium .tile .title { font-size: 14px; }
.grid.size-small .tile .title  { font-size: 12px; }

.tile-screenshot { padding: 0; aspect-ratio: 1.3; }
.tile-screenshot .screenshot-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.tile-screenshot .title {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  padding: 7px 12px;
  background: var(--menu-bg);
  backdrop-filter: blur(12px) saturate(1.8);
  -webkit-backdrop-filter: blur(12px) saturate(1.8);
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
  -webkit-line-clamp: 1;
  text-shadow: none;
}

.tile .screenshot-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--tile-bg), var(--tile-bg-hover));
  color: var(--fg-faint);
  font-size: 13px;
}

/* ───── Add button (FAB) ───── */
.add-btn {
  position: fixed;
  bottom: 40px; right: 40px;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0,122,255,0.5), 0 2px 8px rgba(0,122,255,0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.add-btn:hover { transform: scale(1.08); box-shadow: 0 16px 40px rgba(0,122,255,0.55); }
.add-btn:active { transform: scale(0.95); }

/* ───── Context menu ───── */
.context-menu {
  position: fixed;
  min-width: 220px;
  background: var(--menu-bg);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.12);
  z-index: 1000;
  display: none;
  animation: menuIn 0.15s ease;
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.context-menu.visible { display: block; }
.context-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  border-radius: 8px;
  transition: background 0.1s;
}
.context-menu button:hover { background: rgba(0,122,255,0.12); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: rgba(255,59,48,0.12); }
.context-menu .sep { height: 1px; background: var(--divider); margin: 4px 0; }

/* ───── Dialogs ───── */
dialog {
  background: var(--dialog-bg);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  color: var(--fg);
  border: 1px solid var(--tile-border);
  border-radius: 22px;
  padding: 28px;
  min-width: 460px;
  max-width: 560px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog::backdrop { background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h3 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
dialog h4 { font-size: 13px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 8px 0 4px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--fg-muted); font-weight: 500; }
dialog label.checkbox-row { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; }
dialog label.checkbox-row input { width: 18px; height: 18px; cursor: pointer; }
dialog label.checkbox-row span { font-size: 14px; color: var(--fg); }
dialog input[type="text"], dialog input[type="url"], dialog select {
  padding: 11px 14px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
}
dialog input:focus, dialog select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px rgba(0,122,255,0.15); }
dialog select option {
  background: var(--dialog-bg);
  color: var(--fg);
}

/* Скрываем заголовок Kai Dial — пользователю не нужен */
.title-bar h1 { display: none; }
.title-bar { justify-content: flex-end; }

/* Music bar — нижняя полоса как у YouTube Music */
.music-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: rgba(15, 15, 17, 0.92);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  z-index: 8;
  color: #f0f0f0;
}
.m-btn {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.m-btn:hover { background: rgba(255,255,255,0.08); }
.m-btn:active { transform: scale(0.92); }
.m-play {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.12);
}
.m-play:hover { background: rgba(255,255,255,0.18); }
.m-time {
  font-size: 13px;
  color: #aaa;
  font-feature-settings: 'tnum';
  min-width: 90px;
  white-space: nowrap;
}
.m-track {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding-left: 12px;
}
.m-cover {
  width: 48px; height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #2a2a2c;
  flex-shrink: 0;
}
.m-meta {
  min-width: 0;
  flex: 1;
}
.m-title {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-author {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
/* iframe скрыт за экран — играет звук, мы рисуем UI сверху */
.m-iframe {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: none;
}

/* Сдвигаем app чтобы тайлы не уезжали под music-bar */
body:has(.music-bar:not([hidden])) #app { padding-bottom: 96px; }

/* Список выбора (поиск города, таймзоны, прогноз) */
.search-results, .picker-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 4px;
  background: var(--input-bg);
  border-radius: 10px;
}
.search-results .item, .picker-list .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  color: var(--fg);
}
.search-results .item:hover, .picker-list .item:hover { background: rgba(0,122,255,0.12); }
.search-results .item.active, .picker-list .item.active { background: var(--accent); color: white; }
.search-results .item .meta, .picker-list .item .meta { color: var(--fg-muted); font-size: 12px; }
.search-results .item.active .meta, .picker-list .item.active .meta { color: rgba(255,255,255,0.85); }

/* Прогноз погоды */
.forecast-list { display: flex; flex-direction: column; gap: 4px; }
.forecast-day {
  display: grid;
  grid-template-columns: 110px 36px 1fr 56px 56px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--input-bg);
  border-radius: 10px;
}
.forecast-day .date { font-size: 13px; color: var(--fg); font-weight: 500; }
.forecast-day .icon { font-size: 22px; text-align: center; }
.forecast-day .desc { font-size: 12px; color: var(--fg-muted); }
.forecast-day .hi { font-size: 14px; font-weight: 600; text-align: right; color: var(--fg); }
.forecast-day .lo { font-size: 14px; text-align: right; color: var(--fg-muted); }
dialog .hint { font-size: 12px; color: var(--fg-faint); line-height: 1.5; }
dialog .hint code { background: var(--input-bg); padding: 2px 6px; border-radius: 4px; font-size: 11px; font-family: ui-monospace, 'SF Mono', monospace; }

.settings-section { padding: 12px 0; border-top: 1px solid var(--divider); margin-top: 4px; }

.music-shortcuts { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.music-shortcut {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--divider);
  background: var(--input-bg);
  color: var(--fg);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.music-shortcut:hover { background: var(--tile-border); }

.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.actions button {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--divider);
  background: var(--input-bg);
  color: var(--fg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.actions button:hover { background: var(--hover-bg); }
.actions button[type="submit"], .actions #s-save {
  background: var(--accent);
  color: #fff;
  border: none;
}
.actions button[type="submit"]:hover, .actions #s-save:hover { filter: brightness(1.08); }

/* Mobile / small screens */
@media (max-width: 720px) {
  #app { padding: 24px 16px 100px; }
  .title-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .widgets { gap: 6px; }
  .widget { padding: 6px 10px; }
  .clock .clock-time { font-size: 18px; }
  .clock .clock-date { font-size: 10px; max-width: 100px; }
  dialog { min-width: auto; width: calc(100vw - 32px); }
}
