  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #dde1e6;
    --border-strong: #c7cdd6;
    --text: #1a1d21;
    --text-secondary: #5b6270;
    --text-muted: #9aa1ac;
    --accent: #2f6fed;
    --accent-bg: #e8f0fe;
    --accent-text: #1d4ed8;
    --success-bg: #e6f6ea;
    --success-text: #1f7a34;
    --warning-bg: #fdf3e0;
    --warning-text: #a86a06;
    --danger-bg: #fbe9e9;
    --danger-text: #b42318;
    --purple-bg: #eeecfb;
    --purple-text: #4a3fb8;
    --teal-bg: #e2f5f0;
    --teal-text: #0f7a5c;
    --coral-bg: #fdece3;
    --coral-text: #b8481f;
    --radius: 8px;
  }
  body.dark {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #2a2f38;
    --border-strong: #3a4048;
    --text: #e8eaed;
    --text-secondary: #9aa1ac;
    --text-muted: #6b7280;
    --accent: #5b8def;
    --accent-bg: #16233d;
    --accent-text: #8ab2ff;
    --success-bg: #123321;
    --success-text: #4ade80;
    --warning-bg: #3a2c0d;
    --warning-text: #f5c451;
    --danger-bg: #3a1414;
    --danger-text: #f87171;
    --purple-bg: #241f3d;
    --purple-text: #b3a8f5;
    --teal-bg: #103129;
    --teal-text: #55d9ac;
    --coral-bg: #3d2416;
    --coral-text: #f4977a;
  }
  html { height: 100%; }
  body { transition: background 0.15s ease, color 0.15s ease; height: 100%; overflow: hidden; }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
  }
  #stage { height: 100%; }
  h1, h2, h3 { font-weight: 600; margin: 0; }
  button {
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    padding: 8px 14px;
  }
  button:hover { background: var(--surface-2); }
  button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
  button.primary:hover { background: #2559c9; }
  button.ghost { border-color: transparent; background: transparent; }
  button.ghost:hover { background: var(--surface-2); }
  button.icon-btn { border: none; background: transparent; padding: 7px; display: inline-flex; align-items: center; justify-content: center; }
  button.icon-btn:hover { background: var(--surface-2); }
  button.icon-btn .icon { width: 18px; height: 18px; }
  input, select, textarea {
    font-family: inherit;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    width: 100%;
  }
  textarea { resize: vertical; }
  label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 6px; }
  .field { margin-bottom: 16px; }
  .top-bar { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; max-width: 1100px; margin: 0 auto; }
  .toggle { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius); }
  .toggle button { border: none; background: transparent; padding: 6px 14px; }
  .toggle button.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
  .badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 500; }
  .cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 180px)); gap: 12px; }
  .cards-grid.empty-drop { border: 1.5px dashed var(--border-strong); border-radius: 12px; min-height: 60px; grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px; }
  .card-tile { cursor: grab; }
  .card-tile {
    aspect-ratio: 1 / 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px; display: flex; flex-direction: column; justify-content: space-between; min-width: 0;
  }
  .card-tile.dragging { opacity: 0.35; }
  .card-tile.drag-over { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
  .cards-grid.drag-over-zone { background: var(--accent-bg); border-radius: 12px; }
  .card-tile-title {
    font-weight: 600; font-size: 13.5px; line-height: 1.3; margin: 8px 0 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .card-tile-channel { font-size: 11.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card-tile-actions { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
  .card-tile-actions .icon-btn { padding: 5px; }
  .card-row {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px;
  }
  .step-bar { display: flex; gap: 6px; margin-bottom: 24px; }
  .step-bar button { flex: 1; font-size: 12px; padding: 10px 6px; text-align: center; }
  .step-bar button.active { background: var(--surface-2); border-color: var(--border-strong); font-weight: 600; }
  .source-option {
    flex: 1 1 140px; padding: 14px; border-radius: var(--radius); border: 1.5px solid var(--border-strong);
    background: var(--surface); text-align: left; display: flex; flex-direction: column; gap: 4px;
  }
  .source-option.selected { border-color: var(--accent); background: var(--accent-bg); }
  .source-option .opt-title { font-weight: 600; font-size: 14px; }
  .source-option .opt-sub { font-size: 12px; color: var(--text-secondary); }
  .source-option.selected .opt-sub { color: var(--accent-text); }
  .topic-card {
    padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--border-strong);
    background: var(--surface); cursor: pointer; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
  }
  .topic-card.selected { border-color: var(--accent); background: var(--accent-bg); }
  .day-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
  .day-chip {
    width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  }
  .day-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .info-box { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; }
  .info-box code { background: var(--surface); border: 0.5px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 11.5px; color: var(--text); }
  .status-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
  .summary-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
  .summary-block .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 3px; }
  .summary-block .v { font-size: 14px; }
  .nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; justify-content: flex-start; border: none; background: transparent; color: var(--text-secondary); padding: 9px 10px; font-size: 13px; }
  .nav-btn.active { background: var(--surface); color: var(--text); font-weight: 600; }
  .icon { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
  .mobile-frame { width: 100%; max-width: 360px; margin: 0 auto; border: 1px solid var(--border-strong); border-radius: 24px; overflow: hidden; background: var(--surface); min-height: 640px; display: flex; flex-direction: column; }
  .mobile-tabbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
  .mobile-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: none; background: var(--surface-2); border-radius: 10px; padding: 8px 4px; font-size: 10.5px; color: var(--text-secondary); aspect-ratio: 1 / 1;
  }
  .mobile-tab.active { background: var(--accent-bg); color: var(--accent-text); }
  .desktop-shell { display: grid; grid-template-columns: 200px 1fr; height: 100%; overflow: hidden; background: var(--surface); transition: grid-template-columns 0.18s ease; }
  .desktop-shell.collapsed { grid-template-columns: 56px 1fr; }
  .desktop-sidebar { background: var(--surface-2); border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
  .sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .sidebar-footer { padding-top: 8px; border-top: 1px solid var(--border); display: flex; justify-content: center; }
  .desktop-sidebar.collapsed .nav-label, .desktop-sidebar.collapsed .sidebar-title { display: none; }
  .desktop-sidebar.collapsed .nav-btn { justify-content: center; padding: 9px 0; }
  .desktop-sidebar.collapsed .sidebar-head { justify-content: center; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 16px; }
  .sidebar-title { font-weight: 700; font-size: 14px; }
  @media (max-width: 640px) {
    .desktop-shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .desktop-sidebar { display: none; }
    .desktop-main { padding: 16px 12px; height: 100%; overflow-y: auto; }
    .mobile-tabbar { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); background: var(--surface); }
  }
  .desktop-main { padding: 22px 26px; height: 100%; overflow-y: auto; }
  .success-box { text-align: center; padding: 40px 20px; }
  .success-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--success-bg); color: var(--success-text); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 22px; }
  .auth-screen { max-width: 360px; margin: 80px auto 0; padding: 32px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; gap: 10px; }
  .auth-screen h2 { text-align: center; font-size: 22px; margin-bottom: 4px; }
  .auth-divider { text-align: center; color: var(--text-muted); font-size: 12px; margin: 4px 0; }
  #tg-widget { display: flex; justify-content: center; margin-top: 4px; }
  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: var(--radius); font-size: 13px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.15); white-space: nowrap; }
  .muted { color: var(--text-muted); font-size: 12px; }
  .top-bar { justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .mobile-tabbar { display: none; }
  .mobile-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 10px 4px 8px; font-size: 10px; color: var(--text-secondary); border: none; background: transparent; border-radius: 0; cursor: pointer; width: 100%; }
  .mobile-tab:hover { background: var(--surface-2); }
  .mobile-tab.active { color: var(--accent); background: var(--accent-bg); }
  .mobile-tab .icon { width: 20px; height: 20px; }
  .auth-wrap { height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg); }
  input:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }
