
    /* ---------------- Core palette & derived tokens ---------------- */
    :root{
      /* neutral surfaces & text */
      --bg: #f7faf7;
      --card: #ffffff;
      --text: #0b1b12;
      --muted: #5f6b64;
      --line: #e3eae4;

      /* brand hue: default = green */
      --brand-h: 140; /* green */
      /* brand ramps (light) */
      --brand: hsl(var(--brand-h) 75% 32%);
      --brand-2: hsl(var(--brand-h) 70% 44%);
      --brand-3: hsl(var(--brand-h) 80% 54%);
      --brand-4: hsl(var(--brand-h) 90% 62%);
      /* brand tints / alpha */
      --tint-weak: hsl(var(--brand-h) 80% 95%);
      --tint-weak-2: hsl(var(--brand-h) 80% 90%);
      --tint-strong-1: hsl(var(--brand-h) 70% 86%);
      --tint-strong-2: hsl(var(--brand-h) 70% 78%);
      --tint-hover-alpha: 0.10;

      --danger: #d12f2f;
      --focus: hsl(var(--brand-h) 75% 28%);

      /* secondary surfaces */
      --surface-2: #f1f6f3;
      --surface-3: #eaf3ee;
    }

  /* Theme-specific surface overrides (light mode) */
  html[data-theme="light"][data-color="red"]{
    --bg: #fff5f5;
    --card: #fffafa;
    --text: #2d0f0f;
    --muted: #7a4b4b;
    --line: #f7d1d1;
    --surface-2: #fdeeee;
    --surface-3: #fadddd;
  }
  html[data-theme="light"][data-color="blue"]{
    --bg: #f4f8ff;
    --card: #ffffff;
    --text: #0f1b2d;
    --muted: #5a6a85;
    --line: #d6e2ff;
    --surface-2: #ecf2ff;
    --surface-3: #dde9ff;
  }
  html[data-theme="light"][data-color="yellow"]{
    --bg: #fffbea;
    --card: #fffdf5;
    --text: #2c2100;
    --muted: #7a6c3b;
    --line: #f3e6b6;
    --surface-2: #fff6d1;
    --surface-3: #ffefb0;
  }
  html[data-theme="light"][data-color="christmas"]{
    --bg: #fdfefc;
    --card: #ffffff;
    --text: #1d2b1f;
    --muted: #52655a;
    --line: #dfeee2;
    --surface-2: #f6fbf4;
    --surface-3: #eef7f0;
  }
  html[data-theme="light"][data-color="rainbow"]{
    --bg: #fdf6ff;
    --card: #ffffff;
    --text: #1c0f2d;
    --muted: #6a5a85;
    --line: #ead9ff;
    --surface-2: #f6ecff;
    --surface-3: #efddff;
  }
  html[data-theme="light"][data-color="custom"]{
    --bg: hsl(var(--brand-h) 55% 95%);
    --card: hsl(var(--brand-h) 40% 99%);
    --text: hsl(var(--brand-h) 40% 18%);
    --muted: hsl(var(--brand-h) 20% 40%);
    --line: hsl(var(--brand-h) 30% 80%);
    --surface-2: hsl(var(--brand-h) 45% 92%);
    --surface-3: hsl(var(--brand-h) 40% 89%);
  }


    /* Theme color families (light) */
    html[data-color="green"]{ --brand-h:140; }
    html[data-color="red"]  { --brand-h:0; }
    html[data-color="blue"] { --brand-h:210; }
    html[data-color="yellow"]{ --brand-h:45; }
    html[data-color="christmas"]{ --brand-h:135; }
    html[data-color="rainbow"]{ 
      --brand-h:140; /* fallback */
    }
    
    /* Rainbow theme overrides - apply vibrant gradients to all UI elements */
    html[data-color="rainbow"] button, 
    html[data-color="rainbow"] .btn {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: none !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .chip[aria-pressed="true"] {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: none !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .pill {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: 2px solid !important;
      border-image: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) 1 !important;
      animation: rainbow-border 2s linear infinite, rainbow-bg 3s ease-in-out infinite !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .status--current {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: none !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .status--next {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: 2px solid !important;
      border-image: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) 1 !important;
      animation: rainbow-border 2s linear infinite, rainbow-bg 3s ease-in-out infinite !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .progress {
      background: linear-gradient(90deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
    }
    
    html[data-color="rainbow"] .add-block-btn {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) !important;
      background-size: 400% 400% !important;
      animation: rainbow-bg 3s ease-in-out infinite !important;
      border: none !important;
      color: white !important;
    }
    
    html[data-color="rainbow"] .clock {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-text 3s ease-in-out infinite;
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    
    html[data-color="rainbow"] .countdown {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-text 3s ease-in-out infinite;
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    html[data-color="rainbow"] body{
      background: linear-gradient(135deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-bg 10s ease-in-out infinite;
      color: var(--text);
    }
    html[data-color="christmas"] body{
      background:
        radial-gradient(circle at 10% -10%, rgba(255,255,255,0.25), transparent 55%),
        radial-gradient(circle at 90% 0%, rgba(255,248,214,0.35), transparent 50%),
        linear-gradient(180deg, rgba(15,78,46,0.35), rgba(8,48,28,0.65)),
        var(--bg);
      color: var(--text);
      position: relative;
    }
    @keyframes christmasTwinkle {
      0%, 100% { opacity: 0.85; filter: drop-shadow(0 0 6px rgba(255,255,255,0.6)); }
      50% { opacity: 0.45; filter: drop-shadow(0 0 1px rgba(255,255,255,0.3)); }
    }
    html[data-color="christmas"] body::before,
    html[data-color="christmas"] body::after{
      content:"";
      position:fixed;
      left:0;
      width:100%;
      pointer-events:none;
      z-index:0;
      background-repeat:repeat-x;
      background-size:200px 80px,200px 80px,200px 80px,200px 80px,200px 80px;
      animation: christmasTwinkle 8s ease-in-out infinite;
      mix-blend-mode:screen;
    }
    html[data-color="christmas"] body::before{
      top:0;
      height:90px;
      background-image:
        radial-gradient(circle at 20px 45px, #ffeec0 0 6px, transparent 7px),
        radial-gradient(circle at 70px 35px, #ff9aa5 0 6px, transparent 7px),
        radial-gradient(circle at 120px 50px, #9ff1c1 0 6px, transparent 7px),
        radial-gradient(circle at 170px 38px, #7ed2ff 0 6px, transparent 7px),
        linear-gradient(#1a361f 12px, transparent 12px);
    }
    html[data-color="christmas"] body::after{
      bottom:0;
      height:110px;
      background-image:
        radial-gradient(circle at 30px 35px, #ffc1ce 0 5px, transparent 6px),
        radial-gradient(circle at 90px 50px, #b5ffe0 0 5px, transparent 6px),
        radial-gradient(circle at 150px 40px, #fff2ad 0 5px, transparent 6px),
        radial-gradient(circle at 190px 55px, #ffd3b1 0 5px, transparent 6px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.2) 0 40px, transparent 40px 60px);
    }
    html[data-color="christmas"] .container{
      border: 2px solid rgba(34,97,63,0.2);
      border-radius: 24px;
      padding-top: 28px;
      padding-bottom: 28px;
      box-shadow: 0 25px 60px rgba(5,30,18,0.25);
      background:
        linear-gradient(90deg, rgba(217,72,84,0.08), rgba(56,148,96,0.08));
    }
    html[data-color="christmas"] .card{
      border-color: rgba(34,97,63,0.18);
      box-shadow: 0 10px 24px rgba(6,25,15,0.18);
    }
    html[data-color="christmas"] .themed-card::before{
      background: linear-gradient(135deg, rgba(238,82,94,0.35), rgba(36,128,83,0.2));
      opacity: 1;
    }
    html[data-color="christmas"] .themed-card{
      color: #ffffff;
    }
    html[data-color="christmas"] .themed-card .label,
    html[data-color="christmas"] .themed-card .muted,
    html[data-color="christmas"] .themed-card #currentName,
    html[data-color="christmas"] .themed-card #currentRoom,
    html[data-color="christmas"] .themed-card #currentTimeRange,
    html[data-color="christmas"] .themed-card #elapsedOut,
    html[data-color="christmas"] .themed-card #leftOut,
    html[data-color="christmas"] .themed-card #nextName,
    html[data-color="christmas"] .themed-card #nextRoom,
    html[data-color="christmas"] .themed-card #nextTimeRange,
    html[data-color="christmas"] .themed-card #nextInOut,
    html[data-color="christmas"] .themed-card #untilOut{
      color: #ffffff;
    }
    html[data-color="christmas"] .label,
    html[data-color="christmas"] .muted,
    html[data-color="christmas"] .subclock,
    html[data-color="christmas"] .clock,
    html[data-color="christmas"] .countdown,
    html[data-color="christmas"] #dateOut,
    html[data-color="christmas"] #clockOut,
    html[data-color="christmas"] #elapsedOut,
    html[data-color="christmas"] #leftOut,
    html[data-color="christmas"] #currentName,
    html[data-color="christmas"] #nextName{
      color: #0c2f1d;
    }
    html[data-color="christmas"] #clockOut{
      color: #b5ffe0;
      font-size: clamp(1.8rem, 4vw, 2.4rem);
      white-space: nowrap;
    }
    html[data-color="christmas"] .pill{
      border-color: rgba(255,109,120,0.4);
      background: linear-gradient(120deg, rgba(233,94,106,0.5), rgba(28,110,72,0.08));
      color: #fef4f6;
    }
    html[data-color="christmas"] #schoolState,
    html[data-color="christmas"] #tzOut,
    html[data-color="christmas"] #dateOut{
      color: #9aeaba;
    }
    html[data-color="christmas"] .progress{
      background: linear-gradient(90deg, #ff8b8b, #46b07b);
    }

    /* ---------------- Dark theme overrides ---------------- */
    [data-theme="dark"]{
      --bg: #0e1512;
      --card: #0f1813;
      --text: #e7f5ec;
      --muted: #9bb2a7;
      --line: #213128;

      /* keep hue; adjust lightness/chroma for dark */
      --brand: hsl(var(--brand-h) 70% 40%);
      --brand-2: hsl(var(--brand-h) 75% 48%);
      --brand-3: hsl(var(--brand-h) 80% 58%);
      --brand-4: hsl(var(--brand-h) 90% 66%);

      --tint-weak: hsl(var(--brand-h) 28% 16%);
      --tint-weak-2: hsl(var(--brand-h) 30% 18%);
      --tint-strong-1: hsl(var(--brand-h) 34% 20%);
      --tint-strong-2: hsl(var(--brand-h) 36% 24%);
      --tint-hover-alpha: 0.16;

      --danger: #ff5c5c;
      --focus: hsl(var(--brand-h) 70% 52%);

      --surface-2: #0f1a15;
      --surface-3: #13251c;
    }

  /* Theme-specific surface overrides (dark mode) */
  html[data-theme="dark"][data-color="red"]{
    --bg: #140707;
    --card: #1b0a0a;
    --text: #ffecec;
    --muted: #f0a5a5;
    --line: #3b1414;
    --surface-2: #210d0d;
    --surface-3: #2c1111;
  }
  html[data-theme="dark"][data-color="blue"]{
    --bg: #08111f;
    --card: #0c1829;
    --text: #e3efff;
    --muted: #9bb2d6;
    --line: #1b2b44;
    --surface-2: #111f32;
    --surface-3: #152640;
  }
  html[data-theme="dark"][data-color="yellow"]{
    --bg: #1f1900;
    --card: #2a2200;
    --text: #fff8d1;
    --muted: #d9c48a;
    --line: #3d3100;
    --surface-2: #352b00;
    --surface-3: #403200;
  }
  html[data-theme="dark"][data-color="christmas"]{
    --bg: #071c11;
    --card: #0d2d1c;
    --text: #f0fff8;
    --muted: #97c7b4;
    --line: #1a4731;
    --surface-2: #14402a;
    --surface-3: #1a4b33;
  }
  html[data-theme="dark"][data-color="rainbow"]{
    --bg: #140820;
    --card: #1a0b2c;
    --text: #f5e7ff;
    --muted: #cbaef0;
    --line: #2c1341;
    --surface-2: #221038;
    --surface-3: #2b1548;
  }
  html[data-theme="dark"][data-color="custom"]{
    --bg: hsl(var(--brand-h) 32% 12%);
    --card: hsl(var(--brand-h) 28% 16%);
    --text: hsl(var(--brand-h) 40% 90%);
    --muted: hsl(var(--brand-h) 35% 70%);
    --line: hsl(var(--brand-h) 25% 28%);
    --surface-2: hsl(var(--brand-h) 30% 14%);
    --surface-3: hsl(var(--brand-h) 32% 18%);
  }

    * { box-sizing: border-box; }
    html, body { height: 100%; }
    body {
      margin: 0; height: 100%;
      font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
      background:
        radial-gradient(900px 600px at 10% -10%, hsl(var(--brand-h) 70% 48% / 0.08), transparent),
        radial-gradient(900px 600px at 110% 10%, hsl(var(--brand-h) 60% 42% / 0.08), transparent),
        var(--bg);
      color: var(--text);
      overflow: hidden;
    }
    .container { max-width: 1100px; margin: 0 auto; padding: 20px; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
    header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
    .controls {
      display:flex;
      align-items:center;
      justify-content:flex-start;
      gap:10px;
      flex-wrap:wrap;
      width:100%;
    }
    .controls-main {
      display:flex;
      gap:8px;
      align-items:center;
      flex-wrap:wrap;
      justify-content:flex-start;
      flex:0 1 auto;
      min-width:220px;
    }
    .controls-menu,
    .controls-external {
      display:flex;
      gap:8px;
      align-items:center;
      flex-wrap:wrap;
      flex:0 0 auto;
    }
    .controls-menu {
      justify-content:flex-start;
      flex:0 1 auto;
      gap:6px;
    }
    .controls-external {
      justify-content:flex-end;
      gap:6px;
      margin-left:auto;
      flex:1 1 200px;
    }

    button, .btn {
      background: linear-gradient(180deg, var(--brand), hsl(var(--brand-h) 70% 28%));
      border: 1px solid hsl(var(--brand-h) 70% 28%);
      color: #ffffff;
      padding: 10px 14px; border-radius: 12px; cursor:pointer; font-weight: 700;
    }
    button:hover { filter: brightness(1.05); }

    select, input[type="text"]{
      appearance: none; -webkit-appearance: none; -moz-appearance: none;
      background: var(--surface-2);
      border: 1px solid var(--line);
      color: #0a3d25;
      padding: 10px 12px; border-radius: 10px; font-weight: 700;
    }
    [data-theme="dark"] select, [data-theme="dark"] input[type="text"] { color: #d6efe1; }

    /* Hue slider for custom color */
    .hue-row { display:inline-flex; gap:8px; align-items:center; flex-wrap:wrap; }
    .hue-slider {
      -webkit-appearance: none; appearance: none;
      width: 220px; height: 10px; border-radius: 999px; border: 1px solid var(--line);
      background: linear-gradient(90deg, #f00 0%, #ff0 16.6%, #0f0 33.3%, #0ff 50%, #00f 66.6%, #f0f 83.3%, #f00 100%);
      outline: none;
    }
    .hue-slider::-webkit-slider-thumb {
      -webkit-appearance: none; appearance: none;
      width: 18px; height: 18px; border-radius: 50%;
      background: var(--card); border: 2px solid var(--brand);
      box-shadow: 0 1px 2px rgba(0,0,0,.3);
    }
    .hue-slider::-moz-range-thumb {
      width: 18px; height: 18px; border-radius: 50%;
      background: var(--card); border: 2px solid var(--brand);
      box-shadow: 0 1px 2px rgba(0,0,0,.3);
    }

    .grid { display:grid; grid-template-columns: 1.2fr 1fr; gap:16px; margin-top: 16px; }
    @media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

    .card { background: var(--card); border:1px solid var(--line); border-radius:18px; padding:18px; box-shadow: 0 6px 16px rgba(0,0,0,0.06); }
    [data-theme="dark"] .card { box-shadow: 0 6px 16px rgba(0,0,0,0.5); }

    /* THEMED cards: used for Current/Next info blocks */
    .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak-2), var(--tint-weak));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.35);
      background: transparent;
      border-color: var(--themed-card-border);
      position: relative;
      overflow: hidden;
    }
    [data-theme="dark"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak), var(--tint-strong-1));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.45);
      background: transparent;
      border-color: var(--themed-card-border);
    }
    
    /* Ensure themed cards respond to color changes */
    html[data-color="green"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak-2), var(--tint-weak));
      --themed-card-border: hsl(var(--brand-h) 35% 70% / 0.35);
    }
    html[data-color="red"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak-2), var(--tint-weak));
      --themed-card-border: hsl(var(--brand-h) 35% 70% / 0.35);
    }
    html[data-color="blue"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak-2), var(--tint-weak));
      --themed-card-border: hsl(var(--brand-h) 35% 70% / 0.35);
    }
    html[data-color="yellow"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak-2), var(--tint-weak));
      --themed-card-border: hsl(var(--brand-h) 35% 70% / 0.35);
    }
    
    html[data-theme="dark"][data-color="green"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak), var(--tint-strong-1));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.45);
    }
    html[data-theme="dark"][data-color="red"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak), var(--tint-strong-1));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.45);
    }
    html[data-theme="dark"][data-color="blue"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak), var(--tint-strong-1));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.45);
    }
    html[data-theme="dark"][data-color="yellow"] .themed-card{
      --themed-card-bg: linear-gradient(180deg, var(--tint-weak), var(--tint-strong-1));
      --themed-card-border: hsl(var(--brand-h) 35% 40% / 0.45);
    }

    .themed-card::before{
      content: "";
      position: absolute;
      inset: 0;
      border-radius: inherit;
      opacity: 0.75;
      background: var(--themed-card-bg);
      pointer-events: none;
      z-index: 0;
    }
    html[data-color="rainbow"] .themed-card::before{
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-bg 6s ease-in-out infinite;
    }
    .themed-card > *{
      position: relative;
      z-index: 1;
    }

    .muted { color: var(--muted); font-weight: 500; }
    .clock { font-size: clamp(28px, 5vw, 48px); font-weight: 900; letter-spacing: 0.5px; }
    .subclock { font-size: clamp(12px, 1.8vw, 14px); letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }

    .hstack { display:flex; align-items:center; gap:10px; }
    .vstack { display:flex; flex-direction:column; gap:10px; }

    .dayover-message{
      width: 100%;
      padding: 0;
      border-radius: 18px;
      border: none;
      background: transparent;
      min-height: 0;
      flex: 1;
    }
    .dayover-message iframe{
      width: 100%;
      height: 100%;
      min-height: 360px;
      border: 0;
      border-radius: 18px;
      display: block;
    }

    .hehe-trigger{
      position: fixed;
      bottom: 10px;
      left: 10px;
      width: 10px;
      height: 10px;
      font-size: 8px;
      line-height: 10px;
      opacity: 0.1;
      border: none;
      background: transparent;
      padding: 0;
      cursor: pointer;
      z-index: 120;
      color: inherit;
    }
    .hehe-trigger:hover{
      opacity: 0.15;
    }
    .hehe-modal{
      border: none;
      padding: 0;
      background: transparent;
    }
    .hehe-modal::backdrop{
      background: rgba(0,0,0,0.85);
    }
    .hehe-modal video{
      max-width: min(90vw, 480px);
      width: 100%;
      height: auto;
      border-radius: 16px;
      display: block;
    }

    .pixel-tracker{
      position:absolute;
      width:1px;
      height:1px;
      opacity:0;
      pointer-events:none;
    }
    .tracker-frame{
      position:absolute;
      width:1px;
      height:1px;
      border:0;
      opacity:0;
      pointer-events:none;
    }

    .pill {
      display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius: 999px;
      border:1px solid hsl(var(--brand-h) 35% 70% / 0.45);
      background: var(--tint-weak);
      color: var(--brand);
      font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
    }
    [data-theme="dark"] .pill{
      border-color: hsl(var(--brand-h) 35% 40% / 0.55);
    }

    .countdown { font-size: clamp(28px, 5vw, 46px); font-weight: 900; }
    .label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }

    .progress-wrap { position: relative; height: 12px; background: var(--surface-3); border:1px solid var(--line); border-radius: 999px; overflow: hidden; }
    .progress { position:absolute; inset:0; width:0%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s ease; }

    .schedule { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
    .schedule th, .schedule td { padding: 10px 10px; border-bottom: 1px solid var(--line); }
    .schedule th { text-align:left; color:var(--muted); font-size:12px; letter-spacing:1px; text-transform:uppercase; }

    .schedule tr.active { background: var(--tint-weak-2); position: relative; }
    .schedule tr.active::before {
      content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
      background: var(--brand);
      box-shadow: 0 0 0 2px hsl(var(--brand-h) 70% 46% / 0.12);
    }

    .status { font-size: 12px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); display:inline-block; background: var(--surface-2); }
    .status--current {
      color:#ffffff; background: linear-gradient(180deg, var(--brand), hsl(var(--brand-h) 70% 28%));
      border: 1px solid hsl(var(--brand-h) 70% 28%); font-weight: 800;
    }
    .status--next {
      color: #0a3d25; background: linear-gradient(180deg, var(--tint-strong-1), var(--tint-strong-2));
      border: 1px solid hsl(var(--brand-h) 45% 64%); font-weight: 800;
    }
    [data-theme="dark"] .status--next{ color:#cde9db; border-color: hsl(var(--brand-h) 35% 36%); }
    .status--done {
      color: hsl(var(--brand-h) 18% 34%);
      background: var(--surface-2);
      border-color: hsl(var(--brand-h) 20% 70% / 0.35);
    }
    [data-theme="dark"] .status--done{
      color: hsl(var(--brand-h) 18% 72% / 0.8);
      border-color: hsl(var(--brand-h) 20% 40% / 0.45);
    }

    .row { display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
    @media (max-width: 600px){ .row { grid-template-columns: 1fr; } }

    .kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; background:var(--surface-2); border:1px solid var(--line); padding:2px 6px; border-radius: 6px; color: #0a3d25; }
    [data-theme="dark"] .kbd { color:#d6efe1; }

    dialog::backdrop { background: rgba(0,0,0,0.35); backdrop-filter: blur(2px); }
    [data-theme="dark"] dialog::backdrop { background: rgba(0,0,0,0.55); }
    dialog { border:1px solid var(--line); border-radius: 16px; padding: 0; width: min(980px, 96vw); color: var(--text); background: var(--card); }
    .simple-dialog{ width:min(360px, 90vw); }
    .simple-dialog__body{
      padding:24px;
      text-align:center;
      display:flex;
      flex-direction:column;
      gap:12px;
    }
    .simple-dialog__title{ font-size:22px; font-weight:900; }
    .simple-dialog__subtitle{ color:var(--muted); font-size:15px; }
    .modal-header { padding: 14px 16px; display:flex; gap:8px; align-items:center; justify-content:space-between; border-bottom: 1px solid var(--line); }
    .modal-body { padding: 16px; }
    .footer { display:flex; justify-content:space-between; gap:10px; padding: 12px 16px; border-top:1px solid var(--line); }

    .tabs { display:flex; gap:4px; background:var(--surface-2); border-bottom:1px solid var(--line); padding:8px; }
    .tab { padding:8px 12px; border:1px solid var(--line); border-bottom:none; background:var(--card); border-radius:10px 10px 0 0; cursor:pointer; font-weight:800; color:#0a3d25; }
    [data-theme="dark"] .tab{ color:#d6efe1; }
    .tab[aria-selected="true"] { background: var(--tint-weak-2); color:#0a3d25; }
    [data-theme="dark"] .tab[aria-selected="true"] { color:#d6efe1; }

    .tabpanes { padding: 12px 8px; }

    /* New Editor Styles */
    .editor-container { max-width: 100%; margin: 0 auto; }
    
    .editor-controls { 
      display: flex; 
      gap: 12px; 
      align-items: center; 
      flex-wrap: wrap; 
      padding: 16px; 
      background: var(--surface-2); 
      border-radius: 12px; 
      margin-bottom: 16px;
      border: 1px solid var(--line);
    }
    
    .editor-controls .control-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    
    .editor-controls label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--muted);
    }
    
    .editor-controls select {
      padding: 8px 12px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: var(--card);
      font-weight: 600;
      min-width: 120px;
    }
    
    .blocks-container {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px;
      overflow: hidden;
    }
    
    .blocks-header {
      background: var(--surface-2);
      padding: 12px 16px;
      border-bottom: 1px solid var(--line);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .blocks-title {
      font-weight: 700;
      color: var(--text);
    }
    
    .blocks-actions {
      display: flex;
      gap: 8px;
    }
    
    .block-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 16px;
      border-bottom: 1px solid var(--line);
      transition: background-color 0.2s ease;
    }
    
    .block-item:hover {
      background: var(--surface-2);
    }
    
    .block-item:last-child {
      border-bottom: none;
    }
    
    .block-drag-handle {
      cursor: grab;
      color: var(--muted);
      font-size: 16px;
      padding: 4px;
      border-radius: 4px;
    }
    
    .block-drag-handle:hover {
      background: var(--surface-3);
      color: var(--text);
    }
    
    .block-content {
      flex: 1;
      display: grid;
      grid-template-columns: 2fr 1fr 1.2fr 1.2fr 0.8fr;
      gap: 12px;
      align-items: center;
    }
    
    .block-field {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    
    .block-field label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--muted);
    }
    
    .block-field input,
    .block-field select {
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid var(--line);
      background: var(--card);
      font-weight: 500;
      transition: border-color 0.2s ease;
    }
    
    .block-field input:focus,
    .block-field select:focus {
      outline: none;
      border-color: var(--brand);
      box-shadow: 0 0 0 2px hsl(var(--brand-h) 70% 50% / 0.1);
    }
    
    .time-inputs {
      display: flex;
      gap: 6px;
      align-items: center;
    }
    
    .time-inputs select {
      padding: 8px 6px;
      min-width: 50px;
      text-align: center;
    }
    
    .block-actions {
      display: flex;
      gap: 6px;
    }
    
    .block-action {
      padding: 8px;
      border-radius: 6px;
      border: 1px solid var(--line);
      background: var(--surface-2);
      cursor: pointer;
      transition: all 0.2s ease;
      font-size: 12px;
      font-weight: 600;
    }
    
    .block-action:hover {
      background: var(--surface-3);
      transform: translateY(-1px);
    }
    
    .block-action.danger {
      background: hsl(0 100% 96%);
      border-color: hsl(0 100% 88%);
      color: #8b1f1f;
    }
    
    .block-action.danger:hover {
      background: hsl(0 100% 92%);
    }
    
    [data-theme="dark"] .block-action.danger {
      background: #2a1717;
      border-color: #5a2a2a;
      color: #ff9a9a;
    }
    
    [data-theme="dark"] .block-action.danger:hover {
      background: #3a1f1f;
    }
    
    .empty-state {
      text-align: center;
      padding: 40px 20px;
      color: var(--muted);
    }
    
    .empty-state-icon {
      font-size: 48px;
      margin-bottom: 12px;
      opacity: 0.5;
    }
    
    .empty-state-text {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 8px;
    }
    
    .empty-state-subtext {
      font-size: 14px;
      opacity: 0.8;
    }
    
    .add-block-btn {
      background: linear-gradient(180deg, var(--brand), hsl(var(--brand-h) 70% 28%));
      border: 1px solid hsl(var(--brand-h) 70% 28%);
      color: #ffffff;
      padding: 12px 20px;
      border-radius: 10px;
      cursor: pointer;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: all 0.2s ease;
    }
    
    .add-block-btn:hover {
      filter: brightness(1.05);
      transform: translateY(-1px);
    }
    
    .quick-actions {
      display: flex;
      gap: 8px;
      margin-top: 16px;
      padding: 12px;
      background: var(--surface-2);
      border-radius: 8px;
      border: 1px solid var(--line);
    }
    
    .quick-action {
      padding: 8px 12px;
      border-radius: 6px;
      border: 1px solid var(--line);
      background: var(--card);
      cursor: pointer;
      font-size: 12px;
      font-weight: 600;
      transition: all 0.2s ease;
    }
    
    .quick-action:hover {
      background: var(--surface-3);
    }
    
    .quick-action.danger {
      background: hsl(0 100% 96%);
      border-color: hsl(0 100% 88%);
      color: #8b1f1f;
    }
    
    [data-theme="dark"] .quick-action.danger {
      background: #2a1717;
      border-color: #5a2a2a;
      color: #ff9a9a;
    }
    
    /* Validation and feedback styles */
    .block-field input.error,
    .block-field select.error {
      border-color: var(--danger);
      box-shadow: 0 0 0 2px hsl(0 70% 50% / 0.1);
    }
    
    .block-item.error {
      background: hsl(0 100% 98%);
      border-left: 4px solid var(--danger);
    }
    
    [data-theme="dark"] .block-item.error {
      background: hsl(0 20% 15%);
    }
    
    .validation-message {
      font-size: 11px;
      color: var(--danger);
      margin-top: 2px;
      font-weight: 500;
    }
    
    .block-item.validating {
      opacity: 0.7;
    }
    
    /* Improved focus states */
    .block-field input:focus,
    .block-field select:focus {
      outline: none;
      border-color: var(--brand);
      box-shadow: 0 0 0 2px hsl(var(--brand-h) 70% 50% / 0.15);
      transform: translateY(-1px);
    }
    
    /* Smooth transitions */
    .block-item,
    .block-field input,
    .block-field select,
    .block-action,
    .add-block-btn {
      transition: all 0.2s ease;
    }
    
    /* Loading state */
    .blocks-container.loading {
      opacity: 0.6;
      pointer-events: none;
    }
    
    .blocks-container.loading::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 20px;
      height: 20px;
      margin: -10px 0 0 -10px;
      border: 2px solid var(--line);
      border-top: 2px solid var(--brand);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    
    /* Rainbow animation keyframes */
    @keyframes rainbow-cycle {
      0% { --brand-h: 0; }     /* Red */
      16.66% { --brand-h: 30; }   /* Orange */
      33.33% { --brand-h: 60; }   /* Yellow */
      50% { --brand-h: 120; }  /* Green */
      66.66% { --brand-h: 240; }  /* Blue */
      83.33% { --brand-h: 280; }  /* Indigo/Purple */
      100% { --brand-h: 0; }   /* Back to Red */
    }

    textarea { width: 100%; height: 300px; background:var(--surface-2); color: var(--text); border:1px solid var(--line); border-radius: 12px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

    .help { font-size: 12px; color: var(--muted); }
    .inline { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
    .ghost { background:var(--surface-2); border:1px dashed var(--line); color:#0a3d25; }
    [data-theme="dark"] .ghost { color:#d6efe1; }

    .icon-btn{
      background:transparent;
      border:none;
      padding:6px;
      border-radius:10px;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      line-height:0;
      cursor:pointer;
    }
    .icon-btn:hover{ background:hsl(var(--brand-h) 50% 40% / var(--tint-hover-alpha)); }
    .icon{ width:28px; height:28px; display:block; }

    .hide-rooms .col-room, .hide-rooms #currentRoom, .hide-rooms #nextRoom{ display:none; }

    /* Overlays (onboarding + welcome) */
    .onboard {
      position: fixed; inset: 0; z-index: 9999;
      background:
        radial-gradient(1200px 800px at 10% -10%, hsl(var(--brand-h) 70% 50% / 0.14), transparent),
        radial-gradient(1200px 800px at 110% 10%, hsl(var(--brand-h) 70% 44% / 0.12), transparent),
        var(--bg);
      display:flex; align-items:center; justify-content:center;
      opacity: 1; transform: translateY(0);
      transition: opacity .35s ease, transform .35s ease;
    }
    .onboard.hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }
    .onboard-card {
      width: min(560px, 92vw);
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 22px;
      box-shadow: 0 20px 60px rgba(0,0,0,.15);
      text-align: center;
    }
    .onboard-title { font-weight: 900; font-size: 22px; margin-bottom: 10px; }
    .onboard-sub { color: var(--muted); margin-bottom: 14px; }
    .onboard-actions { display:flex; gap:10px; align-items:center; }
    .onboard-actions input[type="text"] { flex: 1; }
    .onboard-row{ display:flex; gap:10px; margin-top:10px; }
    .chip{
      padding:8px 12px; border-radius:999px; border:1px solid hsl(var(--brand-h) 35% 70% / 0.45); background:var(--tint-weak);
      cursor:pointer; font-weight:800; color:var(--brand);
    }
    /* Staggered text fade utility */
    .text-fade { display: inline-block; }
    .text-fade .char { opacity: 0; transition: opacity .25s ease; will-change: opacity; }
    .text-fade.ready .char { opacity: 1; }
    
    /* Dialog fade-in/out */
    dialog{
      opacity: 0; transform: translateY(6px);
      transition: opacity .25s ease, transform .25s ease;
      border: 1px solid var(--line); background: var(--card); color: inherit;
      width: auto; max-width: none; height: auto; max-height: none;
    }
    dialog[open].is-visible{ opacity: 1; transform: translateY(0); }
    dialog::backdrop{ background: rgba(0,0,0,0); transition: background .25s ease; }
    dialog[open].is-visible::backdrop{ background: rgba(0,0,0,0.35); }

    /* Themed custom selects */
    select{
      -webkit-appearance: none; appearance: none;
      background-color: var(--card); color: inherit;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 34px 8px 12px;
      background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
      background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
      transition: border-color .2s ease, box-shadow .2s ease;
    }
    select:hover{ border-color: hsl(var(--brand-h) 35% 70% / 0.6); }
    select:focus{ outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px hsl(var(--brand-h) 70% 50% / 0.15); }

    /* Custom dropdown wrapper (scroll open) */
    .select-wrap{ position: relative; display: inline-block; }
    .select-menu{ position:absolute; left:0; right:0; top: calc(100% + 4px); background: var(--card); border:1px solid var(--line); border-radius:12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); max-height: 0; overflow: hidden; transition: max-height .25s ease; z-index: 50; }
    .select-wrap.open .select-menu{ max-height: 95vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .select-menu .opt{ padding:8px 12px; cursor:pointer; }
    .select-menu .opt:hover{ background: var(--tint-weak); }

    /* Force onboarding/welcome card to fit 85% screen */
    .onboard-card{ width: min(560px, 92vw); max-width: min(560px, 92vw); height: auto; max-height: none; overflow: visible; }
    /* Ensure dialog bodies scroll within 85vh */
    dialog .modal-body{ max-height: none; overflow: visible; }
    
    /* Toast message */
    .toast{
      position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
      background: var(--card); color: inherit; border:1px solid var(--line); border-radius: 12px; padding: 10px 14px;
      box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none;
      transition: opacity .25s ease, transform .25s ease; z-index: 10001; font-weight: 800;
    }
    .toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

    /* Confetti */
    .confetti-piece{
      position: fixed; top: -10px; width: 8px; height: 14px; border-radius:2px;
      opacity: 0.9; z-index: 10000; pointer-events: none;
      animation-name: confetti-fall; animation-timing-function: cubic-bezier(.2,.8,.2,1);
    }
    @keyframes confetti-fall{
      0% { transform: translateY(-10px) rotate(0deg); }
      100%{ transform: translateY(110vh) rotate(720deg); }
    }
    .chip[aria-pressed="true"]{
      color:#fff; background: linear-gradient(180deg, var(--brand), hsl(var(--brand-h) 70% 28%)); border-color:hsl(var(--brand-h) 70% 28%);
    }
    
    /* Password Modal Styles */
    .password-modal {
      position: fixed; inset: 0; z-index: 10000;
      background: rgba(0,0,0,0.75);
      backdrop-filter: blur(8px);
      display: flex; align-items: center; justify-content: center;
      opacity: 0; visibility: hidden;
      transition: all 0.3s ease;
    }
    
    .password-modal.visible {
      opacity: 1; visibility: visible;
    }
    
    .password-modal-content {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 24px;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
      text-align: center;
      width: min(400px, 90vw);
      transform: translateY(20px);
      transition: transform 0.3s ease;
    }
    
    .password-modal.visible .password-modal-content {
      transform: translateY(0);
    }
    
    .password-modal-title {
      font-weight: 900;
      font-size: 20px;
      margin-bottom: 12px;
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-text 3s ease-in-out infinite;
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    
    .password-modal-subtitle {
      color: var(--muted);
      margin-bottom: 20px;
      font-size: 14px;
    }
    
    .rainbow-password-field {
      width: 100%;
      padding: 12px 16px;
      border-radius: 10px;
      border: 2px solid;
      background: var(--card);
      font-size: 16px;
      font-weight: 600;
      text-align: center;
      margin-bottom: 16px;
      
      /* Rainbow border animation */
      border-image: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080) 1;
      animation: rainbow-border 2s linear infinite;
    }
    
    .rainbow-password-field:focus {
      outline: none;
      box-shadow: 0 0 20px rgba(255,255,255,0.3);
    }
    
    .password-modal-actions {
      display: flex;
      gap: 10px;
      justify-content: center;
    }
    
    .password-modal-btn {
      padding: 10px 20px;
      border-radius: 8px;
      border: 1px solid var(--line);
      cursor: pointer;
      font-weight: 700;
      transition: all 0.2s ease;
    }
    
    .password-modal-btn.primary {
      background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
      background-size: 400% 400%;
      animation: rainbow-bg 3s ease-in-out infinite;
      color: white;
      border: none;
    }
    
    .password-modal-btn.secondary {
      background: var(--surface-2);
      color: var(--text);
    }
    
    .password-modal-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    
    @keyframes rainbow-text {
      0%, 100% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
    }
    
    @keyframes rainbow-border {
      0% { filter: hue-rotate(0deg); }
      100% { filter: hue-rotate(360deg); }
    }
    
    @keyframes rainbow-bg {
      0%, 100% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
    }
    
  
