:root {
  --bg-canvas: #09090B;
  --bg-sidebar: #121214;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-tertiary: #71717A;
  --accent-purple: #8B5CF6;
  --accent-cyan: #06B6D4;
  --accent-green: #10B981;
  --accent-orange: #F59E0B;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg-canvas: #F4F4F5;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FAFAFA;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --text-primary: #18181B;
  --text-secondary: #52525B;
  --text-tertiary: #A1A1AA;
  --accent-purple: #6D28D9;
  --accent-cyan: #0891B2;
  --accent-green: #059669;
  --accent-orange: #D97706;
}

[data-theme="light"] .window-controls-global {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* 顶栏内嵌红绿灯（避免 fixed 与侧栏 drag 区重叠导致 Electron 吞点击） */
.desktop-shell-chrome {
  flex-shrink: 0;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  -webkit-app-region: drag;
  z-index: 100000;
  position: relative;
}

.desktop-shell-chrome .window-controls {
  -webkit-app-region: no-drag;
  pointer-events: auto;
}

.desktop-shell-chrome-drag {
  flex: 1;
  align-self: stretch;
  min-width: 48px;
  -webkit-app-region: drag;
}

.desktop-shell-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

#ds-titlebar ~ .desktop-shell-chrome,
body:has(#ds-titlebar) .desktop-shell-chrome {
  display: none !important;
}

.sidebar {
  width: 72px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 24px;
  z-index: 50;
  -webkit-app-region: no-drag;
  position: relative;
}

.sidebar-drag-zone {
  flex: 1;
  width: 100%;
  min-height: 32px;
  -webkit-app-region: drag;
}

.window-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  -webkit-app-region: no-drag;
  pointer-events: auto;
}

.window-controls-global {
  display: none;
}

.window-controls button {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  -webkit-app-region: no-drag;
  pointer-events: auto;
}

.window-controls button::before {
  content: '';
  position: absolute;
  inset: -10px;
}

.dot-r { background: #FF5F57; }
.dot-y { background: #FEBC2E; }
.dot-g { background: #28C840; }

.app-logo {
  width: 52px;
  height: 52px;
  margin-bottom: 28px;
  margin-top: 8px;
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  align-items: center;
  -webkit-app-region: no-drag;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.nav-btn i,
.nav-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-btn.ds-web-link::after {
  content: none;
}

.nav-btn.active {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
}

.nav-btn:hover:not(.active) {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  -webkit-app-region: no-drag;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  background: center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.avatar.avatar-initials,
.pp-avatar.avatar-initials {
  background-color: #8B5CF6;
  background-image: none !important;
}

.avatar-wrap {
  position: relative;
}

.profile-popover {
  position: absolute;
  left: calc(100% + 12px);
  bottom: 0;
  width: 260px;
  padding: 16px;
  border-radius: 16px;
  background: #FFFFFF;
  color: #111827;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 200;
}

[data-theme="light"] .profile-popover,
.profile-popover {
  background: #FFFFFF;
}

.profile-popover.hidden { display: none; }

.pp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pp-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: center/cover no-repeat;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.pp-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
}

.pp-edit {
  border: none;
  background: transparent;
  padding: 2px;
  cursor: pointer;
  color: #6366F1;
  display: flex;
  align-items: center;
}

.pp-edit i,
.pp-edit svg {
  width: 14px;
  height: 14px;
}

.pp-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border: none;
  border-top: 1px solid #F3F4F6;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}

.pp-row i { width: 16px; height: 16px; color: #9CA3AF; }

.pp-phone {
  padding-top: 10px;
  font-size: 13px;
  color: #6B7280;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  flex-shrink: 0;
  height: 68px;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-app-region: drag;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  -webkit-app-region: no-drag;
}

.breadcrumb i {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.breadcrumb span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  -webkit-app-region: no-drag;
}

.clock {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.container {
  flex: 1;
  min-height: 0;
  padding: 16px 48px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: minmax(180px, 240px) minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  height: 100%;
}

.bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s;
}

[data-theme="light"] .bento-card {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.bento-card:hover {
  border-color: var(--border-strong);
}

.bento-card.card-tools,
.bento-card.card-tasks {
  overflow: visible;
  padding: 22px 24px;
}

.card-tools .card-header.tight,
.card-tasks .card-header.tight {
  margin-bottom: 12px;
}

.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.card-header.tight {
  margin-bottom: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-title i {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.hero-card {
  padding: 36px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(0, 0, 0, 0) 100%), var(--bg-card);
}

[data-theme="light"] .hero-card {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(255, 255, 255, 1) 100%);
}

.hero-content {
  display: flex;
  justify-content: space-between;
  height: 100%;
  gap: 24px;
  align-items: center;
  min-height: 0;
}

.hero-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hero-left h1 {
  font-size: 34px;
  margin: 0 0 12px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.hero-left p {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.6;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-canvas);
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, filter 0.2s;
  width: fit-content;
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(0.9);
}

.next-class-box {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.3);
}

.nc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.next-class-box h2 {
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.next-class-box p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.next-class-box p:last-child {
  margin-bottom: 0;
}

.preflight-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.status-ready {
  font-size: 12px;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding: 12px 16px;
  background: var(--bg-canvas);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.device-name {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.device-name i {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.device-val {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.val-ok { color: var(--accent-green); }

.dot-ok {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

.fake-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 60px;
  margin-top: 16px;
}

.fc-bar {
  flex: 1;
  background: var(--border-strong);
  border-radius: 4px 4px 0 0;
}

.fc-bar.active {
  background: var(--accent-purple);
}

.schedule-track {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.s-item {
  display: flex;
  gap: 20px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.2s;
  align-items: center;
  flex-shrink: 0;
}

.s-item:hover {
  border-color: var(--border-strong);
}

.s-time {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  width: 50px;
  text-align: right;
  color: var(--text-primary);
  flex-shrink: 0;
}

.s-content {
  flex: 1;
  min-width: 0;
}

.s-content h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.s-content p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-sm {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-sm:hover {
  background: rgba(6, 182, 212, 0.2);
}

.badge {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  flex-shrink: 0;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 0 0 auto;
}

.tool-card {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s;
  cursor: pointer;
  align-items: flex-start;
}

.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.tool-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-card h4 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.tool-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.task-item:hover {
  border-color: var(--border-strong);
}

.t-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.t-info {
  flex: 1;
  min-width: 0;
}

.t-info h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.t-info p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.dth-empty {
  padding: 20px;
  text-align: center;
  background: var(--bg-canvas);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  color: var(--text-secondary);
}

.dth-empty a,
.dth-empty button {
  color: var(--accent-cyan);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.stat-row {
  display: flex;
  gap: 32px;
}

.stat-num {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.stat-num small {
  font-size: 16px;
  color: var(--text-tertiary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 一屏放不下：隐藏课前检测，Hero 占满首行 */
body.layout-compact .card-preflight {
  display: none;
}

body.layout-compact .hero-card {
  grid-column: span 12;
}

body.layout-compact .bento-grid {
  grid-template-rows: minmax(160px, 200px) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

body.layout-compact .hero-card {
  padding: 28px;
}

body.layout-compact .hero-left h1 {
  font-size: 28px;
}

body.layout-compact .tool-card {
  padding: 16px;
  gap: 12px;
}

body.layout-compact .tool-icon {
  width: 36px;
  height: 36px;
}

body.layout-compact .container {
  padding-bottom: 16px;
}

@media (max-height: 720px) {
  .hero-left h1 { font-size: 26px; }
  .hero-left p { margin-bottom: 16px; }
  .bento-card { padding: 20px; }
  .card-header { margin-bottom: 16px; }
}

.dth-shell-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  background: var(--bg-canvas);
}

body.shell-framed #dthViewHome {
  display: none;
}

body.shell-framed .dth-shell-frame {
  display: block;
}

