/* Desktop Shell — active only when html[data-layout-mode="desktop"] */

html[data-layout-mode="desktop"] body {
  overflow-x: hidden;
}

html[data-layout-mode="desktop"] .bottom-nav,
html[data-layout-mode="desktop"] .bottom-nav-spacer,
html[data-layout-mode="desktop"] .top-bar,
html[data-layout-mode="desktop"] .mobile-desktop-toggle {
  display: none !important;
}

html[data-layout-mode="desktop"] .layout-container {
  display: contents;
}

html[data-layout-mode="desktop"] .layout-main {
  display: block;
  max-width: none;
  padding: 0;
}

/* Override mobile #app constraint — the desktop-shell grid handles layout */
html[data-layout-mode="desktop"] #app {
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Multi-column grids for content lists inside desktop-main */
html[data-layout-mode="desktop"] .desktop-main .content-list,
html[data-layout-mode="desktop"] .desktop-main .history-grid,
html[data-layout-mode="desktop"] .desktop-main .stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* Dashboard 2-column: main content + side rail */
html[data-layout-mode="desktop"] .desktop-main .dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1280px) {
  html[data-layout-mode="desktop"] .desktop-main .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Forms inside desktop stay readable (don't stretch full width) */
html[data-layout-mode="desktop"] .desktop-main .form-card,
html[data-layout-mode="desktop"] .desktop-main .auth-card {
  max-width: 720px;
}

/* Cards inside desktop-main look like panels */
html[data-layout-mode="desktop"] .desktop-main .glass-card {
  border-radius: 14px;
}

/* Profile apps grid — horizontal on desktop */
html[data-layout-mode="desktop"] .profile-apps-grid {
  flex-direction: row !important;
}

/* Rhythm options — horizontal on desktop */
html[data-layout-mode="desktop"] .rhythm-options-wrap {
  flex-direction: row !important;
}
html[data-layout-mode="desktop"] .rhythm-options-wrap .rhythm-radio-label {
  flex: 1;
  min-width: 0;
}

.desktop-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: transparent;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.desktop-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: rgba(12, 12, 24, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.desktop-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 10px;
  text-decoration: none;
  color: #fff;
}

.desktop-sidebar-logo-mark {
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.5px;
}

.desktop-sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.desktop-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
.desktop-sidebar-nav::-webkit-scrollbar { display: none; }

.desktop-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.desktop-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.desktop-sidebar-item.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.12));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.35);
}

.desktop-sidebar-item svg {
  flex-shrink: 0;
}

.desktop-sidebar-item.sidebar-admin-item {
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(244, 63, 94, 0.8);
}
.desktop-sidebar-item.sidebar-admin-item:hover {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.08);
}
.desktop-sidebar-item.sidebar-admin-item.active {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.15), rgba(225, 29, 72, 0.1));
  color: #f43f5e;
  box-shadow: inset 0 0 0 1px rgba(244, 63, 94, 0.3);
}

.desktop-sidebar-footer {
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.desktop-sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.desktop-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Main wrap */
.desktop-main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.desktop-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 32px;
  background: rgba(12, 12, 24, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.desktop-topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.desktop-topbar-search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.5);
}

.desktop-topbar-search:focus-within {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.desktop-topbar-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font-size: 14px;
}

.desktop-topbar-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.desktop-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.desktop-topbar-credits {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fde68a;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.desktop-topbar-credits.low { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); }
.desktop-topbar-credits.zero { color: #f87171; border-color: rgba(248, 113, 113, 0.35); }

.desktop-topbar-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  color: #fff;
  text-decoration: none;
}

/* Main content */
.desktop-main {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ============ Dashboard desktop layout ============ */
html[data-layout-mode="desktop"] .desktop-main .dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1180px) {
  html[data-layout-mode="desktop"] .desktop-main .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-label {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.45);
  font-weight: 600;
  margin-bottom: 8px;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html[data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-trend {
  font-size: 0.6875rem;
  margin-top: 6px;
  color: rgba(240, 240, 255, 0.5);
  font-weight: 600;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell {
  padding: 12px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  transition: all 0.18s;
  cursor: pointer;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell:hover {
  border-color: rgba(124, 92, 255, 0.35);
  background: rgba(124, 92, 255, 0.06);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell.today {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.1);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-name {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.4);
  font-weight: 700;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-num {
  font-size: 1.25rem;
  font-weight: 800;
  color: #f0f0ff;
  margin: 6px 0 4px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-count {
  font-size: 0.6875rem;
  color: rgba(240, 240, 255, 0.5);
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-side-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
html[data-layout-mode="desktop"] .desktop-main .dashboard-side-rail .glass-card {
  padding: 18px;
}
html[data-layout-mode="desktop"] .desktop-main .side-card-title {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(240, 240, 255, 0.45);
  font-weight: 700;
  margin: 0 0 12px;
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #f0f0ff;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s;
  margin-bottom: 8px;
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn:hover {
  border-color: rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.08);
  transform: translateX(2px);
}
html[data-layout-mode="desktop"] .desktop-main .quick-action-btn:last-child { margin-bottom: 0; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: opacity 0.15s;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item:last-child { border-bottom: none; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-item:hover { opacity: 0.82; }
html[data-layout-mode="desktop"] .desktop-main .activity-feed-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-text {
  flex: 1; min-width: 0;
  font-size: 0.8125rem; color: #f0f0ff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html[data-layout-mode="desktop"] .desktop-main .activity-feed-meta {
  font-size: 0.6875rem; color: rgba(240, 240, 255, 0.4); flex-shrink: 0;
}

/* Responsive fallback for narrower desktops */
@media (max-width: 1180px) {
  .desktop-shell {
    grid-template-columns: 72px 1fr;
  }
  .desktop-sidebar-logo-text,
  .desktop-sidebar-item span,
  .desktop-sidebar-toggle span {
    display: none;
  }
  .desktop-sidebar-item {
    justify-content: center;
  }
}

/* Module accordion */
.sidebar-module { margin: 1px 0; border-radius: 10px; }
.sidebar-module-header {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer; border-radius: 10px;
  transition: background .15s;
}
.sidebar-module-header:hover { background: rgba(255,255,255,0.05); }
.sidebar-module.expanded .sidebar-module-header { background: rgba(255,255,255,0.03); }
.sidebar-module-icon { font-size: 16px; }
.sidebar-module-label { flex: 1; font-size: 13px; font-weight: 600; }
.sidebar-chevron { font-size: 16px; opacity: .4; transition: transform .2s; }
.sidebar-module.expanded .sidebar-chevron { transform: rotate(180deg); }
.sidebar-module-items { padding-left: 8px; overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.sidebar-module.expanded .sidebar-module-items { max-height: 2000px; }
.sidebar-section-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(240,240,255,0.25);
  padding: 6px 14px 2px;
}
.sidebar-sub-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px; border-radius: 8px;
  border-left: 2px solid transparent; cursor: pointer;
  color: rgba(255,255,255,.5); font-size: 12.5px;
  transition: all .15s; text-decoration: none;
}
.sidebar-sub-item:hover { background: rgba(255,255,255,0.04); color: rgba(255,255,255,.8); }
.sidebar-sub-item.active { border-left-color: var(--mod-color); color: var(--mod-color); background: rgba(255,255,255,0.04); }
.sidebar-module.locked .sidebar-module-header { cursor: pointer; }
.sidebar-module.locked .sidebar-module-label { opacity: .7; }
.sidebar-sub-item.locked-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px; border-radius: 8px;
  color: rgba(255,255,255,.28); font-size: 12.5px;
  cursor: pointer; transition: all .15s;
  border-left: 2px solid transparent;
}
.sidebar-sub-item.locked-item:hover {
  background: rgba(255,255,255,0.03); color: rgba(255,255,255,.4);
}
/* Collapsible subgroups (Funnels nav) */
.sidebar-group { margin: 1px 0; }
.sidebar-group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; cursor: pointer; border-radius: 7px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: rgba(255,255,255,0.35);
  transition: background .15s, color .15s;
}
.sidebar-group-header:hover { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.55); }
.sidebar-group.has-active > .sidebar-group-header { color: var(--mod-color, rgba(255,255,255,0.5)); }
.sidebar-group-label { flex: 1; }
.sidebar-group-chevron { transition: transform .2s; }
.sidebar-group.open > .sidebar-group-header .sidebar-group-chevron { transform: rotate(180deg); }
.sidebar-group-items { overflow: hidden; max-height: 0; transition: max-height .2s ease; padding-left: 4px; }
.sidebar-group.open > .sidebar-group-items { max-height: 500px; }
.sidebar-group.locked .sidebar-group-header { opacity: 0.45; }
[data-theme="light"] .sidebar-group-header { color: rgba(26,26,46,0.4); }
[data-theme="light"] .sidebar-group-header:hover { background: rgba(0,0,0,0.04); color: rgba(26,26,46,0.6); }
[data-theme="light"] .sidebar-group.has-active > .sidebar-group-header { color: var(--mod-color, rgba(26,26,46,0.6)); }

.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.06); padding-top: 4px; }

/* ═══ DESKTOP LIGHT MODE ═══ */
[data-theme="light"] .desktop-sidebar {
  background: rgba(255, 255, 255, 0.85);
  border-right-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .desktop-sidebar-logo { color: #1a1a2e; }
[data-theme="light"] .desktop-sidebar-logo-text { color: rgba(26, 26, 46, 0.7); }

[data-theme="light"] .desktop-sidebar-item {
  color: rgba(26, 26, 46, 0.6);
}

[data-theme="light"] .desktop-sidebar-item:hover {
  background: rgba(99, 102, 241, 0.06);
  color: rgba(26, 26, 46, 0.85);
}

[data-theme="light"] .desktop-sidebar-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .desktop-sidebar-item.sidebar-admin-item {
  border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .desktop-sidebar-footer { border-top-color: rgba(0, 0, 0, 0.06); }

[data-theme="light"] .desktop-sidebar-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(26, 26, 46, 0.6);
}

[data-theme="light"] .desktop-sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a2e;
}

[data-theme="light"] .desktop-topbar {
  background: rgba(255, 255, 255, 0.85);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .desktop-topbar-title { color: #1a1a2e; }

[data-theme="light"] .desktop-topbar-search {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(26, 26, 46, 0.5);
}

[data-theme="light"] .desktop-topbar-search input { color: #1a1a2e; }
[data-theme="light"] .desktop-topbar-search input::placeholder { color: rgba(26, 26, 46, 0.5); }

[data-theme="light"] .desktop-topbar-credits {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: #92400e;
}

/* Dashboard KPIs */
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-label,
[data-theme="light"] .kpi-label { color: rgba(26, 26, 46, 0.5) !important; }

html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .kpi-card .kpi-trend,
[data-theme="light"] .kpi-trend { color: rgba(26, 26, 46, 0.5) !important; }

/* Week mini calendar */
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-cell {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-name { color: rgba(26, 26, 46, 0.55) !important; }
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-num { color: #1a1a2e !important; }
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .dashboard-week-mini .day-count { color: rgba(26, 26, 46, 0.5) !important; }

/* Side rail */
[data-theme="light"] .side-card-title { color: rgba(26, 26, 46, 0.5) !important; }

html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .quick-action-btn {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.02);
  color: #1a1a2e;
}

html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .quick-action-btn:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
}

/* Activity feed */
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .activity-feed-item {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .activity-feed-text { color: #1a1a2e !important; }
html[data-theme="light"][data-layout-mode="desktop"] .desktop-main .activity-feed-meta { color: rgba(26, 26, 46, 0.55) !important; }

/* Sidebar modules */
[data-theme="light"] .sidebar-module-header:hover { background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .sidebar-module.expanded .sidebar-module-header { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] .sidebar-section-label { color: rgba(26, 26, 46, 0.45); }
[data-theme="light"] .sidebar-sub-item { color: rgba(26, 26, 46, 0.5); }
[data-theme="light"] .sidebar-sub-item:hover { background: rgba(0, 0, 0, 0.04); color: rgba(26, 26, 46, 0.8); }
[data-theme="light"] .sidebar-sub-item.active { color: var(--mod-color); background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .sidebar-sub-item.locked-item { color: rgba(26, 26, 46, 0.35); }
[data-theme="light"] .sidebar-sub-item.locked-item:hover { background: rgba(0, 0, 0, 0.03); color: rgba(26, 26, 46, 0.4); }
[data-theme="light"] .sidebar-bottom { border-top-color: rgba(0, 0, 0, 0.06); }
