 *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --bg: #0a0a0a;
      --surface: #141414;
      --surface2: #1c1c1c;
      --accent: #c8f53a;
      --accent-glow: rgba(200, 245, 58, 0.13);
      --red: #ff5555;
      --red-glow: rgba(255, 85, 85, 0.1);
      --text: #efefef;
      --text-2: #888;
      --text-3: #3a3a3a;
      --border: rgba(255,255,255,0.07);
      --r: 14px;
      --nav-h: 64px;
    }

    html {
      background: var(--bg);
      color: var(--text);
      font-family: 'Syne', sans-serif;
      min-height: 100%;
      -webkit-tap-highlight-color: transparent;
      overflow-x: hidden;
    }

    body {
      min-height: 100vh;
      min-height: 100dvh;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    }

    button { touch-action: manipulation; }

    /* ── Header ─────────────────────────────── */
    .header {
      position: sticky;
      top: 0;
      z-index: 10;
      padding-top: env(safe-area-inset-top);
      background: rgba(10,10,10,0.92);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border-bottom: 1px solid var(--border);
    }

    .header-inner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 20px;
    }

    .logo { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; color: var(--accent); }

    .header-date {
      font-family: 'DM Mono', monospace;
      font-size: 11px;
      color: var(--text-2);
      letter-spacing: 0.5px;
      text-transform: uppercase;
    }

    /* ── Views ──────────────────────────────── */
    .view {
      display: none;
      padding: 16px 16px 24px;
      max-width: 480px;
      margin: 0 auto;
    }

    .view.active { display: block; }

    /* ── Section header ─────────────────────── */
    .section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
    }

    .section-title {
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      color: var(--text-2);
    }

    .edit-btn {
      font-family: 'Syne', sans-serif;
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.5px;
      color: var(--text-2);
      background: none;
      border: none;
      cursor: pointer;
      padding: 4px 0;
      transition: color 0.15s;
    }

    .edit-btn.active { color: var(--accent); }

    /* ── Month navigator ────────────────────── */
    .month-nav {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 14px;
    }

    .month-btn {
      width: 32px;
      height: 32px;
      border-radius: 9px;
      border: 1px solid var(--border);
      background: var(--surface2);
      color: var(--text-2);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: background 0.12s, color 0.12s, border-color 0.12s;
    }

    .month-btn:hover:not(:disabled) {
      background: var(--accent-glow);
      color: var(--accent);
      border-color: rgba(200,245,58,0.25);
    }

    .month-btn:disabled { opacity: 0.25; cursor: default; }

    .month-label {
      flex: 1;
      text-align: center;
      font-family: 'DM Mono', monospace;
      font-size: 13px;
      font-weight: 500;
      color: var(--text);
      letter-spacing: 0.3px;
    }

    /* ── Habit list ─────────────────────────── */
    #habits-list { display: flex; flex-direction: column; gap: 12px; }

    /* ── Habit card ─────────────────────────── */
    .habit-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 14px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      transition: border-color 0.2s;
    }

    .habit-card.editing { border-color: rgba(255,85,85,0.22); }

    .habit-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .habit-info {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }

    .habit-emoji { font-size: 22px; line-height: 1; flex-shrink: 0; }

    .habit-name {
      font-size: 15px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .streak {
      flex-shrink: 0;
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      font-weight: 500;
      padding: 4px 10px;
      border-radius: 100px;
      white-space: nowrap;
      color: var(--accent);
      background: var(--accent-glow);
    }

    .del-btn {
      flex-shrink: 0;
      width: 32px;
      height: 32px;
      border-radius: 8px;
      border: 1px solid rgba(255,85,85,0.2);
      background: var(--red-glow);
      color: var(--red);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.15s;
    }

    .del-btn:hover { background: rgba(255,85,85,0.18); }

    /* ── Monthly calendar grid ──────────────── */
    .cal-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 3px;
    }

    .cal-lbl {
      font-family: 'DM Mono', monospace;
      font-size: 8px;
      font-weight: 500;
      text-transform: uppercase;
      color: var(--text-3);
      text-align: center;
      padding-bottom: 4px;
    }

    .cal-lbl.weekend { color: #4a4a4a; }

    .cal-day {
      aspect-ratio: 1;
      border-radius: 7px;
      border: none;
      background: var(--surface2);
      color: var(--text-2);
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      font-weight: 500;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.1s, color 0.1s;
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
    }

    .cal-day.done {
      background: var(--accent);
      color: #0a0a0a;
      font-weight: 700;
    }

    .cal-day.today:not(.done) {
      outline: 1.5px solid rgba(200,245,58,0.45);
      outline-offset: -1.5px;
      color: var(--accent);
    }

    @media (hover: hover) {
      .cal-day:not(.done):not(:disabled):hover {
        background: var(--accent-glow);
        color: var(--accent);
      }
    }

    .cal-day:disabled { opacity: 0.15; cursor: default; }

    .cal-empty { aspect-ratio: 1; }

    /* ── Empty state ────────────────────────── */
    .empty {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      padding: 64px 20px;
      text-align: center;
    }

    .empty-icon { font-size: 40px; }
    .empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
    .empty-sub { font-size: 13px; color: var(--text-3); }

    /* ── FAB ────────────────────────────────── */
    .fab {
      position: fixed;
      right: max(20px, env(safe-area-inset-right));
      bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
      z-index: 20;
      width: 50px;
      height: 50px;
      border-radius: 15px;
      background: var(--accent);
      color: #0a0a0a;
      border: none;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 20px rgba(200,245,58,0.28);
      transition: transform 0.12s, box-shadow 0.12s;
    }

    .fab:active { transform: scale(0.91); box-shadow: 0 2px 10px rgba(200,245,58,0.18); }
    .fab[hidden] { display: none; }

    /* ── Bottom nav ─────────────────────────── */
    .nav {
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 30;
      height: calc(var(--nav-h) + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
      background: rgba(10,10,10,0.94);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      border-top: 1px solid var(--border);
      display: flex;
    }

    .nav-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      border: none;
      background: none;
      color: var(--text-3);
      cursor: pointer;
      transition: color 0.15s;
      padding: 10px 0;
    }

    .nav-item.active { color: var(--accent); }
    .nav-item[disabled] { cursor: not-allowed; opacity: 0.4; }
    .nav-icon { width: 21px; height: 21px; }
    .nav-lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; }

    /* ── Modal ──────────────────────────────── */
    .overlay {
      position: fixed;
      inset: 0;
      z-index: 50;
      background: rgba(0,0,0,0.65);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      display: flex;
      align-items: flex-end;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s;
    }

    .overlay.open { opacity: 1; pointer-events: all; }

    .modal {
      width: 100%;
      max-width: 480px;
      margin: 0 auto;
      background: var(--surface);
      border-radius: 22px 22px 0 0;
      border: 1px solid var(--border);
      border-bottom: none;
      padding: 0 20px calc(24px + env(safe-area-inset-bottom));
      transform: translateY(100%);
      transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
    }

    .overlay.open .modal { transform: translateY(0); }

    .modal-handle {
      width: 36px; height: 4px;
      background: var(--border);
      border-radius: 2px;
      margin: 14px auto 22px;
    }

    .modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

    .field-label {
      font-size: 11px; font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase;
      color: var(--text-2); margin-bottom: 10px;
    }

    .emoji-grid {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 6px;
      margin-bottom: 22px;
    }

    .emoji-opt {
      aspect-ratio: 1;
      font-size: 20px;
      border: 1.5px solid var(--border);
      background: var(--surface2);
      border-radius: 10px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: border-color 0.12s, background 0.12s;
    }

    .emoji-opt.selected { border-color: var(--accent); background: var(--accent-glow); }

    .name-input {
      display: block; width: 100%;
      padding: 14px 16px;
      background: var(--surface2);
      border: 1.5px solid var(--border);
      border-radius: 12px;
      color: var(--text);
      font-family: 'Syne', sans-serif;
      font-size: 16px; font-weight: 500;
      margin-bottom: 20px;
      outline: none;
      transition: border-color 0.15s;
      -webkit-appearance: none;
      appearance: none;
    }

    .name-input::placeholder { color: var(--text-3); }
    .name-input:focus { border-color: rgba(200,245,58,0.4); }

    .add-btn {
      display: block; width: 100%;
      padding: 15px;
      background: var(--accent); color: #0a0a0a;
      border: none; border-radius: 12px;
      font-family: 'Syne', sans-serif;
      font-size: 15px; font-weight: 700;
      cursor: pointer;
      transition: opacity 0.12s, transform 0.12s;
    }

    .add-btn:disabled { opacity: 0.35; cursor: not-allowed; }
    .add-btn:not(:disabled):active { opacity: 0.85; transform: scale(0.99); }

    /* ── Coming soon ────────────────────────── */
    .coming-soon {
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 10px; padding: 80px 20px;
      color: var(--text-3);
    }

    .coming-soon-icon { font-size: 36px; }
    .coming-soon-text { font-size: 14px; font-weight: 600; }

    /* ── Search bar ──────────────────────────── */
    .search-wrap { position: relative; margin-bottom: 14px; }

    .search-input {
      width: 100%;
      padding: 11px 14px 11px 38px;
      background: var(--surface);
      border: 1.5px solid var(--border);
      border-radius: 12px;
      color: var(--text);
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      outline: none;
      transition: border-color 0.15s;
      -webkit-appearance: none;
      appearance: none;
    }

    .search-input::placeholder { color: var(--text-3); }
    .search-input:focus { border-color: rgba(200,245,58,0.3); }

    .search-icon {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-3);
      pointer-events: none;
    }

    /* ── Note list ───────────────────────────── */
    #notes-list { display: flex; flex-direction: column; gap: 8px; }

    .note-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 14px;
      cursor: pointer;
      transition: border-color 0.15s;
      display: flex;
      flex-direction: column;
      gap: 6px;
      text-align: left;
      width: 100%;
      -webkit-appearance: none;
      appearance: none;
    }

    .note-card:active { border-color: rgba(200,245,58,0.2); }

    .note-card-top {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 8px;
    }

    .note-card-title {
      font-size: 14px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      min-width: 0;
    }

    .note-card-date {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--text-3);
      white-space: nowrap;
      flex-shrink: 0;
    }

    .note-card-preview {
      font-size: 12px;
      color: var(--text-2);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .note-card-tag {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--accent);
      background: var(--accent-glow);
      padding: 2px 7px;
      border-radius: 5px;
      align-self: flex-start;
    }

    /* ── Note editor (fullscreen) ────────────── */
    .note-editor {
      position: fixed;
      inset: 0;
      z-index: 40;
      background: var(--bg);
      display: flex;
      flex-direction: column;
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
      transform: translateX(100%);
      transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .note-editor.open { transform: translateX(0); }

    .editor-header {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .editor-back {
      width: 34px; height: 34px;
      border: none; background: none;
      color: var(--accent);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      border-radius: 8px; flex-shrink: 0;
      transition: background 0.12s;
    }

    .editor-back:hover { background: var(--accent-glow); }

    .editor-title-input {
      flex: 1;
      font-family: 'Syne', sans-serif;
      font-size: 16px; font-weight: 700;
      color: var(--text);
      background: none; border: none; outline: none;
      min-width: 0;
      -webkit-appearance: none; appearance: none;
    }

    .editor-title-input::placeholder { color: var(--text-3); }

    .mode-toggle {
      display: flex;
      background: var(--surface2);
      border-radius: 8px;
      padding: 2px; gap: 2px;
      flex-shrink: 0;
    }

    .mode-btn {
      font-family: 'DM Mono', monospace;
      font-size: 10px; font-weight: 500;
      padding: 4px 8px;
      border-radius: 6px;
      border: none; background: none;
      color: var(--text-2);
      cursor: pointer;
      transition: all 0.12s;
      letter-spacing: 0.5px;
    }

    .mode-btn.active { background: var(--surface); color: var(--accent); }

    .editor-body {
      flex: 1;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    .editor-textarea {
      flex: 1; width: 100%;
      padding: 16px;
      background: transparent; border: none;
      color: var(--text);
      font-family: 'DM Mono', monospace;
      font-size: 13px; line-height: 1.85;
      resize: none; outline: none;
      -webkit-appearance: none; appearance: none;
    }

    .editor-view-wrap {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
    }

    .editor-view-content {
      padding: 16px;
      font-family: 'Syne', sans-serif;
      font-size: 14px; line-height: 1.8;
      color: var(--text-2);
      white-space: normal;
      word-break: break-word;
      min-height: 80px;
    }

    /* Link chips */
    .note-link {
      display: inline;
      font-family: 'DM Mono', monospace;
      font-size: 12px; font-weight: 500;
      color: var(--accent);
      background: var(--accent-glow);
      border: 1px solid rgba(200,245,58,0.22);
      border-radius: 5px;
      padding: 1px 5px;
      cursor: pointer;
      transition: background 0.1s;
      -webkit-appearance: none; appearance: none;
      vertical-align: baseline;
    }

    .note-link:hover { background: rgba(200,245,58,0.22); }

    .note-link-missing {
      display: inline;
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      color: var(--text-2);
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 5px;
      padding: 1px 5px;
      vertical-align: baseline;
    }

    .note-link-create {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--accent);
      background: none; border: none;
      cursor: pointer; padding: 0 0 0 4px;
      opacity: 0.75; vertical-align: baseline;
    }

    .note-link-create:hover { opacity: 1; }

    /* Backlinks */
    .backlinks-section {
      border-top: 1px solid var(--border);
      flex-shrink: 0;
      max-height: 36vh;
      overflow-y: auto;
    }

    .backlinks-inner { padding: 10px 16px 12px; }

    .backlinks-header {
      font-size: 10px; font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase;
      color: var(--text-3);
      margin-bottom: 6px;
    }

    .backlink-item {
      display: flex; align-items: center; gap: 6px;
      padding: 5px 0;
      font-family: 'Syne', sans-serif;
      font-size: 13px; color: var(--text-2);
      cursor: pointer;
      border: none; background: none;
      width: 100%; text-align: left;
      transition: color 0.12s;
    }

    .backlink-item:hover { color: var(--accent); }

    /* Editor footer */
    .editor-footer {
      display: flex; align-items: center; gap: 10px;
      padding: 10px 16px;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    .editor-tag-wrap { flex: 1; display: flex; align-items: center; gap: 5px; }

    .editor-tag-prefix {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      color: var(--text-3);
      flex-shrink: 0;
    }

    .editor-tag-input {
      font-family: 'DM Mono', monospace;
      font-size: 16px; color: var(--text-2);
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 4px 8px; outline: none;
      width: 90px;
      transition: border-color 0.12s;
      -webkit-appearance: none; appearance: none;
    }

    .editor-tag-input::placeholder { color: var(--text-3); }
    .editor-tag-input:focus { border-color: rgba(200,245,58,0.3); }

    .editor-meta {
      font-family: 'DM Mono', monospace;
      font-size: 10px; color: var(--text-3);
      white-space: nowrap;
    }

    .editor-del {
      width: 32px; height: 32px;
      border-radius: 8px;
      border: 1px solid rgba(255,85,85,0.2);
      background: var(--red-glow);
      color: var(--red);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
      transition: background 0.15s;
    }

    .editor-del:hover { background: rgba(255,85,85,0.18); }

    /* ── Project list ────────────────────────── */
    #projects-list { display: flex; flex-direction: column; gap: 12px; }

    .proj-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 14px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      transition: border-color 0.2s;
    }

    .proj-card.editing { border-color: rgba(255,85,85,0.22); }

    .proj-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .proj-info {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }

    .proj-emoji { font-size: 22px; line-height: 1; flex-shrink: 0; }

    .proj-name {
      font-size: 15px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .status-badge {
      flex-shrink: 0;
      font-family: 'DM Mono', monospace;
      font-size: 11px;
      font-weight: 500;
      padding: 3px 9px;
      border-radius: 100px;
      white-space: nowrap;
    }

    .status-badge.active { color: var(--accent); background: var(--accent-glow); }
    .status-badge.pause  { color: #f5a623; background: rgba(245,166,35,0.12); }
    .status-badge.done   { color: #7b8cde; background: rgba(123,140,222,0.12); }

    .proj-desc {
      font-size: 13px;
      color: var(--text-2);
      line-height: 1.55;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .proj-tags { display: flex; flex-wrap: wrap; gap: 5px; }

    .tag {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      font-weight: 500;
      padding: 3px 8px;
      border-radius: 6px;
      background: var(--surface2);
      border: 1px solid var(--border);
      color: var(--text-2);
    }

    .proj-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding-top: 2px;
    }

    .proj-link {
      font-family: 'DM Mono', monospace;
      font-size: 11px;
      color: var(--text-2);
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 5px;
      min-width: 0;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      transition: color 0.12s;
    }

    .proj-link:hover { color: var(--accent); }

    .proj-edit-btn {
      flex-shrink: 0;
      font-family: 'Syne', sans-serif;
      font-size: 11px;
      font-weight: 600;
      color: var(--text-2);
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 5px 10px;
      cursor: pointer;
      transition: color 0.12s, border-color 0.12s;
    }

    .proj-edit-btn:hover { color: var(--accent); border-color: rgba(200,245,58,0.25); }

    /* ── Project modal extras ────────────────── */
    .modal--scroll {
      max-height: 84vh;
      max-height: 84dvh;
      display: flex;
      flex-direction: column;
      padding: 0;
    }

    .modal-head {
      flex-shrink: 0;
      padding: 0 20px;
    }

    .modal-body {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      padding: 0 20px calc(24px + env(safe-area-inset-bottom));
    }

    .textarea-input {
      display: block; width: 100%;
      padding: 12px 16px;
      background: var(--surface2);
      border: 1.5px solid var(--border);
      border-radius: 12px;
      color: var(--text);
      font-family: 'Syne', sans-serif;
      font-size: 16px; font-weight: 400;
      line-height: 1.5;
      margin-bottom: 20px;
      outline: none;
      resize: none;
      transition: border-color 0.15s;
      -webkit-appearance: none;
      appearance: none;
    }

    .textarea-input::placeholder { color: var(--text-3); }
    .textarea-input:focus { border-color: rgba(200,245,58,0.4); }

    .status-selector {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      margin-bottom: 20px;
    }

    .status-opt {
      padding: 10px 4px;
      border-radius: 10px;
      border: 1.5px solid var(--border);
      background: var(--surface2);
      color: var(--text-2);
      font-family: 'Syne', sans-serif;
      font-size: 12px; font-weight: 600;
      cursor: pointer;
      text-align: center;
      transition: all 0.12s;
    }

    .status-opt[data-s="active"].selected { border-color: var(--accent);  background: var(--accent-glow); color: var(--accent); }
    .status-opt[data-s="pause"].selected  { border-color: #f5a623; background: rgba(245,166,35,0.12); color: #f5a623; }
    .status-opt[data-s="done"].selected   { border-color: #7b8cde; background: rgba(123,140,222,0.12); color: #7b8cde; }

    .tag-input-area {
      background: var(--surface2);
      border: 1.5px solid var(--border);
      border-radius: 12px;
      padding: 9px 12px;
      margin-bottom: 6px;
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      transition: border-color 0.15s;
      cursor: text;
    }

    .tag-input-area:focus-within { border-color: rgba(200,245,58,0.4); }

    .tag-pill {
      display: flex;
      align-items: center;
      gap: 3px;
      font-family: 'DM Mono', monospace;
      font-size: 11px; font-weight: 500;
      color: var(--accent);
      background: var(--accent-glow);
      border-radius: 6px;
      padding: 3px 5px 3px 8px;
      white-space: nowrap;
    }

    .tag-pill-x {
      background: none; border: none;
      color: var(--accent); cursor: pointer;
      font-size: 15px; line-height: 1;
      padding: 0; opacity: 0.65;
      display: flex; align-items: center;
    }

    .tag-pill-x:hover { opacity: 1; }

    .tag-raw-input {
      flex: 1; min-width: 80px;
      background: none; border: none;
      color: var(--text);
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      outline: none; padding: 2px 0;
    }

    .tag-raw-input::placeholder { color: var(--text-3); }

    .field-hint {
      font-size: 11px;
      color: var(--text-3);
      margin-bottom: 20px;
    }

    .field-label-row {
      display: flex;
      align-items: baseline;
      gap: 6px;
      margin-bottom: 10px;
    }

    .field-label-opt {
      font-size: 10px;
      font-weight: 400;
      color: var(--text-3);
      text-transform: none;
      letter-spacing: 0;
    }

    /* ── Block editor (EDIT mode) ────────────────────────── */
    .blocks-container {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      padding: 8px 0 24px;
    }

    .block-wrap {
      position: relative;
      display: flex;
      align-items: flex-start;
      padding: 2px 48px 2px 16px;
    }

    .block-wrap:hover .block-controls,
    .block-wrap:focus-within .block-controls { opacity: 1; }

    .block-controls {
      position: absolute;
      right: 6px; top: 4px;
      display: flex; gap: 2px;
      opacity: 0;
      transition: opacity 0.15s;
    }

    .block-ctrl {
      width: 22px; height: 22px;
      border: none;
      background: var(--surface2);
      color: var(--text-2);
      border-radius: 5px;
      cursor: pointer;
      font-size: 13px;
      display: flex; align-items: center; justify-content: center;
      line-height: 1;
      transition: background 0.12s, color 0.12s;
    }

    .block-ctrl:hover:not([disabled]) { background: var(--surface); color: var(--text); }
    .block-ctrl[disabled] { opacity: 0.25; cursor: default; }
    .block-ctrl--del:hover:not([disabled]) { background: var(--red-glow); color: var(--red); }

    .block-ce {
      flex: 1;
      min-height: 1.5em;
      outline: none;
      word-break: break-word;
      font-family: 'Syne', sans-serif;
      font-size: 16px; line-height: 1.75;
      color: var(--text);
      padding: 3px 0;
    }

    .block-ce:empty::before {
      content: attr(placeholder);
      color: var(--text-3);
      pointer-events: none;
    }

    .block-heading { font-size: 18px; font-weight: 700; line-height: 1.4; }
    .block-heading[data-level="3"] { font-size: 15px; }

    .block-code {
      font-family: 'DM Mono', monospace;
      font-size: 12px; line-height: 1.7;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 10px 12px;
      color: #a8e890;
      width: 100%;
      white-space: pre-wrap;
    }

    .block-image-wrap,
    .block-link-wrap {
      flex: 1;
      display: flex; flex-direction: column; gap: 6px;
      padding: 4px 0;
    }

    .block-field {
      width: 100%;
      padding: 8px 10px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-family: 'DM Mono', monospace;
      font-size: 16px;
      outline: none;
      transition: border-color 0.15s;
      -webkit-appearance: none; appearance: none;
    }

    .block-field::placeholder { color: var(--text-3); }
    .block-field:focus { border-color: rgba(200,245,58,0.3); }

    .block-img-preview {
      width: 100%;
      max-height: 200px;
      object-fit: cover;
      border-radius: 8px;
      border: 1px solid var(--border);
      margin-top: 4px;
      display: block;
    }

    .block-img-error { font-size: 11px; color: var(--red); padding: 4px 0; }

    .block-divider { flex: 1; padding: 10px 0; }
    .block-divider hr { border: none; border-top: 1px solid var(--border); }

    /* ── Slash menu ─────────────────────────────────────── */
    .slash-menu {
      position: fixed;
      z-index: 60;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 6px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.5);
      min-width: 176px;
    }

    .slash-item {
      display: block;
      width: 100%;
      padding: 9px 12px;
      border: none; background: none;
      color: var(--text);
      font-family: 'Syne', sans-serif;
      font-size: 13px; font-weight: 500;
      cursor: pointer;
      border-radius: 7px;
      text-align: left;
      transition: background 0.1s;
    }

    .slash-item:hover { background: var(--surface2); color: var(--accent); }

    /* ── Block VIEW mode ────────────────────────────────── */
    .view-text {
      font-size: 14px; line-height: 1.8;
      color: var(--text-2);
      margin-bottom: 8px;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .view-heading {
      font-size: 18px; font-weight: 700;
      color: var(--text);
      margin: 16px 0 6px;
      line-height: 1.3;
    }

    h3.view-heading { font-size: 15px; }

    .view-code {
      font-family: 'DM Mono', monospace;
      font-size: 12px; line-height: 1.7;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px;
      color: #a8e890;
      overflow-x: auto;
      margin-bottom: 10px;
      white-space: pre;
      display: block;
    }

    .view-image { margin-bottom: 10px; }
    .view-image img { width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
    .view-image figcaption { font-size: 11px; color: var(--text-3); margin-top: 4px; text-align: center; }

    .view-link-tile {
      display: flex;
      align-items: center;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px;
      font-size: 13px; color: var(--text-2);
      text-decoration: none;
      margin-bottom: 10px;
      word-break: break-all;
      transition: border-color 0.12s, color 0.12s;
    }

    .view-link-tile:hover { color: var(--accent); border-color: rgba(200,245,58,0.2); }

    .view-hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

    /* ── iOS / touch fixes ──────────────────────────────── */
    @media (hover: none) {
      /* Block controls always visible — :hover nie działa na dotyku */
      .block-controls { opacity: 1; }

      /* Zmniejsz padding prawej strony block-wrap, bo przyciski zawsze widoczne */
      .block-wrap { padding-right: 56px; }
    }

    /* ── Calendar / Plan view ─────────────────────────────── */
    .day-nav {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 16px;
    }

    .day-nav-btn {
      width: 36px; height: 36px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface2);
      color: var(--text-2);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
      transition: background 0.12s, color 0.12s;
    }

    .day-nav-btn:active { background: var(--accent-glow); color: var(--accent); }

    @media (hover: hover) {
      .day-nav-btn:hover { background: var(--accent-glow); color: var(--accent); }
    }

    .day-nav-center {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 5px;
    }

    .day-nav-date {
      font-size: 14px;
      font-weight: 700;
      color: var(--text);
      text-align: center;
    }

    .day-today-btn {
      font-family: 'DM Mono', monospace;
      font-size: 9px;
      font-weight: 500;
      letter-spacing: 1px;
      text-transform: uppercase;
      color: var(--accent);
      background: var(--accent-glow);
      border: none;
      border-radius: 5px;
      padding: 2px 8px;
      cursor: pointer;
    }

    .day-today-btn[hidden] { display: none; }

    /* ── Calendar event list ──────────────────────────────── */
    #cal-events-list { display: flex; flex-direction: column; gap: 6px; }

    .cal-event-item {
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 13px 14px;
    }

    .cal-event-time {
      font-family: 'DM Mono', monospace;
      font-size: 13px;
      font-weight: 500;
      color: var(--accent);
      flex-shrink: 0;
      min-width: 40px;
    }

    .cal-event-dot {
      font-size: 10px;
      flex-shrink: 0;
      color: var(--text-3);
    }

    .cal-event-dot.override { color: #7b8cde; }

    .cal-event-title {
      flex: 1;
      font-size: 14px;
      font-weight: 600;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .cal-event-skip {
      flex-shrink: 0;
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      letter-spacing: 0.5px;
      color: var(--text-3);
      background: none;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 3px 8px;
      cursor: pointer;
      transition: color 0.12s, border-color 0.12s;
    }

    .cal-event-skip:active { color: var(--red); border-color: rgba(255,85,85,0.3); }

    @media (hover: hover) {
      .cal-event-skip:hover { color: var(--red); border-color: rgba(255,85,85,0.3); }
    }

    .cal-event-del {
      flex-shrink: 0;
      width: 28px; height: 28px;
      border-radius: 7px;
      border: 1px solid rgba(255,85,85,0.2);
      background: var(--red-glow);
      color: var(--red);
      cursor: pointer;
      font-size: 17px;
      display: flex; align-items: center; justify-content: center;
      line-height: 1;
      transition: background 0.12s;
    }

    .cal-event-del:active { background: rgba(255,85,85,0.22); }

    @media (hover: hover) {
      .cal-event-del:hover { background: rgba(255,85,85,0.22); }
    }

    /* ── Template editor (fullscreen) ─────────────────────── */
    .template-editor {
      position: fixed;
      inset: 0;
      z-index: 40;
      background: var(--bg);
      display: flex;
      flex-direction: column;
      padding-top: env(safe-area-inset-top);
      transform: translateX(100%);
      transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .template-editor.open { transform: translateX(0); }

    .template-editor-title {
      flex: 1;
      font-size: 15px;
      font-weight: 700;
      color: var(--text);
    }

    .template-dow-tabs {
      display: flex;
      gap: 4px;
      padding: 10px 16px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .template-dow-btn {
      flex: 1;
      padding: 8px 2px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: none;
      color: var(--text-2);
      font-family: 'DM Mono', monospace;
      font-size: 11px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.12s;
      text-align: center;
    }

    .template-dow-btn.active {
      background: var(--accent-glow);
      border-color: rgba(200,245,58,0.3);
      color: var(--accent);
    }

    .template-events-body {
      flex: 1;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding: 12px 16px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .template-footer {
      padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    /* ── Today's plan widget (habits view) ────────────────── */
    #today-plan-card { margin-bottom: 12px; }

    .today-plan-wrap {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 12px 14px;
      display: flex;
      flex-direction: column;
      gap: 7px;
    }

    .today-plan-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .today-plan-label {
      font-size: 9px;
      font-weight: 700;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      color: var(--text-3);
    }

    .today-plan-see-all {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--accent);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
    }

    .today-plan-event {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .today-plan-time {
      font-family: 'DM Mono', monospace;
      font-size: 11px;
      font-weight: 500;
      color: var(--accent);
      flex-shrink: 0;
      min-width: 36px;
    }

    .today-plan-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-2);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .today-plan-more {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--text-3);
      padding-top: 2px;
    }

    /* ── Event modal: time row ─────────────────────────────── */
    .event-time-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin-bottom: 20px;
    }

    .event-time-col .name-input { margin-bottom: 0; }

    /* ── Calendar timeline ─────────────────────────────────── */
    #cal-events-list { display: block; }

    .cal-timeline {
      position: relative;
      padding-bottom: 8px;
    }

    .cal-hour-line {
      position: absolute;
      left: 0; right: 0;
      display: flex;
      align-items: flex-start;
      border-top: 1px solid var(--border);
    }

    .cal-hour-line:first-child { border-top: none; }

    .cal-hour-label {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--text-3);
      width: 48px;
      flex-shrink: 0;
      text-align: right;
      padding-right: 8px;
      transform: translateY(-8px);
      position: relative;
      z-index: 1;
      line-height: 1;
    }

    .cal-event-block {
      position: absolute;
      border-radius: 8px;
      padding: 5px 8px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      z-index: 2;
      min-height: 28px;
    }

    .cal-event-block.template {
      background: rgba(200,245,58,0.10);
      border-left: 3px solid var(--accent);
    }

    .cal-event-block.override {
      background: rgba(123,140,222,0.12);
      border-left: 3px solid #7b8cde;
    }

    .cal-event-block-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.4;
      padding-right: 28px;
    }

    .cal-event-block-time {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--text-2);
      margin-top: 2px;
      white-space: nowrap;
    }

    .cal-event-block-actions {
      position: absolute;
      top: 4px;
      right: 5px;
    }

    .cal-block-skip {
      font-family: 'DM Mono', monospace;
      font-size: 9px;
      letter-spacing: 0.3px;
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-3);
      padding: 2px 3px;
      opacity: 0.7;
      transition: opacity 0.1s;
    }

    .cal-block-del {
      font-size: 16px;
      line-height: 1;
      background: none;
      border: none;
      cursor: pointer;
      color: var(--red);
      padding: 0 2px;
      opacity: 0.7;
      transition: opacity 0.1s;
    }

    .cal-block-skip:active, .cal-block-del:active { opacity: 1; }

    /* Current time indicator */
    .cal-now-line {
      position: absolute;
      left: 48px;
      right: 0;
      height: 2px;
      background: var(--red);
      z-index: 4;
      border-radius: 1px;
    }

    .cal-now-line::before {
      content: '';
      position: absolute;
      left: -4px;
      top: -3px;
      width: 8px;
      height: 8px;
      background: var(--red);
      border-radius: 50%;
    }

    /* ── Header right group ──────────────────────────────────── */
    .header-right {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    /* ── Notification bell button ────────────────────────────── */
    .notif-btn {
      width: 30px;
      height: 30px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface2);
      color: var(--text-3);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: color 0.15s, border-color 0.15s, background 0.15s;
    }

    .notif-btn:hover  { color: var(--accent); border-color: rgba(200,245,58,0.3); background: var(--accent-glow); }
    .notif-btn.active { color: var(--accent); border-color: rgba(200,245,58,0.4); background: var(--accent-glow); }

    /* ── Notification modal internals ────────────────────────── */
    .notif-status-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 14px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 12px;
      margin-bottom: 20px;
    }

    .notif-status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      flex-shrink: 0;
      background: var(--text-3);
      transition: background 0.2s;
    }

    .notif-status-dot.on  { background: var(--accent); }
    .notif-status-dot.off { background: var(--text-3); }
    .notif-status-dot.err { background: var(--red); }

    .notif-status-text {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      color: var(--text-2);
    }

    .notif-save-btn {
      display: block;
      width: 100%;
      padding: 12px;
      margin-bottom: 16px;
      background: var(--surface2);
      border: 1.5px solid var(--border);
      border-radius: 12px;
      color: var(--text-2);
      font-family: 'Syne', sans-serif;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: border-color 0.15s, color 0.15s;
    }

    .notif-save-btn:hover { border-color: rgba(200,245,58,0.35); color: var(--accent); }

    .notif-actions-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    #notif-actions-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .notif-test-btn {
      padding: 12px;
      border-radius: 12px;
      border: 1.5px solid rgba(200,245,58,0.25);
      background: var(--accent-glow);
      color: var(--accent);
      font-family: 'Syne', sans-serif;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: opacity 0.12s;
    }

    .notif-test-btn:active { opacity: 0.7; }

    .notif-off-btn {
      padding: 12px;
      border-radius: 12px;
      border: 1.5px solid rgba(255,85,85,0.2);
      background: var(--red-glow);
      color: var(--red);
      font-family: 'Syne', sans-serif;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: opacity 0.12s;
    }

    .notif-off-btn:active { opacity: 0.7; }