    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg:           #070710;
      --surface:      #0f0f1c;
      --surface-2:    #161624;
      --surface-3:    #1f1f38;
      --border:       #222238;
      --border-light: #323258;
      --text:         #e2e2f0;
      --text-muted:   #7272a0;
      --text-dim:     #3c3c62;
      --accent:       #7b68f0;
      --accent-hover: #6856de;
      --accent-glow:  rgba(123,104,240,0.2);
      --accent-dim:   rgba(123,104,240,0.1);
      --success:      #2dd4a0;
      --success-dim:  rgba(45,212,160,0.12);
      --warning:      #f59e0b;
      --danger:       #f43f5e;
      --radius:       10px;
      --radius-sm:    7px;
      --radius-lg:    16px;
    }

    input, textarea, [contenteditable] { user-select: text; cursor: text; }
    a { cursor: pointer; }

    /* Global keyboard-focus ring — only shows for keyboard nav, not mouse clicks,
       so it doesn't clutter the visual design but gives clear feedback with tastatur. */
    button:focus-visible,
    a:focus-visible,
    [tabindex]:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    select:focus-visible,
    [contenteditable]:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    html, body {
      /* vh units don't shrink with CSS zoom on <html>, so at zoom > 1 a plain
         100vh body overflows the viewport and grows a scrollbar even when
         nothing needs to scroll. --inv-zoom (set in applyAppZoom) corrects
         for the current zoom factor. */
      min-height: calc(100vh * var(--inv-zoom, 1));
      background: var(--bg);
      background-image:
        radial-gradient(ellipse 80% 50% at 20% 0%, rgba(100,80,240,0.04) 0%, transparent 60%),
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.018) 1px, transparent 0);
      background-size: auto, 22px 22px;
      color: var(--text);
      user-select: none;
      cursor: default;
      font-family: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
      font-size: 17px;
      line-height: 1.7;
      letter-spacing: 0.01em;
      -webkit-font-smoothing: antialiased;
    }

    /* ── Layout ─────────────────────────────────────────────── */
    .app {
      max-width: 760px;
      margin: 0 auto;
      padding: env(safe-area-inset-top, 0px) 28px calc(100px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Header ─────────────────────────────────────────────── */
    .header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 32px 0 22px;
      border-bottom: 1px solid var(--border);
      margin-bottom: 32px;
      position: relative;
    }
    .header::after {
      content: '';
      position: absolute;
      bottom: -1px;
      left: 0;
      width: 60px;
      height: 1px;
      background: linear-gradient(90deg, var(--accent), transparent);
    }

    .logo {
      font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
      font-size: 28px;
      font-weight: 300;
      letter-spacing: -0.5px;
      background: linear-gradient(135deg, #ffffff 15%, #ccc0ff 50%, var(--accent) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      transition: opacity 0.2s;
    }
    .logo:hover { opacity: 0.85; }

    .date-display {
      font-size: 11px;
      color: var(--text-muted);
      font-family: 'Fira Code', monospace;
      margin-top: 4px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .header-actions { display: flex; gap: 8px; align-items: center; }

    /* ── Buttons ────────────────────────────────────────────── */
    .btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 9px 16px;
      border-radius: var(--radius-sm);
      font-family: inherit;
      font-size: 14px;
      font-weight: 500;
      letter-spacing: 0.01em;
      cursor: pointer;
      transition: all 0.14s ease;
      border: none;
      outline: none;
      white-space: nowrap;
    }

    .btn-ghost {
      background: transparent;
      color: var(--text-muted);
      border: 1px solid var(--border);
    }
    .btn-ghost:hover {
      background: var(--surface-2);
      color: var(--text);
      border-color: var(--border-light);
    }

    .btn-primary {
      background: var(--accent);
      color: #fff;
      font-weight: 600;
      letter-spacing: 0.01em;
      box-shadow: 0 1px 8px var(--accent-dim), inset 0 1px 0 rgba(255,255,255,0.08);
    }
    .btn-primary:hover:not(:disabled) {
      background: var(--accent-hover);
      transform: translateY(-1px);
      box-shadow: 0 6px 20px var(--accent-glow);
    }
    .btn-primary:active:not(:disabled) { transform: translateY(0); }
    .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

    .btn-sm { padding: 6px 11px; font-size: 12.5px; }

    .btn-danger {
      background: transparent;
      color: var(--danger);
      border: 1px solid rgba(244,63,94,0.28);
    }
    .btn-danger:hover {
      background: rgba(244,63,94,0.08);
      border-color: var(--danger);
    }

    /* ── API warning ────────────────────────────────────────── */
    .api-warning {
      background: rgba(245,158,11,0.08);
      border: 1px solid rgba(245,158,11,0.25);
      border-radius: var(--radius);
      padding: 13px 18px;
      font-size: 14px;
      color: var(--warning);
      margin-bottom: 22px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: background 0.15s;
    }
    .api-warning:hover { background: rgba(245,158,11,0.14); }

    /* ── Input section ──────────────────────────────────────── */
    .input-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      margin-bottom: 10px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
    }

    .main-textarea {
      width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 16px 18px;
      color: var(--text);
      font-family: inherit;
      font-size: 16px;
      line-height: 1.85;
      resize: vertical;
      min-height: 180px;
      transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
      outline: none;
    }
    .main-textarea:focus {
      border-color: var(--accent);
      background: var(--surface-2);
      box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 16px rgba(0,0,0,0.2);
    }
    .main-textarea::placeholder { color: var(--text-dim); }

    .action-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 14px 0 32px;
    }
    .action-bar-hint {
      font-size: 12px;
      color: var(--text-dim);
    }
    kbd {
      display: inline-block;
      padding: 2px 5px;
      background: var(--surface-2);
      border: 1px solid var(--border-light);
      border-radius: 4px;
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      color: var(--text-muted);
    }

    /* ── Progress ───────────────────────────────────────────── */
    .progress-section { margin-bottom: 28px; }
    .progress-header {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      margin-bottom: 10px;
    }
    .progress-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }
    .progress-percent {
      font-family: 'Fira Code', monospace;
      font-size: 36px;
      font-weight: 400;
      color: var(--success);
      line-height: 1;
      letter-spacing: -1px;
    }
    .progress-bar-container {
      height: 12px;
      background: var(--surface-2);
      border-radius: 99px;
      overflow: visible;
      border: 1px solid var(--border);
      position: relative;
    }
    .progress-bar-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--accent) 0%, #38c4a0 60%, var(--success) 100%);
      border-radius: 99px;
      transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
      min-width: 0;
      box-shadow: 0 0 16px rgba(45,212,160,0.35), 0 0 6px rgba(45,212,160,0.2);
      position: relative;
      overflow: hidden;
    }
    .progress-bar-fill::after {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 40%;
      background: linear-gradient(to bottom, rgba(255,255,255,0.18), transparent);
      border-radius: 99px;
    }

    /* ── Task groups ────────────────────────────────────────── */
    .tasks-container { display: flex; flex-direction: column; gap: 22px; margin-bottom: 36px; }

    .task-group {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .task-group:hover {
      border-color: var(--border-light);
      box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.02);
    }

    .task-group-header {
      padding: 11px 14px 11px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: var(--surface-2);
      border-bottom: 1px solid var(--border);
      gap: 8px;
      transition: background 0.15s;
    }
    .task-group-header-left {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .task-group-indicator {
      width: 3px;
      height: 18px;
      border-radius: 99px;
      background: rgba(123,104,240,0.35);
      flex-shrink: 0;
      transition: background 0.2s;
    }
    .task-group:hover .task-group-indicator {
      background: var(--accent);
    }
    .task-title { font-weight: 600; font-size: 16px; letter-spacing: 0.01em; }
    .task-count {
      font-size: 11px;
      color: var(--text-muted);
      font-family: 'Fira Code', monospace;
      background: var(--surface-3);
      padding: 2px 8px;
      border-radius: 99px;
      border: 1px solid var(--border);
    }

    .task-steps { padding: 6px 0; }

    .step-item {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      padding: 15px 18px;
      cursor: pointer;
      min-height: 48px;
      transition: background 0.12s;
      user-select: none;
    }
    .step-item:hover { background: var(--surface-2); }

    .step-checkbox {
      width: 21px;
      height: 21px;
      min-width: 21px;
      border: 1.5px solid var(--border-light);
      border-radius: 5px;
      margin-top: 2px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.16s;
      background: var(--surface-2);
    }
    .step-item:hover .step-checkbox {
      border-color: var(--accent);
      background: var(--accent-dim);
    }
    .step-item.done .step-checkbox {
      background: var(--success);
      border-color: var(--success);
      box-shadow: 0 0 6px rgba(45,212,160,0.25);
    }
    .step-item.done .step-checkbox::after {
      content: '';
      width: 5px;
      height: 9px;
      border: 2px solid #080810;
      border-top: none;
      border-left: none;
      transform: rotate(45deg) translate(-1px, -1px);
      display: block;
    }

    .step-text {
      font-size: 17px;
      line-height: 1.55;
      color: var(--text);
      flex: 1;
      transition: color 0.15s;
    }
    .step-item.done .step-text {
      color: var(--text-muted);
      text-decoration: line-through;
      text-decoration-color: var(--border-light);
      text-decoration-thickness: 1px;
    }

    /* ── Add more ───────────────────────────────────────────── */
    .add-more-section {
      background: var(--surface);
      border: 1px dashed var(--border-light);
      border-radius: var(--radius);
      overflow: hidden;
      margin-bottom: 20px;
    }
    .add-more-textarea {
      width: 100%;
      background: transparent;
      border: none;
      padding: 14px 18px;
      color: var(--text);
      font-family: inherit;
      font-size: 15px;
      line-height: 1.6;
      resize: none;
      min-height: 80px;
      outline: none;
    }
    .add-more-textarea::placeholder { color: var(--text-dim); }
    .add-more-footer {
      display: flex;
      justify-content: flex-end;
      padding: 8px 10px;
      border-top: 1px solid var(--border);
    }

    /* ── End day ────────────────────────────────────────────── */
    .end-day-section {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      padding: 28px 0 8px;
      border-top: 1px solid var(--border);
    }
    .end-day-hint { font-size: 13px; color: var(--text-dim); }

    /* ── Day complete banner ─────────────────────────────────── */
    .complete-banner {
      background: linear-gradient(135deg, rgba(45,212,160,0.08), rgba(123,104,240,0.1), rgba(45,212,160,0.04));
      border: 1px solid rgba(45,212,160,0.25);
      border-radius: var(--radius-lg);
      padding: 32px 28px;
      text-align: center;
      margin-bottom: 28px;
      box-shadow: 0 8px 40px rgba(45,212,160,0.06), inset 0 1px 0 rgba(255,255,255,0.04);
      position: relative;
      overflow: hidden;
    }
    .complete-banner::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 1px;
      background: linear-gradient(90deg, transparent, rgba(45,212,160,0.4), transparent);
    }
    .complete-banner h2 {
      font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
      font-size: 24px;
      font-weight: 300;
      letter-spacing: -0.5px;
      margin-bottom: 10px;
      background: linear-gradient(135deg, #ffffff 0%, #80f0d0 55%, var(--success) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }
    .complete-banner p { color: var(--text-muted); font-size: 14px; line-height: 1.65; }

    /* ── Summary ────────────────────────────────────────────── */
    .summary-section {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 22px 24px;
      margin-bottom: 24px;
    }
    .summary-title {
      font-weight: 600;
      font-size: 14px;
      color: var(--text-muted);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      margin-bottom: 12px;
    }
    .summary-text { font-size: 15px; color: var(--text); line-height: 1.75; }

    /* ── Loading ────────────────────────────────────────────── */
    .loading-state { text-align: center; padding: 56px 20px; }
    .loading-dots { display: inline-flex; gap: 7px; margin-bottom: 18px; }
    .loading-dots span {
      width: 10px; height: 10px;
      background: var(--accent);
      border-radius: 50%;
      animation: bounce 1.3s infinite;
      box-shadow: 0 0 8px var(--accent-glow);
    }
    .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
    .loading-dots span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes bounce {
      0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
      40% { transform: translateY(-10px); opacity: 1; }
    }
    .loading-text { font-size: 14px; color: var(--text-muted); }

    /* ── Settings overlay ───────────────────────────────────── */
    .settings-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.72);
      backdrop-filter: blur(6px);
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }
    .settings-panel {
      background: var(--surface-2);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-lg);
      padding: 28px;
      width: 100%;
      max-width: 440px;
      max-height: calc(100vh - 40px);
      overflow-y: auto;
      box-shadow: 0 40px 100px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.02);
    }
    .settings-title {
      font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
      font-size: 18px;
      font-weight: 300;
      letter-spacing: -0.3px;
      margin-bottom: 22px;
    }
    .form-group { margin-bottom: 18px; }
    .form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 7px; letter-spacing: 0.06em; text-transform: uppercase; }
    .form-input {
      width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      color: var(--text);
      font-family: 'Fira Code', monospace;
      font-size: 12.5px;
      outline: none;
      transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    }
    .form-input:focus {
      border-color: var(--accent);
      background: var(--surface-2);
      box-shadow: 0 0 0 3px var(--accent-glow);
    }
    select.form-input { cursor: pointer; font-family: inherit; font-size: 14px; }
    .form-hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; line-height: 1.5; }
    .settings-footer {
      display: flex; justify-content: flex-end; gap: 8px;
      margin-top: 24px; padding-top: 16px;
      position: sticky; bottom: 0;
      background: var(--surface-2);
      border-top: 1px solid var(--border);
    }

    /* ── Settings accordion ─────────────────────────────────── */
    .settings-acc {
      border: 1px solid var(--border);
      border-radius: 10px;
      margin-bottom: 10px;
      overflow: hidden;
      background: rgba(255,255,255,0.015);
    }
    .settings-acc-header {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 13px 14px;
      background: transparent;
      border: none;
      cursor: pointer;
      text-align: left;
      color: var(--text);
      font-size: 13px;
      font-weight: 600;
      transition: background 0.15s;
    }
    .settings-acc-header:hover { background: rgba(255,255,255,0.03); }
    .settings-acc-name { flex-shrink: 0; }
    .settings-acc-summary {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-align: right;
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      font-weight: 400;
      color: var(--text-dim);
    }
    .settings-acc-chevron {
      flex-shrink: 0;
      font-size: 11px;
      color: var(--text-dim);
      transition: transform 0.2s ease;
    }
    .settings-acc.open .settings-acc-chevron { transform: rotate(180deg); }
    .settings-acc-body {
      display: none;
      padding: 4px 14px 8px;
      border-top: 1px solid var(--border);
    }
    .settings-acc.open .settings-acc-body { display: block; }
    /* Section titles inside an accordion body don't need the heavy top border */
    .settings-acc-body .settings-section-title { border-top: none; padding-top: 8px; margin-top: 8px; }

    /* ── History panel ──────────────────────────────────────── */
    .history-panel {
      position: fixed;
      right: 0; top: 0; bottom: 0;
      width: 340px;
      background: var(--surface);
      border-left: 1px solid var(--border);
      z-index: 90;
      overflow-y: auto;
      padding: 24px;
      transform: translateX(100%);
      transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    }
    .history-panel.open {
      transform: translateX(0);
      box-shadow: -32px 0 72px rgba(0,0,0,0.6);
    }
    .history-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 20px;
    }
    .history-title { font-size: 16px; font-weight: 700; }

    .history-item {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-left: 3px solid transparent;
      border-radius: var(--radius);
      padding: 14px 16px 14px 14px;
      margin-bottom: 10px;
      transition: border-color 0.15s, background 0.15s, border-left-color 0.15s;
    }
    .history-item { cursor: pointer; }
    .history-item:hover { background: var(--surface-3); border-color: var(--border-light); border-left-color: var(--accent); }
    .history-date { font-size: 11px; color: var(--text-dim); font-family: 'Fira Code', monospace; margin-bottom: 5px; letter-spacing: 0.04em; }
    .history-stats { font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
    .history-pct { color: var(--success); font-family: 'Fira Code', monospace; }
    .history-chevron { font-size: 11px; color: var(--text-dim); transition: transform 0.2s; }
    .history-item.expanded .history-chevron { transform: rotate(180deg); }
    .history-summary {
      font-size: 12px; color: var(--text-muted); margin-top: 7px; line-height: 1.5;
    }
    .history-tasks {
      display: none;
      margin-top: 12px;
      border-top: 1px solid var(--border);
      padding-top: 12px;
    }
    .history-item.expanded .history-tasks { display: block; }
    .history-task-group { margin-bottom: 10px; }
    .history-task-title {
      font-size: 12px; font-weight: 600; color: var(--text-muted);
      letter-spacing: 0.05em; text-transform: uppercase;
      margin-bottom: 5px;
    }
    .history-step {
      display: flex; align-items: flex-start; gap: 8px;
      padding: 3px 0; font-size: 13px; line-height: 1.4;
    }
    .history-step-dot {
      width: 14px; height: 14px; min-width: 14px;
      border-radius: 3px; margin-top: 1px;
      border: 1.5px solid var(--border-light);
      display: flex; align-items: center; justify-content: center;
    }
    .history-step.done .history-step-dot {
      background: var(--success); border-color: var(--success);
    }
    .history-step.done .history-step-dot::after {
      content: '';
      width: 4px; height: 6px;
      border: 1.5px solid #080810;
      border-top: none; border-left: none;
      transform: rotate(45deg) translate(-1px,-1px);
      display: block;
    }
    .history-step.done .history-step-text { color: var(--text-dim); text-decoration: line-through; text-decoration-color: var(--text-dim); }
    .history-step.undone .history-step-text { color: var(--text-muted); }
    .history-move-btn {
      margin-top: 12px; width: 100%;
      background: var(--accent-dim); color: var(--accent);
      border: 1px solid rgba(124,106,247,0.3);
      border-radius: var(--radius-sm);
      padding: 8px; font-size: 13px; font-weight: 600;
      font-family: inherit; cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .history-move-btn:hover { background: rgba(124,106,247,0.2); border-color: var(--accent); }

    /* ── Project card ───────────────────────────────────────── */
    .project-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 13px 16px;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .project-card-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
    .project-badge {
      font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
      padding: 3px 8px; border-radius: 99px; white-space: nowrap; flex-shrink: 0;
    }
    .badge-premiere  { background: rgba(153,102,255,0.15); color: #9966ff; border: 1px solid rgba(153,102,255,0.3); }
    .badge-davinci   { background: rgba(255,107,53,0.15);  color: #ff8c5a; border: 1px solid rgba(255,107,53,0.3); }
    .badge-avid      { background: rgba(0,168,120,0.15);   color: #00c896; border: 1px solid rgba(0,168,120,0.3); }
    .badge-finalcut  { background: rgba(255,59,48,0.15);   color: #ff6b63; border: 1px solid rgba(255,59,48,0.3); }
    .badge-other     { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
    .project-icon-row { display: flex; align-items: center; gap: 12px; }
    .project-icon-emoji {
      width: 46px; height: 46px; text-align: center; font-size: 22px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius-sm); color: var(--text); outline: none;
      cursor: text; user-select: text; font-family: inherit;
    }
    .project-icon-emoji:focus { border-color: var(--accent); }
    .project-icon-colors { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
    .project-icon-swatch {
      width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
      border: 2px solid transparent; transition: transform 0.1s, border-color 0.1s;
      flex-shrink: 0;
    }
    .project-icon-swatch:hover { transform: scale(1.2); }
    .project-icon-swatch.selected { border-color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,0.4); }
    .project-icon-clear {
      font-size: 11px; color: var(--text-dim); cursor: pointer;
      background: none; border: none; font-family: inherit; padding: 0;
      text-decoration: underline; text-underline-offset: 2px;
    }
    .project-icon-clear:hover { color: var(--text); }
    .project-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .project-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

    .no-project-btn {
      width: 100%; background: transparent;
      border: 1px dashed var(--border-light);
      border-radius: var(--radius); padding: 12px 16px;
      color: var(--text-dim); font-family: inherit; font-size: 14px;
      cursor: pointer; margin-bottom: 20px; text-align: left;
      transition: border-color 0.15s, color 0.15s;
    }
    .no-project-btn:hover { border-color: var(--accent); color: var(--accent); }

    /* ── Project modal ───────────────────────────────────────── */
    .project-modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.72);
      backdrop-filter: blur(6px);
      z-index: 100;
      display: flex; align-items: center; justify-content: center; padding: 20px;
    }
    .project-modal {
      background: var(--surface-2); border: 1px solid var(--border-light);
      border-radius: var(--radius-lg); padding: 28px;
      width: 100%; max-width: 480px;
      max-height: 90vh; overflow-y: auto;
      box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    }
    .project-modal-title { font-size: 18px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 22px; }
    .project-modal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }

    /* ── Carry-over section ─────────────────────────────────── */
    .carryover-section {
      background: var(--surface);
      border: 1px solid rgba(124,106,247,0.3);
      border-radius: var(--radius-lg);
      overflow: hidden;
      margin-bottom: 24px;
    }
    .carryover-header {
      background: var(--accent-dim);
      padding: 13px 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid rgba(124,106,247,0.2);
    }
    .carryover-title { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0.03em; }
    .carryover-count { font-size: 12px; color: var(--text-muted); font-family: 'Fira Code', monospace; }
    .carryover-select-all { font-size: 12px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; background: none; border: none; font-family: inherit; padding: 0; }
    .carryover-body { padding: 12px 18px 4px; }
    .carryover-task { margin-bottom: 14px; }
    .carryover-task-title { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px; }
    .carryover-step {
      display: flex; align-items: flex-start; gap: 10px;
      padding: 6px 8px; margin-bottom: 2px; border-radius: var(--radius-sm);
      font-size: 13px; color: var(--text-muted);
      cursor: pointer; transition: background 0.1s; user-select: none;
    }
    .carryover-step:hover { background: var(--surface-2); }
    .carryover-cb {
      width: 16px; height: 16px; min-width: 16px;
      border: 2px solid var(--border-light); border-radius: 4px;
      margin-top: 1px; display: flex; align-items: center; justify-content: center;
      transition: all 0.15s;
    }
    .carryover-step.selected .carryover-cb { background: var(--accent); border-color: var(--accent); }
    .carryover-step.selected .carryover-cb::after {
      content: ''; width: 4px; height: 7px;
      border: 2px solid #fff; border-top: none; border-left: none;
      transform: rotate(45deg) translate(-1px,-1px); display: block;
    }
    .carryover-step.selected .carryover-step-text { color: var(--text); }
    .carryover-footer {
      padding: 11px 18px;
      border-top: 1px solid var(--border);
      display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    }

    /* ── Toast ──────────────────────────────────────────────── */
    .toast {
      position: fixed;
      bottom: calc(28px + env(safe-area-inset-bottom, 0px));
      left: 50%;
      transform: translateX(-50%) translateY(80px);
      background: var(--surface-3);
      border: 1px solid var(--border-light);
      border-radius: var(--radius);
      padding: 10px 22px;
      font-size: 13.5px;
      font-weight: 500;
      z-index: 200;
      transition: transform 0.32s cubic-bezier(0.34,1.56,0.64,1);
      pointer-events: none;
      white-space: nowrap;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04);
      letter-spacing: 0.02em;
    }
    .toast.show { transform: translateX(-50%) translateY(0); }
    .toast.success { border-color: rgba(45,212,160,0.5); color: var(--success); background: rgba(45,212,160,0.06); }
    .toast.error { border-color: rgba(244,63,94,0.5); color: var(--danger); background: rgba(244,63,94,0.06); }

    /* ── Update available pill ─────────────────────────────── */
    .update-pill {
      position: fixed;
      bottom: calc(28px + env(safe-area-inset-bottom, 0px));
      left: 50%;
      transform: translateX(-50%) translateY(80px);
      background: var(--surface-3);
      border: 1px solid var(--border-light);
      border-radius: var(--radius);
      padding: 10px 12px 10px 16px;
      font-size: 13.5px;
      font-weight: 500;
      z-index: 210;
      display: flex; align-items: center; gap: 12px;
      white-space: nowrap;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04);
      letter-spacing: 0.02em;
      opacity: 0;
      pointer-events: none;
      transition: transform 0.32s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
    }
    .update-pill.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }

    /* ── Version pill + global sync ────────────────────────── */
    #versionBar {
      /* Pinned to the bottom-left corner, mirroring .app-zoom-pill on the
         right — same offsets, low idle opacity so it stays unobtrusive. */
      position: fixed;
      bottom: calc(4px + env(safe-area-inset-bottom, 0px));
      left: calc(8px + env(safe-area-inset-left, 0px));
      z-index: 9000;
      padding: 4px 8px;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 6px;
      font-size: 11px;
      font-family: 'Fira Code', monospace;
      color: var(--text-muted);
      opacity: 0.5;
      user-select: none;
      transition: opacity 0.15s ease;
    }
    #versionBar:hover, #versionBar:focus-within { opacity: 1; }
    #versionBarSync {
      background: none; border: none; cursor: pointer;
      font-size: 14px; padding: 0 2px; color: var(--text-muted);
      opacity: 0.7; transition: opacity 0.15s; line-height: 1;
    }
    #versionBarSync:hover { opacity: 1; }
    #versionBarSyncStatus { font-size: 10px; }
    .update-pill-dot {
      width: 7px; height: 7px; border-radius: 50%;
      background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
      flex-shrink: 0;
    }
    .update-pill button.update-pill-btn {
      background: var(--accent); color: #fff; border: none;
      border-radius: calc(var(--radius) - 4px);
      padding: 5px 12px; font-size: 12.5px; font-weight: 600;
      cursor: pointer; transition: background 0.15s;
    }
    .update-pill button.update-pill-btn:hover { background: var(--accent-hover); }
    .update-pill button.update-pill-close {
      background: none; border: none; color: var(--text-muted);
      cursor: pointer; font-size: 15px; padding: 2px 4px; line-height: 1;
    }
    .update-pill button.update-pill-close:hover { color: var(--text); }


    /* ── Todo/Huskeliste items ───────────────────────────────── */
    .todo-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 18px;
      transition: background 0.12s;
      position: relative;
    }
    .todo-item:hover { background: var(--surface-2); }
    .todo-cb {
      width: 18px; height: 18px; min-width: 18px;
      border: 1.5px solid var(--border-light);
      border-radius: 4px; margin-top: 2px;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer; transition: all 0.15s;
      background: var(--surface-2); flex-shrink: 0;
    }
    .todo-cb:hover { border-color: var(--accent); background: var(--accent-dim); }
    .todo-item.done .todo-cb {
      background: var(--success); border-color: var(--success);
      box-shadow: 0 0 6px rgba(45,212,160,0.2);
    }
    .todo-item.done .todo-cb::after {
      content: ''; width: 4px; height: 8px;
      border: 2px solid #04060e;
      border-top: none; border-left: none;
      transform: rotate(45deg) translate(-1px,-1px); display: block;
    }
    .todo-text[contenteditable="true"] { outline: 1px solid var(--accent); border-radius: 3px; padding: 0 2px; cursor: text; }
    .todo-text:hover { text-decoration: underline dotted var(--text-muted); cursor: text; }
    .todo-text {
      font-size: 15px; color: var(--text); flex: 1;
      line-height: 1.55; transition: color 0.15s;
    }
    .todo-item.done .todo-text {
      color: var(--text-muted);
      text-decoration: line-through;
      text-decoration-color: var(--border-light);
      text-decoration-thickness: 1px;
    }
    .todo-del {
      opacity: 0; background: none; border: none;
      color: var(--text-dim); font-size: 13px;
      cursor: pointer; padding: 0 4px; line-height: 1;
      flex-shrink: 0; transition: opacity 0.15s, color 0.15s;
      font-family: inherit; margin-top: 2px;
    }
    .todo-item:hover .todo-del { opacity: 1; }
    .todo-del:hover { color: var(--danger); }

    /* ── Utility ────────────────────────────────────────────── */
    .hidden { display: none !important; }
    .fade-in { animation: fadeIn 0.3s ease; }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(10px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    /* ── Calendar ───────────────────────────────────────────── */
    .cal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.72); backdrop-filter: blur(6px);
      z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
    }
    .cal-modal {
      background: var(--surface-2); border: 1px solid var(--border-light);
      border-radius: var(--radius-lg); padding: 28px;
      width: 100%; max-width: 520px;
      box-shadow: 0 32px 80px rgba(0,0,0,0.6);
    }
    .cal-header {
      display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
    }
    .cal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
    .cal-nav { display: flex; gap: 6px; align-items: center; }
    .cal-nav-btn {
      background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
      color: var(--text-muted); font-size: 16px; width: 32px; height: 32px;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      transition: background 0.1s;
    }
    .cal-nav-btn:hover { background: var(--surface); color: var(--text); }
    .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 16px; }
    .cal-dow {
      text-align: center; font-size: 11px; font-weight: 600; color: var(--text-dim);
      letter-spacing: 0.06em; padding: 4px 0; text-transform: uppercase;
    }
    .cal-day {
      aspect-ratio: 1; border-radius: var(--radius-sm);
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      font-size: 13px; color: var(--text-muted); position: relative; cursor: default;
    }
    .cal-day.has-session {
      cursor: pointer; color: var(--text); font-weight: 600;
      transition: transform 0.1s;
    }
    .cal-day.has-session:hover { transform: scale(1.1); }
    .cal-day.today-marker { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }
    .cal-dot {
      width: 6px; height: 6px; border-radius: 50%;
      margin-top: 3px;
    }
    .cal-legend {
      display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; padding-top: 14px;
      border-top: 1px solid var(--border);
    }
    .cal-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
    .cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
    /* Day detail */
    .cal-detail {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 16px; margin-top: 16px;
    }
    .cal-detail-date { font-size: 12px; color: var(--text-dim); font-family: 'Fira Code', monospace; margin-bottom: 8px; }
    .cal-detail-project { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
    .cal-detail-stats { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
    .cal-detail-summary { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
    .cal-detail-tasks { margin-top: 10px; }
    .cal-detail-task { font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }

    /* ── New day button row ─────────────────────────────────── */
    .new-day-row { text-align: center; padding: 28px 0 8px; }

    @media (max-width: 560px) {
      .history-panel { width: 100%; }
      .app { padding: env(safe-area-inset-top, 0px) 16px calc(80px + env(safe-area-inset-bottom, 0px)); }
    }

    /* ══ Edit Session Mode ════════════════════════════════════════ */

    .btn-start-session {
      display: inline-flex; align-items: center; gap: 4px;
      padding: 4px 10px; border-radius: 6px;
      font-family: inherit; font-size: 12px; font-weight: 600;
      cursor: pointer;
      border: 1px solid rgba(245,158,11,0.35);
      background: rgba(245,158,11,0.08); color: #d97706;
      transition: all 0.15s; white-space: nowrap;
    }
    .btn-start-session:hover {
      background: rgba(245,158,11,0.18); border-color: #f59e0b; color: #f59e0b;
    }

    /* Session start modal */
    .es-modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.82); backdrop-filter: blur(8px);
      z-index: 150;
      display: flex; align-items: center; justify-content: center; padding: 20px;
    }
    .es-modal {
      background: var(--surface-2); border: 1px solid var(--border-light);
      border-radius: var(--radius-lg); padding: 28px;
      width: 100%; max-width: 460px;
      box-shadow: 0 32px 80px rgba(0,0,0,0.7);
    }
    .es-modal-title { font-size: 18px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 6px; }
    .es-modal-task  { font-size: 13px; color: #f59e0b; font-weight: 600; margin-bottom: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .es-section-label {
      font-size: 12px; font-weight: 600; color: var(--text-muted);
      margin-bottom: 10px; letter-spacing: 0.06em; text-transform: uppercase;
    }
    .es-project-grid {
      display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 20px;
    }
    .es-project-btn {
      padding: 9px 4px; border-radius: var(--radius-sm);
      border: 1px solid var(--border); background: var(--surface);
      color: var(--text-muted);
      font-family: 'Fira Code', monospace; font-size: 11px; font-weight: 600;
      cursor: pointer; text-align: center; transition: all 0.15s;
    }
    .es-project-btn:hover  { border-color: rgba(245,158,11,0.4); color: #f59e0b; }
    .es-project-btn.selected { border-color: #f59e0b; background: rgba(245,158,11,0.12); color: #f59e0b; }
    .es-settings-row { display: flex; gap: 14px; margin-bottom: 22px; }
    .es-setting-group { flex: 1; }
    .es-setting-select {
      width: 100%;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-sm); color: var(--text);
      font-family: inherit; font-size: 14px; padding: 9px 12px;
      cursor: pointer; outline: none; transition: border-color 0.15s;
    }
    .es-setting-select:focus { border-color: #f59e0b; }
    .es-modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

    /* Edit Session Mode — main view */
    #editSessionMode { display: none; flex-direction: column; gap: 14px; }
    #editSessionMode.es-active { display: flex; animation: fadeIn 0.3s ease; }

    .es-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 0; border-bottom: 1px solid var(--border);
    }
    .es-back-btn {
      background: none; border: none; color: var(--text-muted);
      font-family: inherit; font-size: 13px; cursor: pointer;
      padding: 0; display: flex; align-items: center; gap: 4px; transition: color 0.15s;
    }
    .es-back-btn:hover { color: var(--text); }
    .es-header-right { display: flex; align-items: center; gap: 8px; }
    .es-type-badge {
      font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
      padding: 3px 10px; border-radius: 99px;
      background: rgba(245,158,11,0.15); color: #f59e0b;
      border: 1px solid rgba(245,158,11,0.3);
      font-family: 'Fira Code', monospace;
    }
    .es-level-text { font-size: 11px; color: var(--text-dim); font-family: 'Fira Code', monospace; }
    .es-task-name  { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
    .es-block-info { font-size: 13px; color: var(--text-muted); font-family: 'Fira Code', monospace; margin-top: 3px; }

    /* Timer card */
    .es-timer-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 28px 24px 22px; text-align: center;
      position: relative; overflow: hidden;
    }
    .es-timer-card::before {
      content: '';
      position: absolute;
      top: 0; left: 50%; transform: translateX(-50%);
      width: 300px; height: 120px;
      background: radial-gradient(ellipse at 50% 0%, rgba(245,158,11,0.07) 0%, transparent 70%);
      pointer-events: none;
    }
    .es-timer-display {
      font-family: 'Fira Code', monospace;
      font-size: 76px; font-weight: 400; color: var(--text);
      line-height: 1; letter-spacing: -4px; margin-bottom: 8px; transition: color 0.4s;
      text-shadow: 0 0 60px rgba(245,158,11,0.12), 0 0 40px rgba(255,255,255,0.04);
    }
    /* Timer progress ring */
    .es-timer-ring {
      width: 100%;
      height: 3px;
      background: rgba(255,255,255,0.06);
      border-radius: 99px;
      overflow: hidden;
      margin-bottom: 14px;
    }
    .es-timer-ring-fill {
      height: 100%;
      background: linear-gradient(90deg, rgba(245,158,11,0.4), #f59e0b);
      border-radius: 99px;
      box-shadow: 0 0 8px rgba(245,158,11,0.4);
      transition: width 1s linear;
    }
    .es-timer-display.es-paused   { color: var(--text-muted); }
    .es-timer-display.es-break    { color: #f59e0b; }
    .es-timer-display.es-warning  { color: #f43f5e; }
    .es-timer-display.es-overtime { color: #f43f5e; font-size: 52px; }
    /* Current step — big and prominent inside timer card */
    .es-step-text {
      font-size: 18px; font-weight: 600; color: var(--text);
      line-height: 1.45; margin-bottom: 18px; letter-spacing: -0.3px;
      min-height: 28px;
    }
    .es-step-text:empty { display: none; }
    .es-timer-status { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; min-height: 20px; }
    .es-controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

    .btn-es {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 10px 20px; border-radius: var(--radius-sm);
      font-family: inherit; font-size: 14px; font-weight: 600;
      cursor: pointer; border: none; transition: all 0.15s; outline: none;
    }
    .btn-es-secondary {
      background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
    }
    .btn-es-secondary:hover:not(:disabled) { background: var(--surface-3); color: var(--text); border-color: var(--border-light); }
    .btn-es-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
    .btn-es-ghost {
      background: transparent; color: var(--text-dim); border: 1px solid var(--border);
      font-size: 13px; padding: 8px 14px;
    }
    .btn-es-ghost:hover { color: var(--text-muted); border-color: var(--border-light); }
    .btn-es-complete {
      background: linear-gradient(135deg, #f59e0b, #f97316); color: #000; font-weight: 700;
    }
    .btn-es-complete:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(245,158,11,0.4); }
    .btn-es-complete:active { transform: translateY(0); }

    /* Stats */
    .es-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .es-stat-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 14px 16px; text-align: center;
      position: relative; overflow: hidden;
    }
    .es-stat-card::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 2px;
      background: linear-gradient(90deg, transparent, rgba(245,158,11,0.6), transparent);
    }
    .es-stat-value {
      font-family: 'Fira Code', monospace; font-size: 28px; font-weight: 500;
      line-height: 1; margin-bottom: 5px; color: #f59e0b;
    }
    .es-stat-label { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

    /* Timeline */
    .es-timeline-header {
      font-size: 11px; font-weight: 600; color: var(--text-dim);
      letter-spacing: 0.08em; text-transform: uppercase;
      margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
    }
    .es-timeline-xp { color: #f59e0b; font-family: 'Fira Code', monospace; font-size: 12px; font-weight: 700; }
    .es-timeline {
      display: flex; gap: 3px; height: 20px;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 6px; overflow: hidden; padding: 3px;
    }
    .es-block-seg { flex: 1; border-radius: 2px; transition: background 0.4s; min-width: 6px; }
    .es-block-seg.seg-pending { background: var(--surface-3); }
    .es-block-seg.seg-active  { background: rgba(245,158,11,0.5); animation: esSegPulse 1.5s ease-in-out infinite; }
    .es-block-seg.seg-done    { background: #f59e0b; }
    .es-block-seg.seg-skipped { background: rgba(245,158,11,0.2); }
    .es-block-seg.seg-break   { background: rgba(245,158,11,0.25); animation: esSegPulse 2s ease-in-out infinite; }

    @keyframes esSegPulse {
      0%, 100% { opacity: 0.5; }
      50%       { opacity: 1; }
    }
    @keyframes esBlockCelebrate {
      0%   { box-shadow: 0 0 0 0   rgba(245,158,11,0); }
      35%  { box-shadow: 0 0 0 10px rgba(245,158,11,0.28); }
      100% { box-shadow: 0 0 0 0   rgba(245,158,11,0); }
    }
    .es-timer-card.celebrate { animation: esBlockCelebrate 0.65s ease; }

    .es-end-row {
      display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 4px;
    }
    .es-end-hint { font-size: 12px; color: var(--text-dim); }

    /* Modal project line */
    .es-modal-project {
      font-size: 12px; color: var(--text-dim); margin-bottom: 18px; margin-top: -12px;
      font-family: 'Fira Code', monospace; letter-spacing: 0.03em;
    }
    .es-modal-project:empty { display: none; }

    /* Tip banner */
    .es-tip-banner {
      background: rgba(124,106,247,0.1); border: 1px solid rgba(124,106,247,0.25);
      border-radius: var(--radius); padding: 14px 16px;
      animation: fadeIn 0.3s ease;
    }
    .es-tip-body   { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
    .es-tip-icon   { font-size: 18px; flex-shrink: 0; }
    .es-tip-text   { font-size: 13px; color: var(--text-muted); line-height: 1.65; }
    .es-tip-text strong { color: var(--text); }
    .es-tip-actions { display: flex; justify-content: flex-end; gap: 8px; }
    .es-tip-btn-ok {
      padding: 6px 14px; border-radius: 6px; font-family: inherit; font-size: 13px;
      font-weight: 600; cursor: pointer; border: none;
      background: var(--accent); color: #fff;
      transition: background 0.15s;
    }
    .es-tip-btn-ok:hover { background: var(--accent-hover); }
    .es-tip-btn-never {
      padding: 6px 12px; border-radius: 6px; font-family: inherit; font-size: 12px;
      cursor: pointer; border: 1px solid var(--border);
      background: transparent; color: var(--text-dim); transition: color 0.15s;
    }
    .es-tip-btn-never:hover { color: var(--text-muted); }

    /* ── Mini floating widget ─────────────────────────────── */
    .es-mini {
      position: fixed; top: calc(20px + env(safe-area-inset-top, 0px)); right: calc(20px + env(safe-area-inset-right, 0px));
      width: 240px; min-width: 200px; min-height: 160px;
      background: #111;
      border: 1px solid rgba(245,158,11,0.35);
      border-radius: 14px;
      box-shadow: 0 12px 40px rgba(0,0,0,0.75), 0 0 0 1px rgba(245,158,11,0.08);
      z-index: 9900;
      user-select: none; overflow: hidden;
      /* allow content to flex inside */
      display: flex; flex-direction: column;
    }
    .es-mini.mini-collapsed .es-mini-body { display: none; }
    .es-mini-handle {
      display: flex; align-items: center; justify-content: space-between;
      padding: 8px 10px 7px; cursor: grab; flex-shrink: 0;
      background: rgba(245,158,11,0.05);
      border-bottom: 1px solid rgba(245,158,11,0.1);
    }
    .es-mini-handle:active { cursor: grabbing; }
    .es-mini-grip { font-size: 14px; color: rgba(255,255,255,0.2); }
    .es-mini-badge-sm {
      font-family: 'Fira Code', monospace; font-size: 10px;
      color: #f59e0b; letter-spacing: 0.05em; font-weight: 700;
    }
    .es-mini-top-btns { display: flex; gap: 5px; }
    .es-mini-top-btn {
      width: 20px; height: 20px; border-radius: 50%;
      border: 1px solid rgba(255,255,255,0.1); cursor: pointer;
      font-size: 10px; display: flex; align-items: center; justify-content: center;
      background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.45);
      transition: all 0.15s; line-height: 1; padding: 0;
      font-family: inherit;
    }
    .es-mini-top-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
    .es-mini-top-btn.btn-red:hover { background: rgba(244,63,94,0.25); color: #f43f5e; border-color: rgba(244,63,94,0.3); }
    .es-mini-top-btn.btn-amber:hover { background: rgba(245,158,11,0.2); color: #f59e0b; border-color: rgba(245,158,11,0.3); }
    .es-mini-body { padding: 10px 12px 18px; flex: 1; display: flex; flex-direction: column; }
    .es-mini-step {
      font-size: 13px; color: rgba(255,255,255,0.85);
      line-height: 1.4; margin-bottom: 4px;
      word-break: break-word;
    }
    .es-mini-timer {
      font-family: 'Fira Code', monospace;
      font-size: 36px; font-weight: 700; letter-spacing: -1px;
      text-align: center; padding: 4px 0 6px; color: #fff;
    }
    .es-mini-timer.t-break   { color: #3b82f6; }
    .es-mini-timer.t-over    { color: #f43f5e; }
    .es-mini-timer.t-warn    { color: #f59e0b; }
    .es-mini-timer.t-paused  { opacity: 0.45; }
    .es-mini-meta {
      display: flex; justify-content: space-between;
      font-size: 11px; color: rgba(255,255,255,0.45);
      margin-bottom: 8px;
    }
    .es-mini-actions { display: flex; gap: 6px; margin-top: auto; }
    .es-mini-btn {
      flex: 1; padding: 8px 4px; border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.1);
      background: rgba(255,255,255,0.05);
      color: rgba(255,255,255,0.7);
      font-family: inherit; font-size: 13px;
      cursor: pointer; transition: all 0.15s; text-align: center;
    }
    .es-mini-btn:hover { background: rgba(255,255,255,0.09); color: #fff; }
    .es-mini-btn.primary {
      background: rgba(245,158,11,0.13); border-color: rgba(245,158,11,0.4);
      color: #f59e0b; font-weight: 700;
    }
    .es-mini-btn.primary:hover { background: rgba(245,158,11,0.22); border-color: #f59e0b; }
    /* Resize handle */
    .es-mini-resize {
      position: absolute; bottom: 0; right: 0;
      width: 18px; height: 18px; cursor: nwse-resize;
      background: linear-gradient(135deg, transparent 40%, rgba(245,158,11,0.35) 40%);
      border-bottom-right-radius: 14px;
    }
    /* Pop-out button in ES header */
    .es-popout-btn {
      padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
      border: 1px solid rgba(245,158,11,0.3);
      background: rgba(245,158,11,0.07); color: #d97706;
      cursor: pointer; font-family: inherit; transition: all 0.15s;
    }
    .es-popout-btn:hover { background: rgba(245,158,11,0.16); border-color: #f59e0b; color: #f59e0b; }

    @media (max-width: 480px) {
      .btn-label { display: none; }
      .header-actions { gap: 4px; }
      .header { padding: 20px 0 16px; }
      .logo { font-size: 20px; }
      .date-display { font-size: 11px; }
      #modeBadge { font-size: 10px; padding: 3px 9px; }
    }

    /* ── Mode themes ────────────────────────────────────────── */
    [data-mode="jobb"] {
      --bg:           #04060e;
      --surface:      #0a0e1e;
      --surface-2:    #101626;
      --surface-3:    #182036;
      --border:       #1e2640;
      --border-light: #2c3660;
      --text:         #dde2f8;
      --text-muted:   #6a7aac;
      --text-dim:     #323e68;
    }

    [data-mode="privat"] {
      --bg:           #0a0c08;
      --surface:      #131710;
      --surface-2:    #1a2016;
      --surface-3:    #222a1c;
      --border:       #283022;
      --border-light: #3a4a30;
      --text:         #ddebd5;
      --text-muted:   #7a9a70;
      --text-dim:     #3a5030;
      --accent:       #68c060;
      --accent-hover: #58b050;
      --accent-glow:  rgba(104,192,96,0.18);
      --accent-dim:   rgba(104,192,96,0.12);
      --success:      #e8b84a;
      --success-dim:  rgba(232,184,74,0.12);
    }

    /* ── Mode landing ───────────────────────────────────────── */
    .mode-landing {
      position: fixed;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #060810;
      z-index: 300;
      padding: 24px;
    }

    .mode-landing-inner {
      width: 100%;
      max-width: 700px;
      text-align: center;
    }

    .mode-landing-logo {
      font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
      font-size: 72px;
      font-weight: 300;
      letter-spacing: -3px;
      background: linear-gradient(135deg, #ffffff 15%, #ccc0ff 50%, #7b68f0 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      margin-bottom: 8px;
      line-height: 1;
    }

    .mode-landing-subtitle {
      font-size: 12px;
      color: #6060a0;
      margin-bottom: 56px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      font-family: 'Fira Code', monospace;
    }

    .mode-cards {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }

    .mode-card {
      border-radius: 24px;
      padding: 52px 38px;
      cursor: pointer;
      transition: transform 0.24s cubic-bezier(0.34,1.4,0.64,1), box-shadow 0.24s ease, border-color 0.2s ease;
      border: 1px solid transparent;
      text-align: left;
      position: relative;
      overflow: hidden;
    }
    .mode-card::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 1px;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    }
    /* Spotlight that follows the pointer — --mx/--my set from JS.
       Sits under the text (z-index 0 vs 1 on children) so copy stays crisp. */
    .mode-card::after {
      content: '';
      position: absolute;
      inset: 0;
      z-index: 0;
      pointer-events: none;
      background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), var(--card-glow, rgba(255,255,255,0.08)), transparent 70%);
      opacity: 0;
      transition: opacity 0.35s ease;
    }
    .mode-card:hover::after { opacity: 1; }
    .mode-card > * { position: relative; z-index: 1; }
    .mode-card:hover { transform: translateY(-8px) scale(1.01); }
    .mode-card:active { transform: translateY(-3px) scale(1); }
    /* Content lifts a touch extra, slightly delayed — gives the card layers */
    .mode-card-title, .mode-card-desc {
      transition: transform 0.3s cubic-bezier(0.34,1.4,0.64,1);
    }
    .mode-card:hover .mode-card-title { transform: translateY(-3px); transition-delay: 40ms; }
    .mode-card:hover .mode-card-desc { transform: translateY(-1px); transition-delay: 70ms; }

    .mode-card-jobb {
      --card-glow: rgba(90,140,255,0.13);
      background: linear-gradient(150deg, #080f24 0%, #0b1d48 100%);
      border-color: #162050;
      box-shadow: 0 24px 60px rgba(0,20,80,0.45);
    }
    .mode-card-jobb:hover {
      border-color: #2a4090;
      box-shadow: 0 32px 80px rgba(0,30,120,0.55);
    }

    .mode-card-privat {
      --card-glow: rgba(110,220,110,0.11);
      background: linear-gradient(150deg, #0c1a08 0%, #102514 100%);
      border-color: #1c3818;
      box-shadow: 0 24px 60px rgba(10,40,10,0.45);
    }
    .mode-card-privat:hover {
      border-color: #2e5828;
      box-shadow: 0 32px 80px rgba(20,70,20,0.55);
    }

    .mode-card-label {
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      font-weight: 400;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      margin-bottom: 16px;
      opacity: 0.5;
    }
    .mode-card-jobb .mode-card-label { color: #90b8ff; }
    .mode-card-privat .mode-card-label { color: #80c878; }

    .mode-card-title {
      font-family: 'Syne', sans-serif;
      font-size: 44px;
      font-weight: 800;
      letter-spacing: -1.5px;
      line-height: 1;
      margin-bottom: 16px;
    }
    .mode-card-jobb .mode-card-title {
      color: #c8daff;
      font-family: 'Barlow Condensed', sans-serif;
      font-weight: 800;
      font-size: 44px;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      line-height: 1.1;
      word-spacing: 0.25em;
    }
    .mode-card-privat .mode-card-title {
      color: #b8e0b0;
      font-family: 'Playfair Display', Georgia, serif;
      font-weight: 700;
      font-size: 44px;
      letter-spacing: -1px;
      line-height: 1.1;
      word-spacing: 0.25em;
    }

    .mode-card-desc {
      font-size: 15px;
      line-height: 1.6;
      opacity: 0.6;
    }
    .mode-card-jobb .mode-card-desc { color: #90b8ff; }
    .mode-card-privat .mode-card-desc { color: #80c878; }

    /* KUNNSKAP — gold/amber, "bible/permanent" feel */
    .mode-card-kunnskap {
      --card-glow: rgba(240,200,110,0.12);
      background: linear-gradient(150deg, #1a1306 0%, #2c1f08 100%);
      border-color: #4a3818;
      box-shadow: 0 24px 60px rgba(80,55,10,0.40);
    }
    .mode-card-kunnskap:hover {
      border-color: #7a5c20;
      box-shadow: 0 32px 80px rgba(120,85,20,0.50);
    }
    .mode-card-kunnskap .mode-card-label { color: #e8c98a; }
    .mode-card-kunnskap .mode-card-title {
      color: #f0dcae;
      font-family: 'VT323', monospace;
      font-weight: 400;
      font-size: 48px;
      letter-spacing: 1px;
      line-height: 1.1;
    }
    .mode-card-kunnskap .mode-card-desc { color: #d8b87a; }

    /* Three cards on the landing: switch grid to 3 columns */
    .mode-cards { grid-template-columns: 1fr 1fr 1fr; }

    @media (max-width: 820px) {
      .mode-cards { grid-template-columns: 1fr; }
      .mode-card { padding: 36px 28px; }
      .mode-card-title { font-size: 36px; }
    }

    /* ══════════════════════════════════════════════════════════
       KUNNSKAP room
    ══════════════════════════════════════════════════════════ */
    .mode-badge-kunnskap { background: linear-gradient(135deg, #2c1f08, #4a3818); }
    .k-breadcrumb { font-family: 'Fira Code', monospace; font-size: 12px; color: var(--text-muted); margin-top: 4px; }

    .k-hero { padding: 8px 0 28px; }
    .k-hero-title {
      font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700;
      font-size: 52px; letter-spacing: 0.5px; line-height: 1;
      background: linear-gradient(135deg, #f0dcae 10%, #e8c98a 55%, #c79a4a 100%);
      -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    }
    .k-hero-sub { color: var(--text-muted); font-size: 15px; margin-top: 10px; }

    .k-chapters { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    @media (max-width: 720px) { .k-chapters { grid-template-columns: 1fr; } }

    .k-card {
      --card-color: var(--accent);
      border: 1px solid var(--border); border-radius: 18px;
      background: var(--surface, #0e0e1a); padding: 22px 24px; cursor: pointer;
      position: relative; overflow: hidden;
      transition: transform 0.2s cubic-bezier(0.34,1.4,0.64,1), border-color 0.2s ease, box-shadow 0.2s ease;
    }
    .k-card::before {
      content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 3px;
      background: var(--card-color); opacity: 0.7;
    }
    .k-card:hover {
      transform: translateY(-4px);
      border-color: var(--card-color);
      box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 0 1px var(--card-color) inset;
    }
    .k-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
    .k-card-icon { font-size: 30px; line-height: 1; }
    .k-card-num { font-family: 'Fira Code', monospace; font-size: 10px; letter-spacing: 0.12em; color: var(--text-muted); }
    .k-card-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: -0.5px; color: var(--text); }
    .k-card-subs { display: flex; flex-direction: column; gap: 5px; }
    .k-card-sub { font-size: 13px; color: var(--text-muted); }

    /* Chapter page */
    .k-chapter-head { display: flex; align-items: center; gap: 18px; padding: 4px 0 22px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
    .k-chapter-icon { font-size: 44px; line-height: 1; }
    .k-chapter-num { font-family: 'Fira Code', monospace; font-size: 11px; letter-spacing: 0.14em; color: var(--card-color, var(--accent)); margin-bottom: 4px; }
    .k-chapter-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 34px; letter-spacing: -1px; color: var(--text); }

    .k-section { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; overflow: hidden; background: var(--surface, #0e0e1a); }
    .k-section-head {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 16px 20px; cursor: pointer; user-select: none;
    }
    .k-section-head:hover { background: var(--accent-dim); }
    .k-section-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; color: var(--text); }
    .k-section-toggle { color: var(--text-muted); transition: transform 0.2s ease; }
    .k-section.open .k-section-toggle { transform: rotate(90deg); }
    .k-section-body { display: none; padding: 4px 20px 20px; }
    .k-section.open .k-section-body { display: block; }
    .k-section-body p { color: var(--text-muted); line-height: 1.7; margin: 10px 0; font-size: 14.5px; }
    .k-section-body ul, .k-section-body ol { color: var(--text-muted); line-height: 1.7; margin: 10px 0 10px 20px; font-size: 14.5px; }
    .k-section-body li { margin: 4px 0; }
    .k-section-body strong { color: var(--text); }
    .k-section-body code { font-family: 'Fira Code', monospace; font-size: 12.5px; background: var(--accent-dim); padding: 1px 5px; border-radius: 4px; color: #cfc6ff; }

    .k-todo { color: var(--text-dim); font-size: 13px; font-style: italic; }
    .k-loading { text-align: center; color: var(--text-muted); padding: 40px 0; font-family: 'Fira Code', monospace; font-size: 13px; }

    /* ── Kunnskap room layout overrides ───────────────────────────────────── */
    .app.kunnskap {
      max-width: none;
      padding-left: 0;
      padding-right: 0;
      background: #0a0c0f;
    }
    /* Header needs its own horizontal padding since .app.kunnskap strips it */
    #kunnskapApp > .header {
      padding-left: 28px;
      padding-right: 28px;
    }
    #kGuideHost {
      width: 100%;
      min-height: calc(100vh - 100px);
    }
    #kGuideHost .home {
      max-width: 1400px;
      padding-left: 48px;
      padding-right: 48px;
    }
    #kGuideHost .chapter-page {
      max-width: 1400px;
    }
    #kGuideHost .chapters {
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    /* Hide the guide's multi-toggle (guide CSS is injected later, so need !important) */
    #kGuideHost .multi-toggle { display: none !important; }
    /* Logo blend: reduce visible background-color mismatch on the NesheiMedia logo */
    #kGuideHost .logo-wrap img { mix-blend-mode: lighten; }

    /* ── BIBEL chat panel ───────────────────────────────────── */
    .bibel-chat-wrap {
      position: fixed;
      top: 0; right: 0; bottom: 0;
      width: 420px;
      display: flex;
      flex-direction: column;
      background: #0f1117;
      border-left: 1px solid #2a2a3a;
      opacity: 0;
      pointer-events: none;
      transform: translateX(24px);
      transition: opacity 0.22s, transform 0.22s cubic-bezier(.4,0,.2,1);
      z-index: 200;
    }
    .bibel-chat-wrap.open { opacity: 1; pointer-events: auto; transform: none; }

    /* Size: small — floating box bottom-right */
    .bibel-chat-wrap.size-small {
      top: auto; bottom: 16px; right: 16px;
      width: 300px; height: 420px;
      border-left: none;
      border-radius: 16px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.75);
    }
    /* Size: medium — sidebar, lower portion */
    .bibel-chat-wrap.size-medium { width: 380px; }
    /* Size: large — wide full-height sidebar */
    .bibel-chat-wrap.size-large  { width: 540px; }

    /* Push guide content left when panel is open as sidebar */
    #kunnskapApp.kunnskap-panel-medium { padding-right: 380px !important; transition: padding-right .22s; }
    #kunnskapApp.kunnskap-panel-large  { padding-right: 540px !important; transition: padding-right .22s; }

    /* Size toggle buttons in panel header */
    .bibel-size-btns { display: flex; gap: 3px; }
    .bibel-size-btn {
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      padding: 2px 7px;
      border-radius: 4px;
      border: 1px solid #2a2a3a;
      background: transparent;
      color: #444460;
      cursor: pointer;
      transition: all .15s;
    }
    .bibel-size-btn:hover { border-color: #e8c98a55; color: #e8c98a; }
    .bibel-size-btn.active { border-color: #e8c98a88; color: #e8c98a; background: #e8c98a11; }
    .bibel-chat-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 18px;
      border-bottom: 1px solid #1e1e2e;
      flex-shrink: 0;
      position: relative; /* anchor for .bibel-model-menu */
    }
    #biblePanelModelBadge { cursor: pointer; transition: color 0.15s; }
    #biblePanelModelBadge:hover { color: #e8c98a; }
    .bibel-model-menu {
      position: absolute;
      top: calc(100% + 4px);
      left: 12px;
      z-index: 60;
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 240px;
      max-height: 320px;
      overflow-y: auto;
      padding: 6px;
      background: #14141f;
      border: 1px solid #2a2a3a;
      border-radius: 8px;
      box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    }
    .bibel-model-menu.hidden { display: none; }
    .bibel-model-menu-label {
      font-family: 'Fira Code', monospace;
      font-size: 9px;
      color: #444460;
      padding: 5px 10px 2px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }
    .bibel-model-item {
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      text-align: left;
      padding: 6px 10px;
      border-radius: 5px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.12s;
    }
    .bibel-model-item:hover { background: rgba(232,201,138,0.08); color: #e8c98a; }
    .bibel-model-item.active { background: rgba(232,201,138,0.10); color: #e8c98a; }
    .bibel-chat-header-title {
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #e8c98a;
      opacity: 0.8;
    }
    .bibel-chat-messages {
      flex: 1;
      overflow-y: auto;
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .bibel-msg {
      max-width: 88%;
      padding: 10px 14px;
      border-radius: 10px;
      font-size: 14px;
      line-height: 1.55;
      white-space: pre-wrap;
    }
    .bibel-msg-user {
      align-self: flex-end;
      background: #1e2a3a;
      color: #c8daff;
      border-bottom-right-radius: 3px;
    }
    .bibel-msg-ai {
      white-space: normal;
      align-self: flex-start;
      background: #151822;
      color: #d4d4e8;
      border-bottom-left-radius: 3px;
      border: 1px solid #1e1e2e;
    }
    .bibel-msg-ai.streaming::after {
      content: '▌';
      animation: blink .7s step-end infinite;
    }
    @keyframes blink { 50% { opacity: 0; } }
    .bibel-msg-error { color: #f87171; font-size: 13px; font-style: italic; }
    .bibel-tool-steps {
      display: flex;
      flex-direction: column;
      gap: 2px;
      margin-bottom: 10px;
      padding-bottom: 8px;
      border-bottom: 1px solid #1e1e2e;
    }
    .bibel-tool-step {
      font-style: italic;
      font-size: 11px;
      color: #7070a0;
      opacity: 0.55;
      letter-spacing: 0.01em;
      line-height: 1.5;
      display: flex;
      align-items: baseline;
      gap: 5px;
    }
    .bibel-tool-step.active { opacity: 0.75; color: #9090b8; }
    .bibel-tool-dots::after {
      content: '…';
      animation: blink 1s step-end infinite;
    }
    .bibel-msg-tokens {
      font-size: 10px;
      color: #44445a;
      margin-top: 6px;
      font-family: monospace;
      letter-spacing: 0.03em;
    }
    .bibel-handoff-overlay {
      position: absolute;
      inset: 0;
      background: rgba(8, 8, 16, 0.92);
      z-index: 30;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      border-radius: inherit;
    }
    .bibel-handoff-box {
      background: #12121e;
      border: 1px solid #2a2a3e;
      border-radius: 10px;
      padding: 20px;
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .bibel-handoff-title { font-size: 14px; font-weight: 600; color: #d4d4e8; }
    .bibel-handoff-desc  { font-size: 12px; color: #7070a0; line-height: 1.5; }
    .bibel-handoff-ta {
      background: #0a0a12;
      border: 1px solid #2a2a3e;
      border-radius: 6px;
      color: #d4d4e8;
      font-size: 12px;
      padding: 10px;
      resize: vertical;
      font-family: inherit;
      line-height: 1.5;
      min-height: 120px;
    }
    .bibel-handoff-ta:focus { outline: none; border-color: #4f8ef7; }
    .bibel-handoff-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
    .bibel-handoff-panel {
      background: #f5c54208;
      border: 1px solid #f5c54222;
      border-radius: 6px;
      margin-bottom: 12px;
      font-size: 12px;
    }
    .bibel-handoff-panel-header {
      padding: 8px 12px;
      color: #c9a830;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      font-weight: 500;
      user-select: none;
    }
    .bibel-handoff-panel-header:hover { color: #f5c542; }
    .bibel-handoff-panel-body {
      padding: 0 12px 10px;
      color: #a0a0b8;
      line-height: 1.6;
      white-space: pre-wrap;
    }
    .bibel-chat-empty {
      color: #555570;
      font-size: 13px;
      text-align: center;
      margin: auto;
      font-family: 'Fira Code', monospace;
    }
    .bibel-chat-footer {
      padding: 12px 14px;
      border-top: 1px solid #1e1e2e;
      display: flex;
      gap: 8px;
      flex-shrink: 0;
    }
    .bibel-chat-input {
      flex: 1;
      background: #0a0c0f;
      border: 1px solid #2a2a3a;
      border-radius: 8px;
      color: var(--text);
      font-size: 14px;
      padding: 8px 12px;
      resize: none;
      height: 72px;
      font-family: inherit;
      line-height: 1.5;
    }
    .bibel-chat-input:focus { outline: none; border-color: #e8c98a; }
    .bibel-chat-send {
      background: #e8c98a22;
      border: 1px solid #e8c98a44;
      color: #e8c98a;
      border-radius: 8px;
      padding: 0 14px;
      cursor: pointer;
      font-size: 18px;
      transition: background .15s;
      align-self: stretch;
    }
    .bibel-chat-send:hover { background: #e8c98a33; }
    .bibel-chat-send:disabled { opacity: .4; cursor: default; }
    .bibel-chat-usage {
      padding: 4px 14px 8px;
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      color: #444460;
      letter-spacing: 0.06em;
      flex-shrink: 0;
    }
    @media (max-width: 820px) {
      .bibel-chat-wrap { width: 100% !important; top: 0 !important; bottom: 0 !important; right: 0 !important; border-radius: 0 !important; height: auto !important; }
    }

    /* Settings: OpenRouter section */
    .settings-section-title {
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--text-muted);
      margin: 20px 0 4px;
      padding-top: 16px;
      border-top: 1px solid var(--border);
    }
    .model-presets {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 8px;
    }
    .model-preset-btn {
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      padding: 4px 10px;
      border-radius: 5px;
      border: 1px solid var(--border);
      background: transparent;
      color: var(--text-muted);
      cursor: pointer;
      transition: all .15s;
    }
    .model-preset-btn:hover { border-color: #e8c98a88; color: #e8c98a; }
    .model-preset-btn.active {
      border-color: #e8c98a;
      color: #e8c98a;
      background: rgba(232,201,138,0.10);
    }
    /* History overlay */
    .bibel-history-overlay {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      background: #0f1117;
      display: flex;
      flex-direction: column;
      z-index: 10;
    }
    .bibel-history-overlay.hidden { display: none; }
    .bibel-history-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 18px;
      border-bottom: 1px solid #1e1e2e;
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      color: #e8c98a;
      letter-spacing: 0.1em;
      flex-shrink: 0;
    }
    .bibel-history-list {
      flex: 1;
      overflow-y: auto;
      padding: 8px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .bibel-history-item {
      padding: 10px 14px;
      border: 1px solid #1e1e2e;
      border-radius: 8px;
      cursor: pointer;
      transition: border-color .15s;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 8px;
    }
    .bibel-history-item:hover { border-color: #e8c98a44; }
    .bibel-history-item.pinned { border-color: #f5c54233; background: #f5c5420a; }
    .bibel-history-section {
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.08em;
      color: #444460;
      text-transform: uppercase;
      padding: 8px 14px 4px;
    }
    .bibel-history-title {
      font-size: 13px;
      color: #d4d4e8;
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .bibel-history-meta {
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      color: #444460;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .bibel-history-del {
      background: none;
      border: none;
      color: #444460;
      cursor: pointer;
      font-size: 13px;
      padding: 0 4px;
      flex-shrink: 0;
    }
    .bibel-history-del:hover { color: #f87171; }
    .bibel-history-empty {
      color: #444460;
      font-family: 'Fira Code', monospace;
      font-size: 12px;
      text-align: center;
      margin: auto;
    }
    .bibel-ep-btn {
      font-family: 'Fira Code', monospace;
      font-size: 11px;
      padding: 6px 14px;
      border-radius: 6px;
      border: 1px solid #2a2a3a;
      background: transparent;
      color: #444460;
      cursor: pointer;
      transition: all .15s;
    }
    .bibel-ep-btn:hover { border-color: #e8c98a55; color: #e8c98a; }
    .bibel-ep-btn.active { border-color: #e8c98a; color: #e8c98a; background: #e8c98a11; font-weight: 600; }
    .bibel-link {
      color: #e8c98a;
      text-underline-offset: 3px;
      text-decoration-color: #e8c98a55;
      cursor: pointer;
    }
    .bibel-link:hover { text-decoration-color: #e8c98a; }
    .bibel-neutral { margin-bottom: 4px; }
    .bibel-box-guide, .bibel-box-general {
      border-radius: 7px;
      padding: 10px 13px;
      margin: 8px 0;
      font-size: 13.5px;
    }
    .bibel-box-guide {
      background: rgba(232,201,138,0.07);
      border-left: 3px solid #e8c98a88;
    }
    .bibel-box-general {
      background: rgba(79,142,247,0.07);
      border-left: 3px solid #4f8ef788;
    }
    .bibel-box-label {
      font-family: 'Fira Code', monospace;
      font-size: 10px;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      opacity: 0.6;
      margin-bottom: 6px;
    }
    .bibel-h2 {
      font-weight: 700;
      font-size: 13px;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: #e8c98a;
      margin: 10px 0 4px;
    }
    .bibel-h3 {
      font-weight: 600;
      font-size: 13px;
      color: #a0a0c0;
      margin: 8px 0 3px;
    }
    .bibel-think {
      font-style: italic;
      font-size: 12px;
      color: #404060;
      border-left: 2px solid #2a2a4a;
      padding: 4px 10px;
      margin-bottom: 8px;
      white-space: pre-wrap;
    }
    .settings-textarea {
      width: 100%;
      background: var(--input-bg, #0f1117);
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text);
      font-size: 13px;
      font-family: inherit;
      padding: 8px 10px;
      resize: vertical;
      line-height: 1.5;
      min-height: 72px;
    }
    .settings-textarea:focus { outline: none; border-color: #e8c98a; }

    /* ── Mode badge in header ───────────────────────────────── */
    .mode-badge {
      display: inline-flex;
      align-items: center;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      padding: 4px 12px;
      border-radius: 99px;
      cursor: pointer;
      transition: opacity 0.15s;
      white-space: nowrap;
    }
    .mode-badge:hover { opacity: 0.7; }
    .mode-badge-jobb {
      background: rgba(20,50,130,0.3);
      color: #90b8ff;
      border: 1px solid rgba(50,90,200,0.4);
    }
    .mode-badge-privat {
      background: rgba(20,60,20,0.3);
      color: #80c878;
      border: 1px solid rgba(40,100,40,0.4);
    }

    /* ── PRIVAT placeholder ─────────────────────────────────── */
    .privat-placeholder {
      text-align: center;
      padding: 80px 20px;
    }
    .privat-placeholder h2 {
      font-size: 28px;
      font-weight: 700;
      color: var(--text);
      margin-bottom: 14px;
      font-family: 'Playfair Display', Georgia, serif;
    }
    .privat-placeholder p {
      font-size: 15px;
      color: var(--text-muted);
      line-height: 1.7;
      max-width: 360px;
      margin: 0 auto 32px;
    }

    /* ── Tab navigation ────────────────────────────────────── */
    .tab-nav {
      display: flex;
      gap: 2px;
      margin-bottom: 26px;
      border-bottom: 1px solid var(--border);
      padding-bottom: 0;
    }
    /* In privat mode the Notatbøker tab comes first */
    body[data-mode="privat"] #tabNotice { order: -1; }
    .tab-btn {
      padding: 9px 18px;
      background: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--text-muted);
      font-family: inherit;
      font-size: 13.5px;
      font-weight: 500;
      cursor: pointer;
      transition: color 0.15s, border-color 0.15s;
      margin-bottom: -1px;
      letter-spacing: 0.03em;
    }
    .tab-btn:hover { color: var(--text); }
    .tab-btn.tab-active {
      color: var(--accent);
      border-bottom: 2px solid var(--accent);
      font-weight: 600;
      letter-spacing: 0.02em;
    }

    /* ── Accordion ──────────────────────────────────────────── */
    .accordion {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      margin-bottom: 14px;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .accordion:hover { border-color: var(--border-light); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
    .accordion-header {
      padding: 14px 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: var(--surface-2);
      border-bottom: 1px solid transparent;
      cursor: pointer;
      user-select: none;
      transition: background 0.1s;
    }
    .accordion-header:hover { background: var(--surface-3); }
    .accordion.open .accordion-header { border-bottom-color: var(--border); }
    .accordion-header-left { display: flex; align-items: center; gap: 10px; }
    .accordion-title-emoji { margin-right: 6px; }
    .accordion-title { font-weight: 600; font-size: 15px; letter-spacing: -0.2px; }
    .accordion-badge {
      font-size: 11px;
      color: var(--text-muted);
      font-family: 'Fira Code', monospace;
      background: var(--surface-3);
      padding: 2px 8px;
      border-radius: 99px;
      border: 1px solid var(--border);
    }
    .accordion-arrow {
      font-size: 12px;
      color: var(--text-dim);
      transition: transform 0.2s;
    }
    .accordion.open .accordion-arrow { transform: rotate(180deg); }
    .accordion-body { display: none; }
    .accordion.open .accordion-body { display: block; }

    /* ── Notice items ───────────────────────────────────────── */
    .notice-list { padding: 8px 0; }
    .notice-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 18px;
      transition: background 0.12s;
      position: relative;
    }
    .notice-item:hover { background: var(--surface-2); }
    .notice-item-text {
      font-size: 14.5px;
      color: var(--text);
      flex: 1;
      line-height: 1.6;
      word-break: break-word;
    }
    .notice-item-text a { text-decoration: none; }
    .notice-link {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 3px 9px 3px 6px;
      color: var(--text);
      font-size: 13px;
      transition: border-color 0.15s, background 0.15s;
      max-width: 100%;
      cursor: pointer;
      pointer-events: auto;
      -webkit-touch-callout: default;
    }
    .notice-link:hover {
      border-color: var(--accent);
      background: var(--surface-3);
      color: var(--text);
    }
    .notice-link-favicon {
      width: 14px;
      height: 14px;
      border-radius: 2px;
      flex-shrink: 0;
    }
    .notice-link-domain {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .notice-link-ext {
      flex-shrink: 0;
      opacity: 0.4;
      width: 11px;
      height: 11px;
    }
    .notice-item-del {
      opacity: 0;
      background: none;
      border: none;
      color: var(--text-dim);
      font-size: 14px;
      cursor: pointer;
      padding: 0 4px;
      line-height: 1;
      flex-shrink: 0;
      transition: opacity 0.15s, color 0.15s;
      font-family: inherit;
    }
    .notice-item:hover .notice-item-del { opacity: 1; }
    .notice-item-del:hover { color: var(--danger); }

    .notice-add-row {
      display: flex;
      gap: 8px;
      padding: 10px 18px 14px;
      border-top: 1px solid var(--border);
    }
    .notice-add-input {
      flex: 1;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 8px 12px;
      color: var(--text);
      font-family: inherit;
      font-size: 14px;
      outline: none;
      transition: border-color 0.15s;
    }
    .notice-add-input:focus { border-color: var(--accent); }
    .notice-add-input::placeholder { color: var(--text-dim); }

    /* ── Notebook grid ──────────────────────────────────────── */
    .notebook-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 18px;
      padding: 16px 18px 20px;
    }

    /* Base card — looks like a physical notebook */
    .notebook-card.nb-drag-over { outline: 2px dashed rgba(104,211,145,0.6); outline-offset: 2px; }
    .notebook-card.nb-card-dragging { opacity: 0.5; }
    .notebook-card {
      border-radius: 3px 8px 8px 3px;
      padding: 16px 12px 12px;
      cursor: pointer;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      position: relative;
      min-height: 180px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      box-shadow: 2px 3px 10px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.04);
      border-left: 6px solid var(--accent);
    }
    .notebook-card:hover {
      transform: translateY(-3px) rotate(0.8deg);
      box-shadow: 4px 10px 28px rgba(0,0,0,0.55);
    }

    .notebook-card-icon {
      font-size: 32px;
      line-height: 1;
      margin-bottom: 8px;
      margin-top: 4px;
      text-align: center;
    }
    .notebook-card-title {
      font-family: 'Playfair Display', Georgia, serif;
      font-size: 13px;
      font-weight: 700;
      color: var(--text);
      line-height: 1.3;
      text-align: center;
      word-break: break-word;
      flex: 1;
    }
    .notebook-card-meta {
      font-size: 10px;
      color: var(--text-dim);
      font-family: 'Fira Code', monospace;
      margin-top: 8px;
      text-align: center;
    }

    /* Action buttons — del and edit */
    .notebook-card-del,
    .notebook-card-edit {
      position: absolute;
      top: 6px;
      opacity: 0;
      background: none;
      border: none;
      color: var(--text-dim);
      font-size: 13px;
      cursor: pointer;
      padding: 2px 4px;
      transition: opacity 0.15s, color 0.15s;
      font-family: inherit;
      line-height: 1;
    }
    .notebook-card-del  { right: 6px; }
    .notebook-card-edit { left: 6px; }
    .notebook-card:hover .notebook-card-del,
    .notebook-card:hover .notebook-card-edit { opacity: 1; }
    .notebook-card-del:hover  { color: var(--danger); }
    .notebook-card-edit:hover { color: var(--accent); }

    /* ── Notebook style variants ────────────────────────────── */

    /* spiral */
    .nb-style-spiral {
      background: #fdf8e1;
      border-left-color: #bfaa60;
      border-radius: 3px 6px 6px 3px;
    }
    .nb-style-spiral::before {
      content: '⬤ ⬤ ⬤ ⬤ ⬤';
      position: absolute;
      top: -1px;
      left: 0; right: 0;
      text-align: center;
      font-size: 5px;
      color: #9a8c5a;
      letter-spacing: 6px;
      line-height: 1;
      padding-top: 3px;
    }
    .nb-style-spiral .notebook-card-title { color: #3a3320; }
    .nb-style-spiral .notebook-card-meta  { color: #7a6e42; }
    .nb-style-spiral .notebook-card-icon  { margin-top: 10px; }

    /* dagbok */
    .nb-style-dagbok {
      background: linear-gradient(160deg, #1c1208 0%, #2a1c0a 100%);
      border-left: 6px solid #c9a84c;
      box-shadow: 2px 3px 14px rgba(0,0,0,0.7), inset 0 0 40px rgba(0,0,0,0.3);
    }
    .nb-style-dagbok .notebook-card-title { color: #e8d5a0; font-style: italic; }
    .nb-style-dagbok .notebook-card-meta  { color: #a08040; }

    /* leksikon */
    .nb-style-leksikon {
      background: linear-gradient(to right, #2c3e50 0%, #3d5166 100%);
      border-left: 10px solid #c0a060;
      border-radius: 2px 6px 6px 2px;
      box-shadow: 3px 4px 14px rgba(0,0,0,0.6);
    }
    .nb-style-leksikon::after {
      content: '';
      position: absolute;
      left: -8px; top: 0; bottom: 0;
      width: 2px;
      background: rgba(255,220,120,0.3);
    }
    .nb-style-leksikon .notebook-card-title { color: #e8dcc8; font-family: Georgia, serif; font-size: 12px; letter-spacing: 0.02em; }
    .nb-style-leksikon .notebook-card-meta  { color: #a09070; }

    /* skoleheft */
    .nb-style-skoleheft {
      background: #f8f8f6;
      border-left: 3px solid #888;
      border-radius: 2px 4px 4px 2px;
    }
    .nb-style-skoleheft::after {
      content: '';
      position: absolute;
      left: 28px; top: 0; bottom: 0;
      width: 1px;
      background: rgba(220,60,60,0.4);
    }
    .nb-style-skoleheft .notebook-card-title { color: #1a1a2e; }
    .nb-style-skoleheft .notebook-card-meta  { color: #666; }

    /* postit */
    .nb-style-postit {
      background: #fef08a;
      border-radius: 2px;
      border-left: none;
      box-shadow: 3px 3px 8px rgba(0,0,0,0.35), inset 0 -3px 6px rgba(0,0,0,0.08);
    }
    .nb-style-postit::after {
      content: '';
      position: absolute;
      bottom: 0; right: 0;
      width: 20px; height: 20px;
      background: linear-gradient(225deg, rgba(0,0,0,0.15) 50%, transparent 50%);
    }
    .nb-style-postit .notebook-card-title { color: #1a1a1a; }
    .nb-style-postit .notebook-card-meta  { color: #555; }

    /* moleskine */
    .nb-style-moleskine {
      background: #1a1a1a;
      border-left: 6px solid #333;
      border-radius: 6px 8px 8px 6px;
      box-shadow: 3px 4px 16px rgba(0,0,0,0.7);
    }
    .nb-style-moleskine::before {
      content: '';
      position: absolute;
      top: 50%; left: -6px; right: 0;
      height: 3px;
      background: rgba(80,80,80,0.8);
      transform: translateY(-50%);
    }
    .nb-style-moleskine .notebook-card-title { color: #e8e8e8; }
    .nb-style-moleskine .notebook-card-meta  { color: #666; }

    /* ren */
    .nb-style-ren {
      background: #f5f2eb;
      border-left: 4px solid #ccc4b0;
      border-radius: 3px 6px 6px 3px;
      box-shadow: 2px 3px 10px rgba(0,0,0,0.18);
    }
    .nb-style-ren .notebook-card-title { color: #2a2a2a; font-weight: 600; }
    .nb-style-ren .notebook-card-meta  { color: #888; }

    /* notebook-add-card */
    .notebook-add-card {
      background: transparent;
      border: 2px dashed var(--border-light);
      border-radius: 6px;
      min-height: 180px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      font-size: 26px;
      cursor: pointer;
      transition: border-color 0.15s, color 0.15s;
      font-family: inherit;
    }
    .notebook-add-card:hover { border-color: var(--accent); color: var(--accent); }


    /* ── Page styles — match the notebook type chosen on the cover ── */
    /* Each style sets its own page colour, line colour and (optionally)
       overrides the paper-* pattern by re-declaring background-image.    */

    /* SPIRAL — yellow legal pad, blue rules, red margin */
    .nb-page-spiral {
      background-color: #f4e6a3;
      background-image:
        linear-gradient(90deg, transparent 0 88px,
          rgba(180,40,40,0.65) 88px 89px,
          rgba(180,40,40,0.25) 89px 90px,
          transparent 90px),
        repeating-linear-gradient(0deg,
          transparent 0 31px,
          rgba(70,100,150,0.40) 31px 32px);
      box-shadow:
        0 0 0 1px rgba(120,90,40,0.25),
        0 1px 0 rgba(255,250,220,0.5) inset,
        0 30px 70px rgba(0,0,0,0.55),
        0 8px 18px rgba(0,0,0,0.4),
        inset 0 -60px 80px -40px rgba(120,80,30,0.18);
    }
    .nb-cv-inner.nb-page-spiral::before {
      background:
        linear-gradient(180deg, rgba(180,140,70,0.4) 0%, rgba(180,140,70,0.05) 100%),
        repeating-linear-gradient(90deg,
          rgba(0,0,0,0.04) 0 1px,
          transparent 1px 3px);
      border-bottom: 1px solid rgba(120,80,30,0.3);
    }
    .nb-cv-inner.nb-page-spiral::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(40,25,5,0.7) 0 4px,
          rgba(200,170,90,0.55) 4px 5.2px,
          transparent 5.6px);
    }

    /* DAGBOK — aged parchment, no ruling, soft stains */
    .nb-page-dagbok {
      background-color: #e8d5a8;
      background-image:
        radial-gradient(ellipse 30% 25% at 18% 22%, rgba(140,90,30,0.10), transparent 70%),
        radial-gradient(ellipse 25% 20% at 78% 76%, rgba(100,50,10,0.12), transparent 70%),
        radial-gradient(ellipse 40% 30% at 60% 40%, rgba(160,110,50,0.07), transparent 70%);
      box-shadow:
        0 0 0 1px rgba(100,60,20,0.35),
        0 30px 70px rgba(0,0,0,0.6),
        0 8px 18px rgba(0,0,0,0.45),
        inset 0 0 120px rgba(80,40,10,0.25);
    }
    .nb-cv-inner.nb-page-dagbok::before {
      background:
        linear-gradient(180deg, rgba(80,40,10,0.5) 0%, rgba(80,40,10,0.1) 100%);
      border-bottom: 1px solid rgba(80,40,10,0.4);
    }
    .nb-cv-inner.nb-page-dagbok::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(40,20,5,0.7) 0 4px,
          rgba(180,140,70,0.5) 4px 5.2px,
          transparent 5.6px);
    }

    /* LEKSIKON — cream encyclopedia page, no margin line, faint sepia */
    .nb-page-leksikon {
      background-color: #ede0c4;
      background-image:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255,235,180,0.2), transparent 70%),
        radial-gradient(ellipse 60% 60% at 50% 100%, rgba(100,70,20,0.10), transparent 70%);
      box-shadow:
        0 0 0 1px rgba(120,90,40,0.25),
        0 30px 70px rgba(0,0,0,0.55),
        0 8px 18px rgba(0,0,0,0.4),
        inset 0 0 100px rgba(100,70,20,0.12);
    }
    .nb-cv-inner.nb-page-leksikon::before {
      background:
        linear-gradient(180deg, rgba(60,40,15,0.4) 0%, transparent 100%);
      border-bottom: 1px solid rgba(60,40,15,0.3);
    }
    .nb-cv-inner.nb-page-leksikon::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(30,18,5,0.6) 0 4px,
          rgba(180,150,90,0.5) 4px 5.2px,
          transparent 5.6px);
    }

    /* SKOLEHEFT — classic white Norwegian school notebook */
    .nb-page-skoleheft {
      background-color: #fafaf2;
      background-image:
        linear-gradient(90deg, transparent 0 88px,
          rgba(200,30,30,0.7) 88px 89px,
          rgba(200,30,30,0.25) 89px 90px,
          transparent 90px),
        repeating-linear-gradient(0deg,
          transparent 0 31px,
          rgba(70,110,180,0.35) 31px 32px);
      box-shadow:
        0 0 0 1px rgba(120,120,120,0.3),
        0 30px 70px rgba(0,0,0,0.55),
        0 8px 18px rgba(0,0,0,0.4);
    }
    .nb-cv-inner.nb-page-skoleheft::before {
      background:
        linear-gradient(180deg, rgba(120,120,120,0.25) 0%, transparent 100%);
      border-bottom: 1px solid rgba(120,120,120,0.3);
    }
    .nb-cv-inner.nb-page-skoleheft::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(60,60,60,0.7) 0 4px,
          rgba(180,180,180,0.7) 4px 5.2px,
          transparent 5.6px);
    }

    /* POSTIT — bright yellow sticky, no ruling, slight folded corner */
    .nb-page-postit {
      background-color: #fde74c;
      background-image:
        radial-gradient(ellipse 70% 50% at 50% 0%, rgba(255,255,200,0.5), transparent 70%),
        radial-gradient(ellipse 80% 80% at 50% 100%, rgba(180,150,30,0.18), transparent 70%);
      box-shadow:
        0 0 0 1px rgba(160,130,30,0.3),
        0 30px 70px rgba(0,0,0,0.55),
        0 8px 18px rgba(0,0,0,0.4),
        inset 0 -40px 60px -30px rgba(180,140,30,0.25);
    }
    .nb-cv-inner.nb-page-postit::before {
      background:
        linear-gradient(180deg, rgba(180,140,30,0.4) 0%, rgba(180,140,30,0.0) 100%);
      border-bottom: 1px solid rgba(180,140,30,0.3);
    }
    .nb-cv-inner.nb-page-postit::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(80,60,10,0.55) 0 4px,
          rgba(220,190,80,0.6) 4px 5.2px,
          transparent 5.6px);
    }

    /* MOLESKINE — premium ivory dot grid */
    .nb-page-moleskine {
      background-color: #1d1d1a;
      background-image:
        radial-gradient(circle, rgba(220,200,150,0.18) 1.2px, transparent 1.6px);
      background-size: 26px 26px;
      box-shadow:
        0 0 0 1px rgba(40,40,40,0.6),
        0 30px 70px rgba(0,0,0,0.7),
        0 8px 18px rgba(0,0,0,0.5),
        inset 0 0 100px rgba(0,0,0,0.4);
    }
    .nb-cv-inner.nb-page-moleskine::before {
      background:
        linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.15) 100%);
      border-bottom: 1px solid rgba(0,0,0,0.7);
    }
    .nb-cv-inner.nb-page-moleskine::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(0,0,0,0.9) 0 4px,
          rgba(180,160,110,0.25) 4px 5.2px,
          transparent 5.6px);
    }

    /* REN — minimal off-white, just a hint of texture */
    .nb-page-ren {
      background-color: #f4f0e8;
      background-image:
        radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255,250,240,0.4), transparent 70%);
      box-shadow:
        0 0 0 1px rgba(180,170,150,0.4),
        0 30px 70px rgba(0,0,0,0.5),
        0 8px 18px rgba(0,0,0,0.35);
    }
    .nb-cv-inner.nb-page-ren::before {
      background:
        linear-gradient(180deg, rgba(180,170,150,0.3) 0%, transparent 100%);
      border-bottom: 1px solid rgba(180,170,150,0.4);
    }
    .nb-cv-inner.nb-page-ren::after {
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(120,110,90,0.6) 0 4px,
          rgba(200,190,170,0.7) 4px 5.2px,
          transparent 5.6px);
    }

    /* Light-page blocks — dark text on slightly translucent white card so
       content stays readable on yellow/cream/white pages.                  */
    .nb-page-spiral .nb-block,
    .nb-page-dagbok .nb-block,
    .nb-page-leksikon .nb-block,
    .nb-page-skoleheft .nb-block,
    .nb-page-postit .nb-block,
    .nb-page-ren .nb-block {
      background: rgba(255,253,245,0.85);
      border: 1px solid rgba(80,60,30,0.18);
      color: #2a2118;
      box-shadow: 0 2px 8px rgba(60,40,15,0.18);
    }
    .nb-page-spiral .nb-block .nb-b-text,
    .nb-page-dagbok .nb-block .nb-b-text,
    .nb-page-leksikon .nb-block .nb-b-text,
    .nb-page-skoleheft .nb-block .nb-b-text,
    .nb-page-postit .nb-block .nb-b-text,
    .nb-page-ren .nb-block .nb-b-text,
    .nb-page-spiral .nb-block-text .nb-b-content,
    .nb-page-dagbok .nb-block-text .nb-b-content,
    .nb-page-leksikon .nb-block-text .nb-b-content,
    .nb-page-skoleheft .nb-block-text .nb-b-content,
    .nb-page-postit .nb-block-text .nb-b-content,
    .nb-page-ren .nb-block-text .nb-b-content {
      color: #2a2118;
    }
    /* Heading block "title" line — green→brown on light pages */
    .nb-page-spiral .nb-bh-title,
    .nb-page-dagbok .nb-bh-title,
    .nb-page-leksikon .nb-bh-title,
    .nb-page-skoleheft .nb-bh-title,
    .nb-page-postit .nb-bh-title,
    .nb-page-ren .nb-bh-title {
      color: #5a3a1a;
      border-bottom-color: rgba(90,60,30,0.35);
    }
    .nb-page-spiral .nb-bh-item,
    .nb-page-dagbok .nb-bh-item,
    .nb-page-leksikon .nb-bh-item,
    .nb-page-skoleheft .nb-bh-item,
    .nb-page-postit .nb-bh-item,
    .nb-page-ren .nb-bh-item {
      color: #2a2118;
    }
    /* Link box titles must stay readable on light page designs too */
    .nb-page-spiral .nb-link-title,  .nb-page-dagbok .nb-link-title,
    .nb-page-leksikon .nb-link-title, .nb-page-skoleheft .nb-link-title,
    .nb-page-postit .nb-link-title,  .nb-page-ren .nb-link-title,
    .nb-page-spiral .nb-link-card-title,  .nb-page-dagbok .nb-link-card-title,
    .nb-page-leksikon .nb-link-card-title, .nb-page-skoleheft .nb-link-card-title,
    .nb-page-postit .nb-link-card-title,  .nb-page-ren .nb-link-card-title {
      color: #2a2118;
    }
    .nb-page-spiral .nb-link-card-domain,  .nb-page-dagbok .nb-link-card-domain,
    .nb-page-leksikon .nb-link-card-domain, .nb-page-skoleheft .nb-link-card-domain,
    .nb-page-postit .nb-link-card-domain,  .nb-page-ren .nb-link-card-domain {
      color: rgba(42,33,24,0.6);
    }
    /* H1 block on light page — dark serif heading */
    .nb-page-spiral .nb-block-h1 .nb-b-text,
    .nb-page-dagbok .nb-block-h1 .nb-b-text,
    .nb-page-leksikon .nb-block-h1 .nb-b-text,
    .nb-page-skoleheft .nb-block-h1 .nb-b-text,
    .nb-page-postit .nb-block-h1 .nb-b-text,
    .nb-page-ren .nb-block-h1 .nb-b-text {
      color: #1a1208;
      border-bottom-color: rgba(90,60,30,0.45);
    }
    /* Style-specific typographic flourishes — apply to non-H1 blocks only,
       so the H1 heading picker (user-selected font) is not overridden. */
    .nb-page-dagbok .nb-block:not(.nb-block-h1) .nb-b-text {
      font-family: 'Playfair Display', Georgia, serif;
      font-style: italic;
    }
    .nb-page-leksikon .nb-block:not(.nb-block-h1) .nb-b-text,
    .nb-page-leksikon .nb-block-text .nb-b-content {
      font-family: Georgia, 'Playfair Display', serif;
    }
    .nb-page-postit .nb-block:not(.nb-block-h1) .nb-b-text {
      font-family: 'Barlow', sans-serif;
    }

    /* ── Notebook canvas view ──────────────────────────────── */
    .nb-canvas-view {
      position: fixed;
      inset: 0;
      z-index: 200;
      display: flex;
      flex-direction: column;
      background: var(--bg);
      animation: nbFadeIn 0.18s ease;
      /* Installed as a standalone PWA with a translucent status bar, so the
         view spans under the Dynamic Island. Without this the top bar — and
         with it the only way back out of a notebook — is unreachable. */
      padding-top:   env(safe-area-inset-top, 0px);
      padding-left:  env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
      box-sizing: border-box;
    }
    @keyframes nbFadeIn {
      from { opacity: 0; transform: scale(0.99); }
      to   { opacity: 1; transform: scale(1); }
    }
    .nb-cv-topbar {
      background: var(--surface);
      border-bottom: 1px solid rgba(255,255,255,0.07);
      padding: 9px 20px;
      display: flex;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
    }
    .nb-cv-back {
      background: transparent;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px;
      color: var(--text-muted);
      padding: 4px 11px;
      font-size: 12px;
      cursor: pointer;
      font-family: inherit;
    }
    .nb-cv-back:hover { color: var(--text); }
    .nb-cv-titlewrap { flex: 1; display: flex; align-items: center; gap: 9px; }
    .nb-cv-icon  { font-size: 20px; }
    .nb-cv-title { font-size: 16px; font-weight: 700; }
    .nb-cv-editbtn {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px;
      color: var(--text-muted);
      padding: 4px 12px;
      font-size: 12px;
      cursor: pointer;
      font-family: inherit;
    }
    .nb-cv-editbtn:hover { background: rgba(255,255,255,0.1); }
    .nb-cv-editbtn.active {
      background: rgba(104,211,145,0.15);
      border-color: rgba(104,211,145,0.4);
      color: #68d391;
    }
    .nb-cv-zoompill {
      display: flex;
      align-items: center;
      gap: 0;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px;
      overflow: hidden;
      flex-shrink: 0;
    }
    .app-zoom-pill {
      position: fixed;
      /* True corner, mirroring #versionBar's offset on the opposite side.
         Can rarely overlap .nb-minimap when a notebook is open — minimap
         fades to opacity 0 on its own when idle, so this is accepted. */
      bottom: calc(4px + env(safe-area-inset-bottom, 0px));
      right: calc(8px + env(safe-area-inset-right, 0px));
      z-index: 9000;
      display: flex;
      align-items: center;
      gap: 0;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px;
      overflow: hidden;
      backdrop-filter: blur(4px);
      opacity: 0.5;
      transition: opacity 0.15s ease;
    }
    .app-zoom-pill:hover, .app-zoom-pill:focus-within { opacity: 1; }
    .nb-cv-zoombtn {
      background: none;
      border: none;
      color: var(--text-muted);
      font-size: 13px;
      padding: 4px 8px;
      cursor: pointer;
      font-family: inherit;
      line-height: 1;
      transition: color 0.15s, background 0.15s;
    }
    .nb-cv-zoombtn:hover { color: var(--text); background: rgba(255,255,255,0.07); }
    .nb-cv-zoomlabel {
      font-size: 11px;
      color: var(--text-dim);
      min-width: 36px;
      text-align: center;
      font-family: 'Fira Code', monospace;
      padding: 0 2px;
      border-left: 1px solid rgba(255,255,255,0.08);
      border-right: 1px solid rgba(255,255,255,0.08);
    }
    @media (max-width: 600px) {
      .nb-cv-zoompill { display: none; }
      /* Narrow screens: icons only, and the way out never shrinks away */
      .nb-cv-label { display: none; }
      .nb-cv-topbar { padding: 6px 10px; gap: 8px; }
      /* Sizes are pre-zoom: the app renders at APP_ZOOM_BASE (0.8), so a 56px
         box lands at ~45 real px — Apple's 44pt minimum touch target. */
      .nb-cv-back {
        flex: 0 0 auto;
        min-width: 56px; min-height: 56px;
        font-size: 20px; line-height: 1; padding: 4px 10px;
        color: var(--text);
      }
      .nb-cv-editbtn, .nb-bg-btn { flex: 0 0 auto; min-width: 52px; min-height: 52px; font-size: 16px; }
      .nb-cv-titlewrap { min-width: 0; overflow: hidden; }
      .nb-cv-title {
        font-size: 15px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      }
    }
    .nb-cv-tabbar {
      background: rgba(0,0,0,0.25);
      border-bottom: 1px solid rgba(255,255,255,0.06);
      padding: 0 20px;
      display: flex;
      align-items: flex-end;
      overflow-x: auto;
      flex-shrink: 0;
    }
    .nb-cv-tab {
      background: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--text-muted);
      padding: 8px 16px;
      font-size: 13px;
      cursor: pointer;
      white-space: nowrap;
      font-family: inherit;
      transition: color 0.15s;
    }
    .nb-cv-tab:hover { color: var(--text); }
    .nb-cv-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
    .nb-cv-tab-add {
      background: transparent;
      border: none;
      color: var(--text-muted);
      padding: 8px 12px;
      font-size: 18px;
      cursor: pointer;
      font-family: inherit;
      line-height: 1;
    }
    .nb-cv-tab-add:hover { color: var(--accent); }
    /* Slim, soft scrollbars. The thumb colour follows the notebook background
       (--nb-scrollbar, set in applyNbBg); falls back to a soft sand tone. */
    .nb-cv-wrap { scrollbar-width: thin; scrollbar-color: rgba(180,160,120,0.32) transparent; }
    /* …and WebKit/Blink (Safari/Chrome) */
    .nb-cv-wrap::-webkit-scrollbar { width: 11px; height: 11px; }
    .nb-cv-wrap::-webkit-scrollbar-track { background: transparent; }
    .nb-cv-wrap::-webkit-scrollbar-thumb {
      background: var(--nb-scrollbar, rgba(180,160,120,0.28));
      border-radius: 8px;
      border: 3px solid transparent;
      background-clip: content-box;
    }
    .nb-cv-wrap::-webkit-scrollbar-thumb:hover { background: var(--nb-scrollbar-hover, rgba(200,180,140,0.5)); background-clip: content-box; }
    .nb-cv-wrap::-webkit-scrollbar-corner { background: transparent; }
    .nb-cv-wrap {
      flex: 1;
      overflow: auto;
      position: relative;
      cursor: grab;
      /* Dark wooden desk surface with subtle warm vignette */
      background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(60,45,25,0.22) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,0,0,0.4) 0%, transparent 70%),
        #060604;
      padding: 28px 24px 60px;
    }

    /* Hold-and-drag to pan the canvas (hand tool); grabbing while active */
    .nb-cv-inner { cursor: grab; }
    .nb-cv-wrap.nb-panning, .nb-cv-wrap.nb-panning * { cursor: grabbing !important; }
    /* The notebook PAGE — sits on the desk like a real sheet */
    .nb-cv-inner {
      position: relative;
      width: 1800px;
      min-height: 1200px;
      margin: 0 auto;
      /* background-color is owned by .paper-X and .nb-page-X — do not set here
         or it wins by being later in the cascade than .nb-page-X rules. */
      padding-top: 56px;          /* room for spiral binding */
      border-radius: 3px 3px 10px 10px;
      box-shadow:
        0 0 0 1px rgba(255,255,255,0.04),
        0 1px 0 rgba(255,255,255,0.06) inset,
        0 30px 70px rgba(0,0,0,0.6),
        0 8px 18px rgba(0,0,0,0.5),
        inset 0 -60px 80px -40px rgba(0,0,0,0.55);
      isolation: isolate;
    }

    /* Spiral binding strip across the top */
    .nb-cv-inner::before {
      content: "";
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 38px;
      background:
        linear-gradient(180deg,
          rgba(0,0,0,0.55) 0%,
          rgba(0,0,0,0.25) 60%,
          rgba(0,0,0,0.0) 100%),
        repeating-linear-gradient(90deg,
          rgba(255,255,255,0.04) 0 1px,
          transparent 1px 3px);
      border-bottom: 1px solid rgba(0,0,0,0.5);
      box-shadow: 0 1px 0 rgba(255,255,255,0.04);
      pointer-events: none;
      z-index: 2;
    }

    /* Spiral rings — repeating circles along the binding strip */
    .nb-cv-inner::after {
      content: "";
      position: absolute;
      top: 11px; left: 28px; right: 28px;
      height: 16px;
      pointer-events: none;
      z-index: 3;
      background-image:
        radial-gradient(circle at 8px 8px,
          rgba(0,0,0,0.85) 0 4px,
          rgba(255,255,255,0.10) 4px 5.2px,
          rgba(255,255,255,0.04) 5.2px 6.5px,
          transparent 6.6px);
      background-size: 56px 16px;
      background-repeat: repeat-x;
      filter: drop-shadow(0 1px 0 rgba(255,255,255,0.05));
    }

    /* Red vertical margin line on the left (like a real notebook) */
    .nb-cv-inner.has-margin {
      background-image:
        linear-gradient(90deg, transparent 0 88px,
          rgba(220,60,60,0.45) 88px 89px,
          rgba(220,60,60,0.18) 89px 90px,
          transparent 90px);
    }
    .nb-cv-inner.show-grid {
      background-image: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
      background-size: 24px 24px;
    }
    .nb-block {
      position: absolute;
      background: rgba(20,30,18,0.92);
      backdrop-filter: blur(8px);
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.07);
      box-shadow: 0 2px 12px rgba(0,0,0,0.4);
      padding: 14px 16px;
      min-width: 160px;
      cursor: text;
      box-sizing: border-box;
      color: var(--text);
      transition: border-color 0.15s, box-shadow 0.15s;
    }
    .nb-block:hover {
      border-color: rgba(255,255,255,0.16);
      box-shadow: 0 6px 22px rgba(0,0,0,0.45);
    }
    .nb-canvas-view.editing .nb-block:hover {
      box-shadow: 0 8px 26px rgba(0,0,0,0.4), 0 0 0 1px rgba(104,211,145,0.28);
    }
    .nb-block.nb-dragging {
      cursor: grabbing !important;
      box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 2px rgba(104,211,145,0.6);
      z-index: 100;
      transform: rotate(1deg);
      /* Re-blurring the backdrop every frame while the box moves is expensive —
         drop it during the drag itself, it's back the instant the box is released. */
      backdrop-filter: none;
    }
    @keyframes nbNewPulse {
      0%, 100% { box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
      50%      { box-shadow: 0 0 0 6px rgba(104,211,145,0.45), 0 0 24px rgba(104,211,145,0.5); }
    }
    .nb-block.nb-new-pulse { animation: nbNewPulse 1.1s ease-in-out 2; }
    .nb-conn-svg {
      position: absolute;
      left: 0; top: 0;
      width: 100%; height: 100%;
      pointer-events: none;
      overflow: visible;
    }
    .nb-conn-svg path { pointer-events: none; }
    .nb-canvas-view.editing .nb-conn-svg path { pointer-events: stroke; cursor: pointer; }
    .nb-conn-dots {
      position: absolute;
      top: 5px; left: 10px;
      display: flex; gap: 4px;
      pointer-events: none;
    }
    .nb-conn-dot {
      width: 11px; height: 11px;
      border-radius: 50%;
      border: 2px solid rgba(0,0,0,0.35);
      box-shadow: 0 1px 3px rgba(0,0,0,0.4);
      display: inline-block;
    }
    /* Connection dot shown inline next to a checklist row it's tied to */
    .nb-bh-conn-dot {
      width: 11px; height: 11px; flex: 0 0 auto;
      margin: 3px 2px 0 auto; align-self: flex-start;
    }
    .nb-cv-inner.nb-connecting,
    .nb-cv-inner.nb-connecting .nb-block { cursor: crosshair !important; }

    /* ── Stacked phone layout ────────────────────────────────
       A 1800px sheet of hand-placed boxes cannot work on a 390px screen, and
       card view makes table blocks several times taller, so absolutely
       positioned neighbours overlap. On a phone the page becomes one column
       in reading order. The class is set from _nbHandheld() in JS so the CSS
       and the JS view of "is this a phone" can never drift apart. */
    .nb-canvas-view.stacked .nb-cv-inner {
      width: auto !important;
      min-height: 0 !important;
      padding: 12px 10px 90px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      box-shadow: none;
      border-radius: 0;
    }
    .nb-canvas-view.stacked .nb-block {
      position: static !important;
      left: auto !important; top: auto !important;
      width: auto !important; height: auto !important;
      max-width: 100%;
    }
    /* Connection lines are drawn from canvas coordinates that no longer apply */
    .nb-canvas-view.stacked .nb-conn-svg,
    .nb-canvas-view.stacked .nb-conn-dots,
    .nb-canvas-view.stacked .nb-minimap { display: none !important; }
    /* Move and resize are disabled in this layout, so their affordances go too */
    .nb-canvas-view.stacked .nb-b-drag,
    .nb-canvas-view.stacked .nb-resize-only { display: none !important; }
    .nb-canvas-view.stacked .nb-cv-inner { cursor: default; }
    /* Heading inside text blocks (H button in the formatting toolbar) */
    .nb-b-text h3, .nb-block-text .nb-b-content h3 {
      font-family: 'Playfair Display', Georgia, serif;
      font-size: 1.6em;
      font-weight: 700;
      margin: 0.3em 0 0.15em;
      line-height: 1.2;
    }
    /* Inline URL chips in text blocks — neutral, readable, like a small link card.
       Inherits the surrounding text color so it stays legible on any box color. */
    .nb-inline-link {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 1px 8px 1px 5px;
      background: rgba(127,127,127,0.14);
      border: 1px solid rgba(127,127,127,0.32);
      border-radius: 6px;
      color: inherit;
      text-decoration: none;
      font-size: 0.92em;
      font-weight: 500;
      cursor: pointer;
      vertical-align: baseline;
      max-width: 100%;
    }
    .nb-inline-link:hover { background: rgba(127,127,127,0.24); border-color: rgba(127,127,127,0.5); }
    .nb-inline-link img { width: 14px; height: 14px; border-radius: 3px; flex: 0 0 auto; }
    /* Link box card display — big thumbnails (YouTube/og:image) */
    .nb-link-cards { display: flex; flex-direction: column; gap: 10px; }
    .nb-link-card {
      position: relative;
      border-radius: 10px;
      overflow: hidden;
      background: rgba(0,0,0,0.25);
      border: 1px solid rgba(255,255,255,0.08);
      cursor: pointer;
      transition: border-color 0.15s, transform 0.15s;
    }
    .nb-link-card:hover { border-color: rgba(104,211,145,0.4); transform: translateY(-1px); }
    .nb-link-card-thumb {
      width: 100%;
      aspect-ratio: 16 / 9;
      object-fit: cover;
      display: block;
    }
    .nb-link-card-thumb-fallback {
      display: flex; align-items: center; justify-content: center;
      font-size: 30px;
      background: rgba(255,255,255,0.05);
    }
    .nb-link-card-thumb-fallback img { width: 48px; height: 48px; border-radius: 9px; }
    .nb-link-card-body { padding: 8px 11px 9px; }
    .nb-link-card-title {
      font-size: 13px; font-weight: 600; line-height: 1.35;
      color: var(--text);
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .nb-link-card-domain { font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 2px; }
    .nb-link-card .nb-link-item-del {
      position: absolute; top: 6px; right: 6px;
      opacity: 0;
      background: rgba(0,0,0,0.55);
      border-radius: 5px;
      padding: 3px 7px;
    }
    .nb-link-card:hover .nb-link-item-del { opacity: 1; }

    /* Glass blocks on light page designs need dark text (translucent over light bg) */
    .nb-cv-inner.nb-page-spiral .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-dagbok .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-leksikon .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-skoleheft .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-postit .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-ren .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner.nb-page-spiral .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-dagbok .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-leksikon .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-skoleheft .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-postit .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-ren .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner.nb-page-spiral .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-dagbok .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-leksikon .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-skoleheft .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-postit .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-ren .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner.nb-page-spiral .nb-block.nb-bk-glass .nb-link-title,
    .nb-cv-inner.nb-page-dagbok .nb-block.nb-bk-glass .nb-link-title,
    .nb-cv-inner.nb-page-leksikon .nb-block.nb-bk-glass .nb-link-title,
    .nb-cv-inner.nb-page-skoleheft .nb-block.nb-bk-glass .nb-link-title,
    .nb-cv-inner.nb-page-postit .nb-block.nb-bk-glass .nb-link-title,
    .nb-cv-inner.nb-page-ren .nb-block.nb-bk-glass .nb-link-title {
      color: #2a2118;
    }
    .nb-cv-inner.nb-page-spiral .nb-block.nb-bk-glass .nb-bh-title,
    .nb-cv-inner.nb-page-dagbok .nb-block.nb-bk-glass .nb-bh-title,
    .nb-cv-inner.nb-page-leksikon .nb-block.nb-bk-glass .nb-bh-title,
    .nb-cv-inner.nb-page-skoleheft .nb-block.nb-bk-glass .nb-bh-title,
    .nb-cv-inner.nb-page-postit .nb-block.nb-bk-glass .nb-bh-title,
    .nb-cv-inner.nb-page-ren .nb-block.nb-bk-glass .nb-bh-title {
      color: #5a3a1a;
      border-bottom-color: rgba(90,60,30,0.35);
    }

    /* Placeholder must be readable on both dark and light page designs */
    .nb-b-text em.nb-placeholder { color: rgba(255,255,255,0.35); font-style: italic; font-weight: normal; }
    .nb-page-spiral .nb-block em.nb-placeholder,
    .nb-page-dagbok .nb-block em.nb-placeholder,
    .nb-page-leksikon .nb-block em.nb-placeholder,
    .nb-page-skoleheft .nb-block em.nb-placeholder,
    .nb-page-postit .nb-block em.nb-placeholder,
    .nb-page-ren .nb-block em.nb-placeholder { color: rgba(42,33,24,0.45); }

    /* Manually chosen text color — wins over page design, box style and box
       color (doubled class bumps specificity above every auto rule) */
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-b-text,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-b-content,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-bh-item,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-bh-item > span,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-link-title,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-link-card-title {
      color: var(--nb-fg);
    }
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-bh-title {
      color: var(--nb-fg);
      border-bottom-color: color-mix(in srgb, var(--nb-fg) 40%, transparent);
    }
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-bh-item.checked span {
      color: var(--nb-fg);
      opacity: 0.55;
    }
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-link-card-domain {
      color: var(--nb-fg);
      opacity: 0.65;
    }
    /* Table inherits the box text colour (tags keep their own chip colours) */
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl td,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl td.nb-tbl-foot-sum,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl-cellval,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl-card-label {
      color: var(--nb-fg);
    }
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl thead th {
      color: var(--nb-fg);
      opacity: 0.7;
    }
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl th,
    .nb-cv-inner .nb-block.nb-has-fg.nb-has-fg .nb-tbl td {
      border-color: color-mix(in srgb, var(--nb-fg) 28%, transparent);
    }
    .nb-edit-only, .nb-resize-only { display: none; }
    /* Clean hover: only a subtle delete button. Boxes still move by dragging
       the body; resize lives in edit mode + the right-click menu. */
    .nb-block:hover .nb-b-del { display: flex; }
    .nb-canvas-view.editing .nb-edit-only,
    .nb-canvas-view.editing .nb-resize-only { display: flex; }
    /* Smooth "magnet" snap when a dropped box is pushed off another */
    .nb-block.nb-snapping { transition: left 0.18s ease, top 0.18s ease, border-color 0.15s, box-shadow 0.15s; }
    .nb-b-drag {
      position: absolute;
      top: 6px; right: 28px;
      background: rgba(0,0,0,0.3);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 4px;
      color: rgba(255,255,255,0.3);
      font-size: 11px;
      cursor: grab;
      padding: 2px 5px;
      line-height: 1;
      opacity: 0;
      transition: opacity 0.15s;
    }
    .nb-block:hover .nb-b-drag { opacity: 1; }
    .nb-b-drag:hover { color: rgba(255,255,255,0.7); }
    .nb-b-del {
      position: absolute;
      top: 6px; right: 5px;
      background: rgba(0,0,0,0.3);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 4px;
      color: rgba(255,255,255,0.3);
      font-size: 11px;
      cursor: pointer;
      padding: 2px 5px;
      line-height: 1;
      opacity: 0;
      transition: opacity 0.15s, color 0.15s;
    }
    .nb-block:hover .nb-b-del { opacity: 1; }
    .nb-b-del:hover { color: #f43f5e; }
    .nb-b-res-e, .nb-b-res-s, .nb-b-res-se {
      position: absolute;
      background: rgba(104,211,145,0.5);
      border-radius: 2px;
    }
    .nb-b-res-e  { right: -4px; top: 20%; bottom: 20%; width: 8px; cursor: ew-resize; }
    .nb-b-res-s  { bottom: -4px; left: 20%; right: 20%; height: 8px; cursor: ns-resize; }
    .nb-b-res-se { right: -4px; bottom: -4px; width: 12px; height: 12px; cursor: nwse-resize; border-radius: 3px; }
    .nb-block-text .nb-b-content { font-size: 14px; line-height: 1.65; color: var(--text); min-height: 2em; word-wrap: break-word; overflow-wrap: anywhere; }
    .nb-b-text { word-wrap: break-word; overflow-wrap: anywhere; }
    .nb-block { overflow: hidden; }
    .nb-block-link { padding: 10px 12px; }
    .nb-block-link .nb-b-content { display: block; width: 100%; }
    .nb-link-list { width: 100%; }
    .nb-block-image { padding: 0; overflow: hidden; }
    .nb-block-image img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 10px; }
    .nb-bh-title {
      font-weight: 700; font-size: 12px;
      text-transform: uppercase; letter-spacing: 0.07em;
      color: #88c878;
      padding-bottom: 6px;
      border-bottom: 1.5px solid rgba(104,192,96,0.3);
      margin-bottom: 6px;
      display: flex; align-items: center; gap: 5px;
      cursor: pointer; user-select: none;
    }
    .nb-bh-arrow { font-size: 9px; transition: transform 0.15s; }
    .nb-block-heading.collapsed .nb-bh-arrow { transform: rotate(-90deg); }
    .nb-block-heading.collapsed .nb-bh-items { display: none; }
    /* Checklists grow with their content so the whole list is always visible */
    .nb-block.nb-block-heading { overflow: visible; height: auto !important; }

    /* ── Table / database block ─────────────────────────────── */
    .nb-block.nb-block-table { height: auto !important; }
    .nb-tbl-wrap { overflow-x: auto; max-width: 100%; }
    .nb-tbl { border-collapse: collapse; width: 100%; font-size: 13px; color: var(--text); }
    .nb-tbl th, .nb-tbl td {
      border: 1px solid rgba(127,127,127,0.22);
      padding: 5px 9px; text-align: left; vertical-align: middle; white-space: nowrap;
    }
    .nb-tbl thead th {
      font-weight: 600; font-size: 12px; color: var(--text-muted);
      background: rgba(127,127,127,0.10); cursor: pointer; user-select: none;
    }
    .nb-tbl thead th:hover { background: rgba(127,127,127,0.18); }
    .nb-tbl td.nb-tbl-td { cursor: text; }
    .nb-tbl td.nb-tbl-td-check, .nb-tbl th.nb-tbl-th-check { text-align: center; width: 1%; }
    .nb-tbl-td-check input[type=checkbox] { accent-color: #4a7c59; width: 16px; height: 16px; cursor: pointer; }
    .nb-tbl td.nb-tbl-td-number { text-align: right; font-variant-numeric: tabular-nums; }
    .nb-tbl-empty { color: var(--text-dim); }
    .nb-tbl-tag {
      display: inline-block; padding: 1px 8px; border-radius: 10px;
      font-size: 11px; font-weight: 600; line-height: 1.5;
      cursor: pointer;
    }
    .nb-tbl-tag:hover { filter: brightness(1.12); }
    .nb-tbl-input {
      width: 100%; min-width: 80px; box-sizing: border-box;
      background: rgba(0,0,0,0.25); color: var(--text);
      border: 1px solid rgba(104,211,145,0.5); border-radius: 4px;
      padding: 3px 6px; font: inherit; outline: none;
    }
    .nb-tbl td.nb-tbl-foot-cell { font-weight: 600; background: rgba(127,127,127,0.08); }
    .nb-tbl td.nb-tbl-foot-sum { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
    /* Total reduced by ticked-off rows — hover for the full breakdown */
    .nb-tbl td.nb-tbl-foot-sum.nb-tbl-foot-partial { color: var(--accent); cursor: help; }
    .nb-tbl-refresh {
      background: transparent; border: 1px dashed rgba(127,127,127,0.4);
      border-radius: 5px; color: var(--text-muted);
      width: 22px; height: 22px; font-size: 12px; line-height: 1;
      cursor: pointer; margin-right: 4px;
    }
    .nb-tbl-refresh:hover { border-color: rgba(127,127,127,0.7); color: var(--text); }
    .nb-tbl-addcol-th { width: 1%; background: transparent !important; cursor: default; padding: 0 !important; }
    .nb-tbl-addcol, .nb-tbl-addrow {
      background: transparent; border: 1px dashed rgba(127,127,127,0.4);
      color: var(--text-muted); border-radius: 6px; cursor: pointer;
      font: inherit; line-height: 1;
    }
    .nb-tbl-addcol { width: 26px; height: 26px; font-size: 16px; padding: 0; }
    .nb-tbl-addrow { margin-top: 8px; padding: 5px 12px; font-size: 12px; }
    .nb-tbl-addcol:hover, .nb-tbl-addrow:hover { color: var(--text); border-color: rgba(127,127,127,0.7); }
    .nb-tbl-rowdel-cell { border: none !important; width: 1%; padding: 0 4px !important; }
    .nb-tbl-rowdel {
      display: none; background: transparent; border: none; color: var(--text-dim);
      cursor: pointer; font-size: 13px; line-height: 1; padding: 2px;
    }
    .nb-canvas-view.editing .nb-tbl-rowdel { display: inline-block; }
    .nb-tbl-rowdel:hover { color: #e53e3e; }

    /* ── Done rows: a ticked check column strikes the whole line (Notion-style) ── */
    .nb-tbl tr.nb-tbl-row-done td.nb-tbl-td,
    .nb-tbl-card.nb-tbl-row-done .nb-tbl-card-field {
      text-decoration: line-through;
      text-decoration-thickness: 1px;
      color: var(--text-dim);
    }
    /* The checkbox cell itself must stay unstruck and fully legible */
    .nb-tbl tr.nb-tbl-row-done td.nb-tbl-td-check,
    .nb-tbl tr.nb-tbl-row-done td.nb-tbl-rowdel-cell,
    .nb-tbl tr.nb-tbl-row-done td.nb-tbl-rowmove-cell { text-decoration: none; }
    .nb-tbl tr.nb-tbl-row-done .nb-tbl-tag,
    .nb-tbl-card.nb-tbl-row-done .nb-tbl-tag { opacity: 0.45; }
    .nb-tbl-card.nb-tbl-row-done { opacity: 0.75; }

    /* ── Row reorder handle (drag on desktop, ▲▼ on touch) ── */
    /* Collapses to nothing outside edit mode so normal viewing is unchanged */
    .nb-tbl-rowmove-cell { border: none !important; width: 0; padding: 0 !important; white-space: nowrap; background: transparent !important; }
    .nb-canvas-view.editing .nb-tbl-rowmove-cell { width: 1%; padding: 0 2px !important; }
    .nb-tbl-rowmove { display: none; }
    .nb-canvas-view.editing .nb-tbl-rowmove { display: inline-flex; align-items: center; }
    .nb-tbl-rowgrip {
      background: transparent; border: none; color: var(--text-dim);
      cursor: grab; font-size: 13px; line-height: 1; padding: 2px 3px;
      touch-action: none; user-select: none;
    }
    .nb-tbl-rowgrip:hover { color: var(--text); }
    .nb-tbl-rowgrip:active { cursor: grabbing; }
    .nb-tbl-rowarrows { display: none; flex-direction: column; gap: 1px; }
    .nb-tbl-rowarrow {
      background: transparent; border: 1px solid rgba(127,127,127,0.3);
      border-radius: 4px; color: var(--text-muted);
      font-size: 10px; line-height: 1; padding: 3px 5px; cursor: pointer;
      font-family: inherit;
    }
    .nb-tbl-rowarrow:hover { color: var(--text); border-color: rgba(127,127,127,0.6); }
    .nb-tbl-rowarrow:disabled { opacity: 0.25; cursor: default; }
    /* Touch devices have no drag-and-drop worth the name — show arrows instead */
    @media (pointer: coarse) {
      /* Long-press is our context menu; iOS's own text callout must not fight it */
      .nb-canvas-view .nb-block, .nb-tbl { -webkit-touch-callout: none; }
      /* NB: do not unset the table's white-space: nowrap here. Letting cells
         wrap makes the table exactly as wide as its block, which removes the
         overflow that .nb-tbl-wrap scrolls — the columns squash instead. */
      /* Card view fixes the table, but the block keeps its stored pixel width;
         a 760px collected table would still run off a phone screen. Note this
         block is (pointer: coarse) only, without _nbHandheld()'s width test —
         deliberately: on a tablet, or a phone in landscape, the cap is roomy
         enough to be a no-op while still bounding the block to the screen. */
      .nb-block.nb-block-table { max-width: calc(100vw - 40px); }
      .nb-tbl-rowgrip { display: none; }
      .nb-tbl-rowarrows { display: flex; }
      .nb-tbl-rowarrow { padding: 6px 9px; font-size: 11px; }
      .nb-tbl-rowdel { padding: 8px 6px; font-size: 15px; }
    }
    .nb-tbl tr.nb-tbl-row-dragging { opacity: 0.4; }
    .nb-tbl tr.nb-tbl-row-over-before td { box-shadow: inset 0 2px 0 0 var(--accent); }
    .nb-tbl tr.nb-tbl-row-over-after  td { box-shadow: inset 0 -2px 0 0 var(--accent); }
    /* Card-per-row view */
    .nb-tbl-cards { display: flex; flex-direction: column; gap: 8px; }
    .nb-tbl-card {
      position: relative; background: rgba(127,127,127,0.08);
      border: 1px solid rgba(127,127,127,0.18); border-radius: 8px; padding: 8px 10px;
    }
    .nb-tbl-card-field { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
    .nb-tbl-card-label { color: var(--text-muted); font-size: 11px; min-width: 64px; flex: 0 0 auto; }
    .nb-tbl-card .nb-tbl-cellval { cursor: text; }
    .nb-tbl-card .nb-tbl-rowdel { position: absolute; top: 4px; right: 6px; }
    .nb-tbl-card .nb-tbl-rowmove { position: absolute; top: 4px; right: 30px; }
    /* Cards have no drag handle, so the arrows are the only way to reorder —
       shown with a mouse too, unlike in the table view. */
    .nb-tbl-card .nb-tbl-rowarrows { display: flex; flex-direction: row; }
    /* Card view has no table footer, so sums get their own strip */
    .nb-tbl-cards-sum {
      margin-top: 8px; padding-top: 7px;
      border-top: 1px solid rgba(127,127,127,0.25);
    }
    .nb-tbl-cards-sum-row {
      display: flex; justify-content: space-between; align-items: baseline;
      gap: 12px; font-size: 13px; padding: 2px 2px;
    }
    .nb-tbl-cards-sum-label { color: var(--text-muted); font-size: 11px; }
    .nb-tbl-cards-sum .nb-tbl-foot-sum {
      font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums;
    }
    .nb-tbl-cards-sum .nb-tbl-foot-sum.nb-tbl-foot-partial { color: var(--accent); }
    .nb-bh-item {
      display: flex; align-items: flex-start; gap: 9px;
      font-size: 15px; padding: 4px 0; color: var(--text); cursor: pointer; line-height: 1.45;
    }
    .nb-bh-item input[type=checkbox] { accent-color: #4a7c59; width: 17px; height: 17px; margin-top: 2px; flex-shrink: 0; cursor: pointer; }
    /* Plain checklist title (no accordion/collapse) — optional label */
    .nb-bh-title-plain {
      border-bottom: 1px solid rgba(104,192,96,0.18);
      cursor: text;
    }
    .nb-bh-title-plain .nb-bh-title-text:empty::before {
      content: attr(data-placeholder);
      color: rgba(160,160,160,0.45);
      font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0;
    }
    .nb-bh-title-empty { border-bottom-color: transparent; margin-bottom: 2px; }
    .nb-bh-item.checked span { text-decoration: line-through; color: var(--text-muted); }
    /* Each checklist row's text must fill the row so it's clickable even when empty */
    .nb-bh-item > span {
      flex: 1;
      min-height: 1.4em;
      min-width: 60px;
      cursor: text;
      outline: none;
      word-break: break-word;
      overflow-wrap: anywhere;
    }
    .nb-bh-item > span:empty::before {
      content: attr(data-placeholder);
      color: rgba(160,160,160,0.5);
      font-style: italic;
      pointer-events: none;
    }
    /* Hide the placeholder while editing so it doesn't overlap the caret */
    .nb-bh-item > span[contenteditable="true"]:empty::before {
      content: "";
    }
    .nb-bh-item > span[contenteditable="true"] {
      background: rgba(104,192,96,0.08);
      border-radius: 3px;
      padding: 0 3px;
      margin: 0 -3px;
    }
    .nb-bh-item-del {
      background: transparent; border: none; color: #ccc;
      font-size: 11px; cursor: pointer; padding: 0 2px; margin-left: auto;
      display: none; flex-shrink: 0; line-height: 1;
    }
    .nb-canvas-view.editing .nb-bh-item-del { display: inline-block; }
    .nb-bh-item-del:hover { color: #e53e3e; }
    .nb-bh-add-btn {
      background: transparent; border: none; color: #4a7c59;
      font-size: 12px; cursor: pointer; padding: 4px 0 1px;
      font-family: inherit; display: none; width: 100%; text-align: left;
    }
    .nb-canvas-view.editing .nb-bh-add-btn { display: block; }
    .nb-bh-add-btn:hover { color: #2d6a4f; }
    .nb-b-text { cursor: text; min-height: 2em; outline: none; user-select: text; }
    .nb-b-text[contenteditable="true"]:focus { outline: 1px solid rgba(104,211,145,0.4); border-radius: 3px; padding: 2px; }
    .nb-fmt-bar {
      position: fixed;
      background: #1a1a1a; border-radius: 8px;
      display: flex; gap: 2px; padding: 5px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.08);
      z-index: 9999; pointer-events: all;
    }
    .nb-fmt-btn {
      background: transparent; border: none; color: #bbb;
      padding: 3px 8px; font-size: 12px; cursor: pointer;
      border-radius: 4px; font-family: inherit; line-height: 1.4;
    }
    .nb-fmt-btn:hover { background: rgba(255,255,255,0.12); color: white; }
    .nb-fmt-sep { width: 1px; background: rgba(255,255,255,0.12); margin: 2px 2px; }
    .nb-fmt-fonts { position: relative; display: inline-flex; }
    .nb-font-picker {
      display: none; position: absolute; top: auto; bottom: calc(100% + 4px); left: 0;
      background: #1a1a1a; border-radius: 6px; padding: 4px;
      box-shadow: 0 4px 16px rgba(0,0,0,0.6); z-index: 200;
      flex-direction: column; gap: 2px; min-width: 100px;
    }
    .nb-fmt-fonts.open .nb-font-picker { display: flex; }
    .nb-font-picker .nb-fmt-btn { text-align: left; padding: 4px 8px; font-size: 13px; }
    .nb-link-list { display: flex; flex-direction: column; gap: 3px; }
    .nb-link-item {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      padding: 5px 7px;
      background: rgba(104,192,96,0.08); border: 1px solid rgba(104,192,96,0.15);
      border-radius: 6px; cursor: pointer;
      transition: background 0.1s; min-height: 30px;
    }
    .nb-link-item:hover { background: rgba(104,192,96,0.15); border-color: rgba(104,192,96,0.3); }
    .nb-link-icon { font-size: 13px; flex-shrink: 0; opacity: 0.75; }
    .nb-link-favicon { width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; object-fit: contain; }
    .nb-b-text ul, .nb-b-text ol { margin: 4px 0 4px 18px; padding: 0; }
    .nb-b-text li { margin: 2px 0; line-height: 1.6; }
    .nb-b-text ul li { list-style-type: disc; }
    .nb-b-text ol li { list-style-type: decimal; }
    .nb-link-title { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .nb-link-item-del, .nb-link-move {
      background: transparent; border: none; color: #bbb;
      font-size: 11px; cursor: pointer; padding: 1px 3px;
      display: none; flex-shrink: 0; border-radius: 3px; line-height: 1;
    }
    .nb-canvas-view.editing .nb-link-item-del,
    .nb-canvas-view.editing .nb-link-move { display: inline-block; }
    .nb-link-item-del:hover { color: #e53e3e; background: rgba(229,62,62,0.08); }
    .nb-link-move:hover { color: #4a7c59; background: rgba(74,124,89,0.1); }
    .nb-link-add-btn {
      background: transparent; border: 1px dashed #c8d8c8; color: #4a7c59;
      font-size: 12px; cursor: pointer; padding: 6px 10px;
      font-family: inherit; display: none; width: 100%;
      text-align: center; border-radius: 6px; margin-top: 2px;
    }
    .nb-canvas-view.editing .nb-link-add-btn { display: block; }
    .nb-link-add-btn:hover { background: #eff3ee; }
    .nb-bh-title-text { flex: 1; }
    .nb-canvas-view.editing .nb-bh-title-text { cursor: text; }
    .nb-bh-title-text[contenteditable="true"] { outline: none; background: rgba(74,124,89,0.08); border-radius: 3px; padding: 0 3px; }

    /* Canvas heading block */
    .nb-block.nb-block-h1 {
      background: transparent;
      border: none;
      border-radius: 0;
      box-shadow: none;
      padding: 8px 8px 6px;
      backdrop-filter: none;
      overflow: visible;
    }
    .nb-block.nb-block-h1:hover {
      background: rgba(255,255,255,0.02);
      border-radius: 6px;
    }
    .nb-block-h1 .nb-b-text {
      font-family: var(--nb-h1-font, 'Playfair Display', Georgia, serif);
      font-weight: var(--nb-h1-weight, 700);
      font-style:  var(--nb-h1-style, normal);
      color: var(--text);
      letter-spacing: -0.4px;
      line-height: 1.2;
      padding-bottom: 8px;          /* fixed pad — underline sits in it, offset moves it */
      position: relative;
      /* shrink to fit the actual heading text length */
      width: -moz-fit-content;
      width: fit-content;
      max-width: 100%;
      font-size: var(--nb-h1-size, clamp(20px, 9cqw, 140px));
    }
    /* All underlines render via ::after so the offset can move them freely,
       even up over the text (negative offset). */
    .nb-block-h1 .nb-b-text::after {
      content: "";
      position: absolute;
      left: 0; right: 0;
      bottom: 0;
      transform: translateY(var(--nb-h1-stroke-offset, 0px));
      pointer-events: none;
    }
    .nb-block.nb-block-h1 .nb-b-content {
      container-type: inline-size;
    }
    /* Alignment (headingAlign): the text shrink-wraps, so it is placed with
       auto margins; text-align handles the lines of a wrapped heading */
    .nb-block-h1[data-align="center"] .nb-b-text { margin-left: auto; margin-right: auto; text-align: center; }
    .nb-block-h1[data-align="right"]  .nb-b-text { margin-left: auto; text-align: right; }
    /* One-line heading: the box follows the text length instead of
       item.width. Inline-size containment would collapse a max-content box
       to zero, so it is dropped here (Auto size is frozen in JS instead). */
    .nb-block.nb-block-h1.nb-h1-oneline { width: max-content !important; }
    .nb-block.nb-block-h1.nb-h1-oneline .nb-b-content { container-type: normal; }
    .nb-block-h1.nb-h1-oneline .nb-b-text { white-space: nowrap; max-width: none; }
    .nb-block-h1.nb-h1-oneline .nb-b-res-e,
    .nb-block-h1.nb-h1-oneline .nb-b-res-se { display: none !important; }
    /* Attached heading: position follows its box (notebook.js nbSyncAttached),
       width is its own. Height is the text's, so only the side handle applies. */
    .nb-block-h1.nb-h1-attached .nb-b-res-s,
    .nb-block-h1.nb-h1-attached .nb-b-res-se { display: none !important; }
    .nb-h1-attach-badge {
      position: absolute;
      left: -20px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 12px;
      opacity: 0.55;
      pointer-events: none;
    }
    .nb-canvas-view.editing .nb-h1-attach-badge { display: block; }
    /* Phone column: one long line would run off the screen, so wrap there */
    .nb-canvas-view.stacked .nb-block.nb-block-h1.nb-h1-oneline { width: auto !important; }
    .nb-canvas-view.stacked .nb-block-h1.nb-h1-oneline .nb-b-text { white-space: normal; max-width: 100%; }
    /* ── H1 underline style variants (set via data-underline on .nb-block) ── */
    .nb-block-h1[data-underline="none"] .nb-b-text::after { display: none; }

    .nb-block-h1[data-underline="solid"] .nb-b-text::after {
      height: var(--nb-h1-stroke-thick, 1.5px);
      background: var(--nb-h1-stroke, rgba(104,192,96,0.55));
    }
    .nb-block-h1[data-underline="thick"] .nb-b-text::after {
      height: var(--nb-h1-stroke-thick, 4px);
      background: var(--nb-h1-stroke, rgba(104,192,96,0.85));
      border-radius: 1px;
    }
    .nb-block-h1[data-underline="double"] .nb-b-text::after {
      height: calc(var(--nb-h1-stroke-thick, 5px) + 2px);
      background: none;
      border-top: 1.5px solid var(--nb-h1-stroke, rgba(104,192,96,0.7));
      border-bottom: 1.5px solid var(--nb-h1-stroke, rgba(104,192,96,0.7));
    }
    .nb-block-h1[data-underline="dashed"] .nb-b-text::after {
      height: var(--nb-h1-stroke-thick, 2px);
      background: none;
      border-top: var(--nb-h1-stroke-thick, 2px) dashed var(--nb-h1-stroke, rgba(104,192,96,0.7));
    }
    .nb-block-h1[data-underline="dotted"] .nb-b-text::after {
      height: var(--nb-h1-stroke-thick, 3px);
      background: none;
      border-top: var(--nb-h1-stroke-thick, 3px) dotted var(--nb-h1-stroke, rgba(104,192,96,0.8));
    }
    /* Wavy — SVG repeat-x */
    .nb-block-h1[data-underline="wavy"] .nb-b-text::after {
      height: 6px;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 6' preserveAspectRatio='none'><path d='M0 3 Q 5 0 10 3 T 20 3' stroke='%2368c060' stroke-width='1.4' fill='none'/></svg>");
      background-repeat: repeat-x;
      background-size: 20px 6px;
    }
    /* Brush stroke — soft fading edges */
    .nb-block-h1[data-underline="brush"] .nb-b-text::after {
      height: 5px;
      background-image: linear-gradient(90deg,
        transparent 0%,
        var(--nb-h1-stroke, rgba(104,192,96,0.85)) 15%,
        var(--nb-h1-stroke, rgba(104,192,96,0.85)) 85%,
        transparent 100%);
    }
    /* Highlighter — translucent yellow stripe behind text. Sits BEHIND text,
       not below it, so it's positioned differently. */
    .nb-block-h1[data-underline="highlight"] .nb-b-text::after {
      bottom: 0;
      top: 30%;
      height: auto;
      background: rgba(255,220,60,0.55);
      z-index: -1;
      transform: translateY(var(--nb-h1-stroke-offset, 0px));
    }
    /* Marker / hand-drawn — wobbly mask */
    .nb-block-h1[data-underline="marker"] .nb-b-text::after {
      left: -2px; right: -2px;
      height: var(--nb-h1-stroke-thick, 5px);
      background-color: var(--nb-h1-stroke, rgba(104,192,96,0.85));
      -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'><path d='M4 5 C 30 4 60 6 90 5 S 150 4 196 5' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/></svg>");
      mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'><path d='M4 5 C 30 4 60 6 90 5 S 150 4 196 5' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/></svg>");
      -webkit-mask-size: 100% 100%;
      mask-size: 100% 100%;
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
    }

    /* Thickness affects border-bottom-width on flat styles */
    .nb-block-h1[data-underline="solid"]  .nb-b-text { border-bottom-width: var(--nb-h1-stroke-thick, 1.5px); }
    .nb-block-h1[data-underline="thick"]  .nb-b-text { border-bottom-width: var(--nb-h1-stroke-thick, 4px); }
    .nb-block-h1[data-underline="dashed"] .nb-b-text { border-bottom-width: var(--nb-h1-stroke-thick, 2px); }
    .nb-block-h1[data-underline="dotted"] .nb-b-text { border-bottom-width: var(--nb-h1-stroke-thick, 3px); }
    .nb-block-h1[data-underline="double"] .nb-b-text { border-bottom-width: calc(var(--nb-h1-stroke-thick, 5px) + 2px); }
    /* Color affects all border-using styles */
    .nb-block-h1[data-underline="solid"]  .nb-b-text,
    .nb-block-h1[data-underline="thick"]  .nb-b-text,
    .nb-block-h1[data-underline="dashed"] .nb-b-text,
    .nb-block-h1[data-underline="dotted"] .nb-b-text,
    .nb-block-h1[data-underline="double"] .nb-b-text { border-bottom-color: var(--nb-h1-stroke, rgba(104,192,96,0.55)); }
    /* On light pages the wavy/brush strokes need a darker default colour.
       Set the variable on .nb-block-h1 (NOT .nb-b-text) so inline styles on
       .nb-block-h1 (e.g. user-picked colour) still win over this fallback. */
    .nb-page-spiral   .nb-block-h1,
    .nb-page-dagbok   .nb-block-h1,
    .nb-page-leksikon .nb-block-h1,
    .nb-page-skoleheft .nb-block-h1,
    .nb-page-postit   .nb-block-h1,
    .nb-page-ren      .nb-block-h1 {
      --nb-h1-stroke: rgba(90,60,30,0.55);
    }
    .nb-page-spiral   .nb-block-h1[data-underline="wavy"] .nb-b-text,
    .nb-page-dagbok   .nb-block-h1[data-underline="wavy"] .nb-b-text,
    .nb-page-leksikon .nb-block-h1[data-underline="wavy"] .nb-b-text,
    .nb-page-skoleheft .nb-block-h1[data-underline="wavy"] .nb-b-text,
    .nb-page-postit   .nb-block-h1[data-underline="wavy"] .nb-b-text,
    .nb-page-ren      .nb-block-h1[data-underline="wavy"] .nb-b-text {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 6' preserveAspectRatio='none'><path d='M0 3 Q 5 0 10 3 T 20 3' stroke='%235a3c1e' stroke-width='1.4' fill='none'/></svg>");
    }
    /* When the user has chosen a custom colour on a light page, switch the
       wavy SVG to inherit from the variable too. */
    .nb-page-spiral   .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text,
    .nb-page-dagbok   .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text,
    .nb-page-leksikon .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text,
    .nb-page-skoleheft .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text,
    .nb-page-postit   .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text,
    .nb-page-ren      .nb-block-h1[data-underline="wavy"][style*="--nb-h1-stroke"] .nb-b-text {
      /* fall back to the default dark SVG since wavy uses inline SVG colour,
         not a CSS variable. Users wanting coloured strokes should use solid,
         thick, marker, dashed, dotted, double or brush. */
    }

    /* ── H1 underline style picker — small popover shown on hover/edit ── */
    .nb-h1-ulpicker {
      position: absolute;
      bottom: 100%;
      right: 0;
      display: none;
      flex-direction: column;
      gap: 8px;
      background: rgba(20,20,20,0.96);
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 10px;
      padding: 10px 12px;
      z-index: 1000;
      box-shadow: 0 12px 36px rgba(0,0,0,0.7);
      backdrop-filter: blur(12px);
      margin-bottom: 8px;
      max-height: min(70vh, 360px);
      overflow-y: auto;
      width: 320px;
      max-width: calc(100vw - 24px);
    }
    /* When flipped to below the block, swap the margin */
    .nb-h1-ulpicker.below {
      bottom: auto;
      top: 100%;
      margin-bottom: 0;
      margin-top: 8px;
    }
    /* Invisible bridge so the gap between block and picker doesn't break
       :hover when the mouse travels up into the picker. */
    .nb-h1-ulpicker::before {
      content: "";
      position: absolute;
      left: 0; right: 0;
      bottom: -10px;
      height: 10px;
    }
    .nb-h1-ulpicker.below::before {
      bottom: auto;
      top: -10px;
    }
    .nb-h1-ulpicker-row {
      display: flex;
      gap: 4px;
      align-items: center;
      flex-wrap: wrap;
    }
    .nb-h1-ulpicker-thick,
    .nb-h1-ulpicker-colors { gap: 6px; }
    /* Show only when the block has `.show-ulpicker` (dbl-click to open),
       OR while edit mode is on for the whole canvas. */
    .nb-block.nb-block-h1.show-ulpicker .nb-h1-ulpicker,
    .nb-canvas-view.editing .nb-block.nb-block-h1 .nb-h1-ulpicker {
      display: flex;
    }
    /* Hide the picker while the user is actually typing in the heading */
    .nb-block.nb-block-h1:has(.nb-b-text[contenteditable="true"]:focus) .nb-h1-ulpicker {
      display: none;
    }
    .nb-h1-ulbtn,
    .nb-h1-thickbtn,
    .nb-h1-colorbtn {
      background: transparent;
      border: 1px solid transparent;
      border-radius: 4px;
      color: rgba(255,255,255,0.75);
      cursor: pointer;
      font-family: inherit;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
    }
    .nb-h1-ulbtn { width: 30px; height: 24px; }
    .nb-h1-thickbtn { width: 30px; height: 18px; padding: 0 4px; color: rgba(255,255,255,0.85); }
    .nb-h1-thickbtn span { width: 100%; display: block; }
    .nb-h1-colorbtn {
      width: 22px; height: 22px;
      border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.18);
    }
    .nb-h1-ulbtn:hover,
    .nb-h1-thickbtn:hover { background: rgba(255,255,255,0.1); color: #fff; }
    .nb-h1-colorbtn:hover { transform: scale(1.1); }
    .nb-h1-ulbtn.active,
    .nb-h1-thickbtn.active {
      background: rgba(104,192,96,0.18);
      border-color: rgba(104,192,96,0.5);
      color: #fff;
    }
    .nb-h1-colorbtn.active {
      border-color: #fff;
      box-shadow: 0 0 0 2px rgba(104,192,96,0.5);
    }
    .nb-h1-ulbtn svg { display: block; width: 18px; height: 10px; }

    /* Offset (avstand fra tekst) — stepper row */
    .nb-h1-ulpicker-offset { gap: 4px; padding: 0 2px; }
    .nb-h1-offset-label {
      font-size: 11px;
      color: rgba(255,255,255,0.55);
      margin-right: auto;
      letter-spacing: 0.02em;
    }
    .nb-h1-offsetbtn {
      background: rgba(255,255,255,0.06);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 4px;
      color: rgba(255,255,255,0.8);
      cursor: pointer;
      font-family: inherit;
      width: 22px; height: 22px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      line-height: 1;
      padding: 0;
    }
    .nb-h1-offsetbtn:hover { background: rgba(255,255,255,0.14); color: #fff; }
    .nb-h1-offset-val {
      font-size: 11px;
      color: rgba(255,255,255,0.8);
      font-family: 'Fira Code', monospace;
      min-width: 26px;
      text-align: center;
    }
    .nb-h1-offset-reset { width: 22px; opacity: 0.6; }
    .nb-h1-offset-reset:hover { opacity: 1; }

    /* Section grouping inside the picker — stacked rows with subtle dividers */
    .nb-h1-section {
      display: flex;
      flex-direction: column;
      gap: 6px;
      min-width: 0;
    }
    .nb-h1-section + .nb-h1-section {
      border-top: 1px solid rgba(255,255,255,0.08);
      padding-top: 8px;
    }
    .nb-h1-section-title {
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.5);
      padding: 0 2px;
    }

    /* Font / size / weight controls */
    .nb-h1-ulpicker-fonts {
      flex-wrap: wrap;
      gap: 3px;
    }
    .nb-h1-fontbtn {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 4px;
      color: rgba(255,255,255,0.8);
      cursor: pointer;
      padding: 3px 9px;
      font-size: 11px;
      line-height: 1.2;
    }
    .nb-h1-fontbtn:hover { background: rgba(255,255,255,0.12); color: #fff; }
    .nb-h1-fontbtn.active {
      background: rgba(104,192,96,0.18);
      border-color: rgba(104,192,96,0.5);
      color: #fff;
    }
    .nb-h1-sizegroup, .nb-h1-weightgroup, .nb-h1-thickgroup, .nb-h1-colorgroup {
      display: inline-flex;
      gap: 2px;
      align-items: center;
    }
    .nb-h1-sizebtn, .nb-h1-wbtn, .nb-h1-linebtn, .nb-h1-alignbtn {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 4px;
      color: rgba(255,255,255,0.8);
      cursor: pointer;
      padding: 2px 7px;
      font-size: 11px;
      min-width: 26px;
      height: 22px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .nb-h1-sizebtn:hover, .nb-h1-wbtn:hover, .nb-h1-linebtn:hover, .nb-h1-alignbtn:hover { background: rgba(255,255,255,0.12); color: #fff; }
    .nb-h1-sizebtn.active, .nb-h1-wbtn.active, .nb-h1-linebtn.active, .nb-h1-alignbtn.active {
      background: rgba(104,192,96,0.18);
      border-color: rgba(104,192,96,0.5);
      color: #fff;
    }
    .nb-h1-wbtn b, .nb-h1-wbtn i { font-style: inherit; font-weight: inherit; }
    .nb-h1-wbtn:first-of-type b { font-weight: 700; }
    .nb-h1-wbtn:last-of-type i  { font-style: italic; }

    /* Minimap — overview of the page with a green «you are here» viewport rect */
    .nb-minimap {
      position: fixed;
      bottom: 22px; right: 84px;
      background: rgba(10,8,4,0.5);
      /* a clearer frame around the whole page */
      border: 1px solid rgba(190,172,130,0.4);
      border-radius: 6px;
      box-shadow: 0 3px 12px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(0,0,0,0.25);
      z-index: 205;
      overflow: hidden;
      cursor: grab;
      opacity: 0.74;
      transition: opacity 0.45s ease;
    }
    .nb-minimap.nb-minimap-idle { opacity: 0; }       /* fade out when idle */
    .nb-minimap:hover { opacity: 0.96; transition: opacity 0.15s ease; }
    .nb-minimap.nb-minimap-grabbing { cursor: grabbing; opacity: 0.96; }
    .nb-minimap-box {
      position: absolute;
      border-radius: 1px;
      opacity: 0.62;
      pointer-events: none;
    }
    .nb-minimap-view {
      position: absolute;
      border: 1.5px solid #4ade80;
      background: rgba(74,222,128,0.16);
      border-radius: 1px;
      pointer-events: none;
      box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
    }
    @media (max-width: 600px) { .nb-minimap { right: 78px; bottom: 18px; } }
    .nb-cv-fab {
      position: fixed;
      bottom: calc(24px + env(safe-area-inset-bottom, 0px));
      right:  calc(24px + env(safe-area-inset-right, 0px));
      width: 48px; height: 48px;
      border-radius: 50%;
      background: var(--accent);
      color: white;
      border: none;
      font-size: 26px;
      line-height: 1;
      cursor: pointer;
      box-shadow: 0 4px 16px rgba(74,124,89,0.45);
      z-index: 210;
      display: flex; align-items: center; justify-content: center;
    }
    .nb-cv-fab:hover { background: #3d6b4c; }
    .nb-cv-add-menu {
      position: fixed;
      bottom: 80px; right: 20px;
      background: var(--surface);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      padding: 6px 0;
      z-index: 210;
      box-shadow: 0 8px 24px rgba(0,0,0,0.35);
      min-width: 160px;
    }
    .nb-cv-add-menu button {
      display: flex; align-items: center; gap: 10px;
      width: 100%;
      background: transparent; border: none;
      color: var(--text);
      padding: 9px 16px;
      font-size: 13px;
      cursor: pointer;
      font-family: inherit;
      text-align: left;
    }
    .nb-cv-add-menu button:hover { background: rgba(255,255,255,0.06); }
    .nb-ctx-menu {
      position: fixed;
      background: var(--surface);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      padding: 6px 0;
      z-index: 400;
      box-shadow: 0 8px 24px rgba(0,0,0,0.45);
      min-width: 200px;
      max-height: 70vh;
      overflow-y: auto;
    }
    .nb-ctx-menu button {
      display: flex; align-items: center; gap: 10px;
      width: 100%;
      background: transparent; border: none;
      color: var(--text);
      padding: 9px 16px;
      font-size: 13px;
      cursor: pointer;
      font-family: inherit;
      text-align: left;
    }
    .nb-ctx-menu button:hover { background: rgba(255,255,255,0.06); }
    .nb-ctx-title {
      padding: 4px 16px 6px;
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.4);
    }
    .nb-ctx-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 5px 0; }
    .nb-ctx-sub-arrow { margin-left: auto; opacity: 0.5; font-size: 10px; }
    .nb-ctx-submenu { display: none; padding: 2px 0 4px 14px; }
    .nb-ctx-sub.open > .nb-ctx-submenu { display: block; }
    .nb-ctx-sub.open > button .nb-ctx-sub-arrow { transform: rotate(90deg); }
    .nb-ctx-empty { padding: 6px 16px 8px; font-size: 12px; color: rgba(255,255,255,0.35); font-style: italic; }
    .nb-ctx-swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 8px; }
    .nb-ctx-menu .nb-ctx-swatch {
      width: 22px; height: 22px;
      padding: 0;
      border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.15);
      flex: 0 0 auto;
    }
    .nb-ctx-menu .nb-ctx-swatch.active { border-color: #68d391; }

    /* Tag-velger ("Samle like tags i tabell") — egen, litt lysere overflate enn
       standard kontekstmeny, så den ikke glir sammen med tabellen bak. */
    .nb-tagpick-panel {
      background: var(--surface-3);
      border: 1px solid rgba(123,104,240,0.35);
      box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(123,104,240,0.08);
      min-width: 220px;
    }
    .nb-tagpick-list { max-height: 260px; overflow-y: auto; padding: 2px 0; }
    .nb-tagpick-row {
      display: flex; align-items: center; gap: 8px;
      padding: 7px 16px; font-size: 12.5px; color: var(--text);
      cursor: pointer;
    }
    .nb-tagpick-row:hover { background: rgba(255,255,255,0.06); }
    .nb-tagpick-row input { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
    .nb-tagpick-count { color: var(--text-muted); font-size: 11px; margin-left: auto; flex: 0 0 auto; }
    /* ── Row editing + tag suggestions ─────────────────────── */
    .nb-tbl-rowdone {
      background: var(--accent); border: none; border-radius: 5px;
      color: #fff; cursor: pointer; font: inherit;
      font-size: 13px; line-height: 1; padding: 5px 9px; margin-left: 4px;
    }
    .nb-tbl-card .nb-tbl-rowdone { position: absolute; top: 4px; right: 6px; }
    @media (pointer: coarse) { .nb-tbl-rowdone { padding: 9px 13px; font-size: 15px; } }
    .nb-tbl tr.nb-tbl-row-editing td,
    .nb-tbl-card.nb-tbl-row-editing { background: rgba(104,211,145,0.07); }
    /* An open row is never struck through — you are editing it, not done with it */
    .nb-tbl tr.nb-tbl-row-editing td.nb-tbl-td,
    .nb-tbl-card.nb-tbl-row-editing .nb-tbl-card-field { text-decoration: none !important; }
    .nb-tbl-card.nb-tbl-row-editing { padding-top: 30px; }
    /* Card fields are a label + value row; the editor should take the rest */
    .nb-tbl-card-field .nb-tbl-input { flex: 1 1 auto; min-width: 0; }

    /* Hand-built because Safari on iOS effectively ignores <datalist>, and the
       phone is exactly where the suggestions matter most. */
    /* Anchored to the cell being edited, so it cannot drift away from the
       field the way a viewport-positioned list did. */
    .nb-tag-suggest {
      position: absolute; top: 100%; left: 0; margin-top: 2px;
      min-width: 100%; z-index: 10000;
      background: var(--surface, #1a1a24);
      border: 1px solid rgba(127,127,127,0.35);
      border-radius: 8px; overflow: hidden;
      box-shadow: 0 6px 20px rgba(0,0,0,0.5);
      max-height: 220px; overflow-y: auto;
      font-size: 13px;
    }
    .nb-tag-suggest-item {
      padding: 8px 12px; cursor: pointer; color: var(--text);
      white-space: nowrap;
    }
    .nb-tag-suggest.above { top: auto; bottom: 100%; margin: 0 0 2px; }
    .nb-tag-suggest-item.active,
    .nb-tag-suggest-item:hover { background: rgba(104,211,145,0.18); }
    /* The cell is the anchor while it holds an editor */
    /* position only — display:block on a <td> drops it out of the table layout
       and collapses the row into a single column. */
    .nb-cell-editing { position: relative; }
    .nb-tbl-card-field .nb-cell-editing { display: block; flex: 1 1 auto; min-width: 0; }
    /* Both of these clip their children, which would cut the list off */
    .nb-block.nb-row-editing-host { overflow: visible; }
    .nb-block.nb-row-editing-host .nb-tbl-wrap { overflow: visible; }
    @media (pointer: coarse) { .nb-tag-suggest-item { padding: 12px 14px; font-size: 15px; } }

    .nb-colpick-list { max-height: 180px; }
    .nb-colpick-name { font-size: 12px; color: var(--text); }
    .nb-tagpick-row input:disabled { opacity: 0.5; }
    .nb-tagpick-btn {
      display: block; width: calc(100% - 32px); margin: 8px 16px 6px;
      background: var(--accent); color: #fff; border: none; border-radius: 6px;
      padding: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
    }
    .nb-tagpick-btn:disabled { opacity: 0.4; cursor: default; }
    .nb-ctx-check { display: inline-block; width: 14px; color: #68d391; }

    /* ── Per-block styles (chosen via box menu) ─────────────── */
    .nb-cv-inner .nb-block.nb-bk-whiteboard {
      background: #eef1f4;
      border: 1px solid #c9d2da;
      box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    }
    .nb-cv-inner .nb-block.nb-bk-whiteboard .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-whiteboard .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-whiteboard .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-whiteboard .nb-link-title { color: #1d3346; }
    .nb-cv-inner .nb-block.nb-bk-whiteboard .nb-bh-title { color: #1d3346; border-bottom-color: rgba(29,51,70,0.3); }

    .nb-cv-inner .nb-block.nb-bk-papir {
      background: #f5efdc;
      border: 1px solid #d8cfb4;
      box-shadow: 2px 3px 8px rgba(0,0,0,0.35);
      transform: rotate(-0.5deg);
    }
    .nb-cv-inner .nb-block.nb-bk-papir .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-papir .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-papir .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-papir .nb-link-title { color: #3a3322; }
    .nb-cv-inner .nb-block.nb-bk-papir .nb-bh-title { color: #5a4a22; border-bottom-color: rgba(90,74,34,0.35); }

    .nb-cv-inner .nb-block.nb-bk-tre {
      background:
        repeating-linear-gradient(90deg, rgba(0,0,0,0.07) 0 2px, transparent 2px 38px),
        linear-gradient(180deg, #7a5230, #6b4626 55%, #75502e);
      border: 1px solid #4e331b;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 3px 10px rgba(0,0,0,0.45);
    }
    .nb-cv-inner .nb-block.nb-bk-tre .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-tre .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-tre .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-tre .nb-link-title { color: #f7ecd9; }
    .nb-cv-inner .nb-block.nb-bk-tre .nb-bh-title { color: #ffe9c4; border-bottom-color: rgba(255,233,196,0.35); }

    .nb-cv-inner .nb-block.nb-bk-glass {
      background: rgba(255,255,255,0.07);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border: 1px solid rgba(255,255,255,0.22);
      box-shadow: 0 4px 18px rgba(0,0,0,0.35);
    }
    .nb-cv-inner .nb-block.nb-bk-glass .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-glass .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-glass .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-glass .nb-link-title { color: var(--text); }
    .nb-cv-inner .nb-block.nb-bk-glass .nb-bh-title { color: var(--text); border-bottom-color: rgba(255,255,255,0.3); }

    /* ── Per-block color (chosen via box menu) ──────────────── */
    .nb-cv-inner .nb-block.nb-has-color {
      background: var(--nb-bk);
      border-color: rgba(0,0,0,0.18);
    }
    .nb-cv-inner .nb-block.nb-has-color .nb-b-text,
    .nb-cv-inner .nb-block.nb-has-color .nb-b-content,
    .nb-cv-inner .nb-block.nb-has-color .nb-bh-item,
    .nb-cv-inner .nb-block.nb-has-color .nb-link-title { color: #20261c; }
    .nb-cv-inner .nb-block.nb-has-color .nb-bh-title { color: #33401f; border-bottom-color: rgba(0,0,0,0.3); }

    /* Tretavle + color: wood stays, color becomes the frame */
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color {
      background:
        repeating-linear-gradient(90deg, rgba(0,0,0,0.07) 0 2px, transparent 2px 38px),
        linear-gradient(180deg, #7a5230, #6b4626 55%, #75502e);
      border: 2px solid var(--nb-bk);
    }
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color .nb-link-title { color: #f7ecd9; }
    .nb-cv-inner .nb-block.nb-bk-tre.nb-has-color .nb-bh-title { color: #ffe9c4; border-bottom-color: rgba(255,233,196,0.35); }

    /* Glass + color: translucent tint, keep light text */
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color {
      background: color-mix(in srgb, var(--nb-bk) 25%, rgba(20,25,20,0.35));
    }
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color .nb-b-text,
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color .nb-b-content,
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color .nb-bh-item,
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color .nb-link-title { color: var(--text); }
    .nb-cv-inner .nb-block.nb-bk-glass.nb-has-color .nb-bh-title { color: var(--text); }


    /* ── Notebook DOCUMENT layout ──────────────────────────── */
    .nb-doc-view {
      position: fixed;
      inset: 0;
      z-index: 200;
      display: flex;
      flex-direction: column;
      background: var(--bg);
      animation: nbFadeIn 0.18s ease;
      /* Same safe-area reasoning as .nb-canvas-view above */
      padding-top:   env(safe-area-inset-top, 0px);
      padding-left:  env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
      box-sizing: border-box;
    }
    .nb-doc-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 20px 16px 80px;
    }
    .nb-doc-content {
      max-width: 860px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    /* Document layout — turn the content column into a real paper sheet
       when a style/paper has been applied. */
    .nb-doc-content.nb-doc-page {
      padding: 56px 64px 80px;
      border-radius: 3px 3px 10px 10px;
      position: relative;
      isolation: isolate;
      box-shadow:
        0 0 0 1px rgba(255,255,255,0.04),
        0 1px 0 rgba(255,255,255,0.06) inset,
        0 30px 70px rgba(0,0,0,0.55),
        0 8px 18px rgba(0,0,0,0.45);
      margin-top: 10px;
    }
    .nb-doc-scroll {
      background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(60,45,25,0.22) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 50% 100%, rgba(0,0,0,0.4) 0%, transparent 70%),
        #060604;
    }
    /* ── Document themes ──────────────────────────────────────── */
    .nb-doc-theme-papir .nb-doc-content {
      background: #faf8f3;
      color: #1a1810;
    }
    .nb-doc-theme-papir .nb-doc-block-text { color: #1a1810; }
    .nb-doc-theme-papir .nb-doc-block-heading .nb-doc-block-text { color: #0d0c08; }
    .nb-doc-theme-papir .nb-doc-block-link { border-color: rgba(80,60,30,0.18); }
    .nb-doc-theme-papir .nb-doc-empty { color: rgba(60,40,20,0.55); }
    .nb-doc-block {
      padding: 6px 0 6px 24px;
      position: relative;
    }
    .nb-doc-block-text {
      font-size: 15px;
      line-height: 1.65;
      color: var(--text);
      outline: none;
      min-height: 1.5em;
      white-space: pre-wrap;
      word-wrap: break-word;
    }
    .nb-doc-block-text:empty::before {
      content: attr(data-placeholder);
      color: var(--text-dim);
      font-style: italic;
      pointer-events: none;
    }
    .nb-doc-block-text[contenteditable="true"]:focus {
      cursor: text;
    }
    .nb-doc-block-text ul, .nb-doc-block-text ol { margin: 4px 0 4px 22px; padding: 0; }
    .nb-doc-block-text li { margin: 2px 0; line-height: 1.6; }
    .nb-doc-block-heading {
      padding: 20px 0 4px 24px;
    }
    .nb-doc-block-heading .nb-doc-block-text {
      font-family: 'Playfair Display', Georgia, serif;
      font-weight: 700;
      font-size: 19px;
      color: var(--text);
      letter-spacing: -0.3px;
    }
    .nb-doc-block-link {
      padding: 0;
      overflow: hidden;
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 8px;
      margin: 4px 0;
    }
    .nb-doc-link-item {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 14px 16px;
      cursor: pointer;
      text-decoration: none;
      color: var(--text);
      transition: background 0.1s;
    }
    .nb-doc-link-item + .nb-doc-link-item {
      border-top: 1px solid rgba(255,255,255,0.05);
    }
    .nb-doc-link-item:hover { background: rgba(255,255,255,0.045); }
    .nb-doc-link-favwrap {
      width: 36px; height: 36px;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 7px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    .nb-doc-link-favicon { width: 18px; height: 18px; border-radius: 3px; }
    .nb-doc-link-icon { font-size: 16px; opacity: 0.7; }
    .nb-doc-link-info {
      flex: 1;
      min-width: 0;
      display: flex; flex-direction: column;
      gap: 2px;
    }
    .nb-doc-link-title {
      font-size: 14px; font-weight: 600;
      color: var(--text);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      line-height: 1.3;
    }
    .nb-doc-link-domain {
      font-size: 12px; color: var(--text-muted);
      font-family: 'Fira Code', monospace;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .nb-doc-link-arrow {
      font-size: 14px;
      color: var(--text-dim);
      opacity: 0;
      transition: opacity 0.15s, transform 0.15s;
      flex-shrink: 0;
    }
    .nb-doc-link-item:hover .nb-doc-link-arrow {
      opacity: 0.8;
      transform: translate(2px, -2px);
    }
    .nb-doc-link-row {
      position: relative;
    }
    .nb-doc-link-row + .nb-doc-link-row {
      border-top: 1px solid rgba(255,255,255,0.05);
    }
    .nb-doc-link-edit {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      right: 44px;
      background: rgba(0,0,0,0.3);
      border: 1px solid rgba(255,255,255,0.08);
      color: var(--text-dim);
      width: 26px; height: 26px;
      border-radius: 5px;
      font-size: 12px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.15s, color 0.15s;
      font-family: inherit;
    }
    .nb-doc-link-row:hover .nb-doc-link-edit { opacity: 1; }
    .nb-doc-link-edit:hover { color: var(--accent); border-color: var(--accent); }
    .nb-doc-link-add {
      width: 100%;
      background: transparent;
      border: none;
      color: var(--text-muted);
      padding: 9px 14px;
      font-size: 12px;
      font-family: inherit;
      cursor: pointer;
      text-align: center;
      border-top: 1px solid rgba(255,255,255,0.04);
    }
    .nb-doc-link-add:hover { color: var(--accent); background: rgba(255,255,255,0.03); }
    .nb-doc-block-image {
      padding: 0;
      overflow: hidden;
    }
    .nb-doc-block-image img {
      display: block;
      width: 100%;
      max-height: 420px;
      object-fit: contain;
      background: #0a0a0a;
    }
    .nb-doc-checklist { display: flex; flex-direction: column; gap: 2px; }
    .nb-doc-check-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 6px 4px;
      border-radius: 4px;
    }
    .nb-doc-check-item:hover { background: rgba(255,255,255,0.025); }
    .nb-doc-check-item input[type=checkbox] {
      width: 16px; height: 16px;
      margin-top: 3px;
      accent-color: var(--accent);
      flex-shrink: 0; cursor: pointer;
    }
    .nb-doc-check-text {
      flex: 1; font-size: 14px; color: var(--text);
      line-height: 1.6; outline: none;
    }
    .nb-doc-check-item.checked .nb-doc-check-text {
      text-decoration: line-through;
      color: var(--text-muted);
    }
    .nb-doc-check-del {
      opacity: 0;
      background: none; border: none;
      color: var(--text-dim);
      font-size: 12px;
      cursor: pointer;
      padding: 0 4px;
      flex-shrink: 0;
      transition: opacity 0.15s, color 0.15s;
      font-family: inherit;
    }
    .nb-doc-check-item:hover .nb-doc-check-del { opacity: 1; }
    .nb-doc-check-del:hover { color: var(--danger); }
    .nb-doc-check-add {
      background: transparent; border: none;
      color: var(--accent);
      font-size: 13px;
      cursor: pointer;
      padding: 6px 0 2px;
      font-family: inherit;
      align-self: flex-start;
    }
    .nb-doc-check-add:hover { opacity: 0.8; }
    .nb-doc-block-del {
      position: absolute;
      top: 8px; right: 8px;
      background: rgba(0,0,0,0.3);
      border: 1px solid rgba(255,255,255,0.08);
      color: var(--text-dim);
      width: 22px; height: 22px;
      border-radius: 4px;
      font-size: 11px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.15s, color 0.15s;
      font-family: inherit;
      line-height: 1;
    }
    .nb-doc-block:hover .nb-doc-block-del { opacity: 1; }
    .nb-doc-block-del:hover { color: var(--danger); border-color: var(--danger); }
    .nb-doc-block-drag {
      position: absolute;
      top: 8px; left: -22px;
      width: 18px; height: 22px;
      color: var(--text-dim);
      font-size: 13px;
      cursor: grab;
      opacity: 0;
      display: flex; align-items: center; justify-content: center;
      transition: opacity 0.15s;
      user-select: none;
    }
    .nb-doc-block:hover .nb-doc-block-drag { opacity: 0.7; }
    .nb-doc-block-drag:active { cursor: grabbing; }
    .nb-doc-block.dragging {
      opacity: 0.4;
    }
    .nb-doc-block.drag-target-before {
      box-shadow: 0 -3px 0 0 var(--accent);
    }
    .nb-doc-block.drag-target-after {
      box-shadow: 0 3px 0 0 var(--accent);
    }
    .nb-doc-empty {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-muted);
      font-size: 14px;
    }
    .nb-doc-empty-icon {
      font-size: 48px;
      margin-bottom: 14px;
      opacity: 0.5;
    }


    /* Background color picker */
    .nb-bg-btn {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 6px;
      width: 28px; height: 28px;
      cursor: pointer;
      padding: 0;
      display: inline-flex; align-items: center; justify-content: center;
      position: relative;
    }
    .nb-bg-btn:hover { background: rgba(255,255,255,0.1); }
    .nb-bg-swatch {
      width: 16px; height: 16px;
      border-radius: 50%;
      border: 1px solid rgba(255,255,255,0.2);
    }
    .nb-bg-menu {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      background: var(--surface-2);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 12px;
      box-shadow: 0 8px 24px rgba(0,0,0,0.5);
      z-index: 300;
      min-width: 220px;
    }
    .nb-bg-menu-title {
      font-size: 11px;
      color: var(--text-muted);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      font-weight: 600;
      margin-bottom: 8px;
    }
    .nb-bg-grid {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 6px;
    }
    .nb-bg-color {
      aspect-ratio: 1;
      border-radius: 6px;
      cursor: pointer;
      border: 2px solid transparent;
      transition: transform 0.1s, border-color 0.1s;
    }
    .nb-bg-color:hover { transform: scale(1.1); }
    .nb-bg-color.selected { border-color: #fff; }
    .nb-bg-custom-row {
      display: flex; align-items: center; gap: 8px;
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid var(--border);
      font-size: 12px;
      color: var(--text-muted);
    }
    .nb-bg-custom-input {
      width: 36px; height: 28px;
      border: none; padding: 0; cursor: pointer;
      background: transparent; border-radius: 4px;
    }


    /* ── Layout chooser in modal ───────────────────────────── */
    .nb-modal-layout-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 20px;
    }
    .nb-modal-layout-card {
      background: var(--surface);
      border: 2px solid var(--border);
      border-radius: 10px;
      padding: 14px 12px;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
    }
    .nb-modal-layout-card:hover { border-color: var(--border-light); }
    .nb-modal-layout-card.selected {
      border-color: var(--accent);
      background: var(--accent-dim);
    }
    .nb-modal-layout-icon { font-size: 26px; margin-bottom: 8px; line-height: 1; }
    .nb-modal-layout-name { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
    .nb-modal-layout-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }


    /* ── Notebook modal ─────────────────────────────────────── */
    .nb-modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.78);
      backdrop-filter: blur(6px);
      z-index: 200;
      display: flex; align-items: center; justify-content: center;
      padding: 20px;
    }
    .nb-modal {
      background: var(--surface-2);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-lg);
      padding: 28px 24px 22px;
      width: 100%; max-width: 500px;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: 0 32px 80px rgba(0,0,0,0.65);
    }
    .nb-modal-title {
      font-size: 17px; font-weight: 700;
      letter-spacing: -0.3px; margin-bottom: 6px;
    }
    .nb-modal-step-indicator {
      font-size: 11px; color: var(--text-dim);
      font-family: 'Fira Code', monospace;
      margin-bottom: 22px;
    }
    .nb-modal-step { display: none; }
    .nb-modal-step.active { display: block; }

    /* Step 1 — name + emoji */
    .nb-modal-preview-emoji {
      font-size: 48px;
      text-align: center;
      margin-bottom: 12px;
      line-height: 1;
      min-height: 56px;
    }
    .nb-modal-emoji-grid {
      display: flex; flex-wrap: wrap; gap: 6px;
      margin: 12px 0;
    }
    .nb-modal-emoji-btn {
      font-size: 22px;
      background: var(--surface);
      border: 2px solid transparent;
      border-radius: 6px;
      width: 40px; height: 40px;
      cursor: pointer;
      transition: border-color 0.1s, transform 0.1s;
      display: flex; align-items: center; justify-content: center;
    }
    .nb-modal-emoji-btn:hover { transform: scale(1.15); }
    .nb-modal-emoji-btn.selected { border-color: var(--accent); background: var(--accent-dim); }
    .nb-modal-emoji-label {
      font-size: 11px; color: var(--text-dim);
      font-family: 'Fira Code', monospace;
      margin: 10px 0 4px;
    }
    .nb-modal-emoji-custom {
      width: 52px; padding: 6px 8px;
      background: var(--surface);
      border: 1px solid var(--border-light);
      border-radius: var(--radius);
      color: var(--text);
      font-size: 18px; text-align: center;
      font-family: inherit;
    }
    .nb-modal-emoji-custom:focus { outline: none; border-color: var(--accent); }

    /* Step 2 — style picker */
    .nb-modal-style-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      gap: 10px;
      margin: 4px 0;
    }
    .nb-modal-style-card {
      border: 2px solid var(--border);
      border-radius: 6px;
      padding: 12px 8px 8px;
      cursor: pointer;
      text-align: center;
      transition: border-color 0.15s;
      font-size: 12px;
      position: relative;
      overflow: hidden;
    }
    .nb-modal-style-card:hover { border-color: var(--accent); }
    .nb-modal-style-card.selected { border-color: var(--accent); background: var(--accent-dim) !important; }
    .nb-modal-style-card-preview {
      font-size: 28px; margin-bottom: 5px; display: block;
    }
    .nb-modal-style-card-name {
      font-size: 11px; color: var(--text-muted);
    }

    /* Step 3 — color + paper */
    .nb-modal-color-row {
      display: flex; flex-wrap: wrap; gap: 8px;
      margin: 8px 0 14px;
    }
    .nb-modal-color-swatch {
      width: 32px; height: 32px;
      border-radius: 50%;
      cursor: pointer;
      border: 3px solid transparent;
      transition: transform 0.1s, border-color 0.1s;
    }
    .nb-modal-color-swatch:hover { transform: scale(1.15); }
    .nb-modal-color-swatch.selected { border-color: #fff; }
    .nb-modal-color-custom {
      width: 32px; height: 32px;
      border-radius: 50%;
      border: 2px dashed var(--border-light);
      cursor: pointer;
      padding: 0; overflow: hidden;
      background: none;
      display: flex; align-items: center; justify-content: center;
    }
    .nb-modal-color-custom input[type="color"] {
      opacity: 0; width: 100%; height: 100%; cursor: pointer;
    }
    .nb-modal-paper-row {
      display: flex; gap: 10px; margin: 8px 0;
    }
    .nb-modal-paper-btn {
      flex: 1;
      padding: 8px 4px;
      border: 2px solid var(--border);
      border-radius: 6px;
      cursor: pointer;
      font-size: 10px;
      color: var(--text-muted);
      background: var(--surface);
      text-align: center;
      transition: border-color 0.15s;
      font-family: inherit;
    }
    .nb-modal-paper-btn:hover { border-color: var(--accent); }
    .nb-modal-paper-btn.selected { border-color: var(--accent); color: var(--text); }
    .nb-modal-paper-icon { font-size: 16px; display: block; margin-bottom: 3px; }

    /* Modal footer */
    .nb-modal-footer {
      display: flex; justify-content: space-between; align-items: center;
      margin-top: 24px; padding-top: 16px;
      border-top: 1px solid var(--border);
    }
    .nb-modal-footer-right { display: flex; gap: 10px; }

    /* ── Project switcher modal ─────────────────────────────── */
    .proj-switcher-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.72);
      backdrop-filter: blur(6px);
      z-index: 100;
      display: flex; align-items: center; justify-content: center; padding: 20px;
    }
    .proj-switcher {
      background: var(--surface-2); border: 1px solid var(--border-light);
      border-radius: var(--radius-lg); padding: 28px;
      width: 100%; max-width: 480px;
      box-shadow: 0 32px 80px rgba(0,0,0,0.6);
      max-height: 80vh; overflow-y: auto;
    }
    .proj-switcher-title {
      font-size: 18px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 20px;
    }
    .proj-list-item {
      display: flex; align-items: center; justify-content: space-between;
      padding: 13px 16px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      margin-bottom: 8px;
      gap: 12px;
    }
    .proj-list-item.active-proj {
      border-color: var(--accent);
      background: var(--accent-dim);
    }
    .proj-list-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
    .proj-list-name { font-weight: 600; font-size: 14px; }
    .proj-list-meta { font-size: 12px; color: var(--text-dim); }
    .proj-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
    .proj-switcher-footer {
      display: flex; justify-content: space-between; align-items: center;
      margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
    }
    .template-picker {
      position: absolute;
      right: 0;
      top: calc(100% + 4px);
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.4);
      min-width: 240px;
      z-index: 1000;
      overflow: hidden;
    }
    .template-picker-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 14px;
      cursor: pointer;
      font-size: 14px;
      gap: 8px;
    }
    .template-picker-item:hover { background: var(--surface-3); }
    .template-picker-item-name { flex: 1; }
    .template-picker-del {
      background: none; border: none; cursor: pointer;
      color: var(--text-dim); font-size: 13px; padding: 0 2px;
      opacity: 0;
    }
    .template-picker-item:hover .template-picker-del { opacity: 1; }
    .template-picker-del:hover { color: var(--danger); }
    .template-picker-divider { border-top: 1px solid var(--border); margin: 4px 0; }
    .template-picker-save {
      padding: 10px 14px;
      font-size: 13px;
      color: var(--accent);
      cursor: pointer;
    }
    .template-picker-save:hover { background: var(--surface-3); }

    /* ── Innboks ──────────────────────────────────────────── */
    .inbox-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 18px;
      height: 18px;
      padding: 0 5px;
      margin-left: 5px;
      background: var(--accent);
      color: #fff;
      border-radius: 9px;
      font-size: 11px;
      font-weight: 700;
      line-height: 1;
      vertical-align: middle;
    }

    .inbox-item {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 14px 16px;
      margin-bottom: 10px;
      position: relative;
    }
    .inbox-item-meta {
      font-size: 12px;
      color: var(--text-muted);
      margin-bottom: 6px;
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .inbox-item-type {
      font-size: 11px;
      background: var(--surface-3);
      border-radius: 4px;
      padding: 1px 6px;
      color: var(--text-dim);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .inbox-item-content {
      font-size: 15px;
      line-height: 1.55;
      color: var(--text);
      margin-bottom: 10px;
      word-break: break-word;
    }
    .inbox-item-voice-label {
      font-size: 11px;
      color: var(--text-muted);
      margin-bottom: 4px;
    }
    .inbox-url-card {
      display: block;
      background: var(--surface-3);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 12px;
      text-decoration: none;
      color: var(--text);
      margin-bottom: 10px;
    }
    .inbox-url-card:hover { border-color: var(--accent); }
    .inbox-url-href { font-size: 12px; color: var(--accent); margin-bottom: 4px; word-break: break-all; }
    .inbox-url-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
    .inbox-url-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
    .inbox-item-img  { max-width: 240px; border-radius: var(--radius-sm); margin-bottom: 10px; display: block; }

    .inbox-actions {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }
    .inbox-action-btn {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 5px 12px;
      border: 1px solid var(--border-light);
      background: var(--surface-3);
      color: var(--text-muted);
      border-radius: var(--radius-sm);
      font-size: 13px;
      cursor: pointer;
    }
    .inbox-action-btn:hover { color: var(--text); border-color: var(--text-dim); }
    .inbox-action-btn.done  { color: var(--success); border-color: var(--success); }

    .inbox-nb-picker {
      margin-top: 10px;
      background: var(--surface-3);
      border: 1px solid var(--border-light);
      border-radius: var(--radius-sm);
      padding: 10px;
    }
    .inbox-nb-picker p {
      font-size: 12px;
      color: var(--text-muted);
      margin-bottom: 8px;
    }
    .inbox-nb-btn {
      display: block;
      width: 100%;
      text-align: left;
      padding: 7px 10px;
      margin-bottom: 4px;
      background: var(--surface-2);
      border: 1px solid var(--border);
      color: var(--text);
      border-radius: 6px;
      font-size: 13px;
      cursor: pointer;
    }
    .inbox-nb-btn:hover { border-color: var(--accent); color: var(--accent); }

    /* ── Notebook emoji help (nb-emoji.js) ──────────────────── */
    .nb-emoji-pop {
      position: fixed;
      z-index: 10001; /* above .nb-fmt-bar */
      background: #1a1a1a;
      border-radius: 10px;
      box-shadow: 0 10px 34px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.08);
      color: #ddd;
      font-size: 13px;
      user-select: none;
    }
    .nb-emoji-glyph { font-size: 18px; line-height: 1; }
    .nb-emoji-hint {
      padding: 6px 10px;
      font-size: 10px;
      color: #777;
      border-top: 1px solid rgba(255,255,255,0.06);
      white-space: nowrap;
    }
    /* ':' suggestions */
    .nb-emoji-ac { min-width: 180px; padding: 4px; }
    .nb-emoji-ac-item {
      display: flex; align-items: center; gap: 10px;
      width: 100%; padding: 5px 8px;
      background: transparent; border: none; border-radius: 6px;
      color: inherit; font: inherit; text-align: left; cursor: pointer;
    }
    .nb-emoji-ac-item.active, .nb-emoji-ac-item:hover { background: rgba(104,192,96,0.18); color: #fff; }
    .nb-emoji-ac-word { font-family: 'Fira Code', monospace; font-size: 11px; color: #999; }
    .nb-emoji-ac-item.active .nb-emoji-ac-word { color: #cfe8cb; }
    /* Picker */
    .nb-emoji-picker { width: 316px; padding: 8px 8px 0; }
    .nb-emoji-search {
      padding: 7px 10px;
      border-radius: 6px;
      background: rgba(255,255,255,0.05);
      color: #777;
      font-size: 12px;
    }
    .nb-emoji-search.has-query { color: #fff; }
    .nb-emoji-cursor {
      display: inline-block; width: 1px; height: 13px; margin-left: 1px;
      background: currentColor; vertical-align: -2px;
      animation: nbEmojiBlink 1s steps(1) infinite;
    }
    @keyframes nbEmojiBlink { 50% { opacity: 0; } }
    .nb-emoji-tabs { display: flex; gap: 2px; margin: 6px 0 4px; flex-wrap: wrap; }
    .nb-emoji-tab {
      background: transparent; border: none; border-radius: 6px;
      padding: 4px 5px; font-size: 16px; line-height: 1; cursor: pointer;
      opacity: 0.55; transition: opacity 0.12s, background 0.12s;
    }
    .nb-emoji-tab:hover { opacity: 1; background: rgba(255,255,255,0.08); }
    .nb-emoji-tab.active { opacity: 1; background: rgba(104,192,96,0.18); }
    .nb-emoji-title {
      font-family: 'Fira Code', monospace; font-size: 9px;
      letter-spacing: 0.1em; text-transform: uppercase; color: #777;
      padding: 4px 2px;
    }
    .nb-emoji-grid {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 2px;
      max-height: 200px;
      overflow-y: auto;
      padding-bottom: 6px;
    }
    .nb-emoji-cell {
      background: transparent; border: none; border-radius: 6px;
      font-size: 20px; line-height: 1; padding: 5px 0; cursor: pointer;
      transition: background 0.1s, transform 0.1s;
    }
    .nb-emoji-cell:hover { background: rgba(255,255,255,0.1); transform: scale(1.15); }
    .nb-emoji-cell.active { background: rgba(104,192,96,0.22); }
    .nb-emoji-empty { grid-column: 1 / -1; padding: 14px; text-align: center; color: #777; font-size: 12px; }
