  @font-face {
    font-family: 'JetBrains Mono';
    src: url('JetBrainsMono.ttf') format('truetype');
    font-weight: 100 800;
    font-display: swap;
  }

  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  :root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface2: #222228;
    --border: #333339;
    --text: #e8e6e3;
    --dim: #9b9ba3;
    --accent: #c4f042;
    --accent-dim: #8ab02e;
    --accent-text: #0a0a0b;
    --red: #f04242;
    --red-dim: #c03535;
    --blue: #42a5f0;
    --grid-opacity: 0.12;
    --note-icon-text: #0a0a0b;
  }

  :root.light {
    --bg: #f4f4f6;
    --surface: #ffffff;
    --surface2: #e8e8ec;
    --border: #d0d0d6;
    --text: #1a1a1e;
    --dim: #6b6b78;
    --accent: #4a8c00;
    --accent-dim: #3d7500;
    --accent-text: #ffffff;
    --red: #d93030;
    --red-dim: #b82525;
    --blue: #2b7fbf;
    --grid-opacity: 0.06;
    --note-icon-text: #ffffff;
  }

  body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  }

  .grid-bg {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: var(--grid-opacity);
    pointer-events: none;
  }

  .app {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    padding-top: 20px;
  }

  .header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px;
  }

  .logo { font-size: 13px; letter-spacing: 4px; color: var(--dim); text-transform: uppercase; }
  .blocks-count { font-size: 13px; color: var(--dim); margin-top: 4px; }

  .nav-btns { display: flex; gap: 8px; }
  .nav-item { display: flex; flex-direction: column; align-items: center; }
  .nav-hint { font-size: 9px; color: var(--dim); margin-top: 3px; opacity: 0.7; transition: opacity 0.5s; }
  .nav-hints-hidden .nav-hint { opacity: 0; height: 0; margin: 0; overflow: hidden; }
  .nav-btn {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    padding: 10px 16px; font-size: 14px; cursor: pointer;
    letter-spacing: 1px; border-radius: 4px; font-family: inherit;
    transition: all 0.2s;
  }
  .nav-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
  .nav-btn.locked { opacity: 0.2; pointer-events: none; }

  .indicators { display: flex; gap: 6px; justify-content: center; margin-bottom: 36px; }
  .indicator {
    width: 40px; height: 4px; border-radius: 2px;
    background: var(--surface2); transition: background 0.3s;
  }
  .indicator.done { background: var(--accent); }

  /* Views */
  .view { display: none; text-align: center; }
  .view.active { display: block; }

  /* Timer display */
  .time-big {
    font-size: 60px; font-weight: 200; letter-spacing: -2px; line-height: 1;
  }
  .time-label {
    font-size: 13px; color: var(--dim); margin-top: 12px; letter-spacing: 2px;
  }

  /* Main button */
  .btn-start {
    background: var(--accent); color: var(--accent-text); border: none;
    padding: 16px 64px; font-size: 14px; font-weight: 700;
    letter-spacing: 3px; cursor: pointer; font-family: inherit;
    border-radius: 4px; margin-top: 48px; transition: background 0.2s;
  }
  .btn-start:active { background: var(--accent-dim); }

  /* Category select */
  .category-select {
    display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
    margin-top: 16px;
  }
  .cat-btn {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    font-family: inherit; font-size: 12px; letter-spacing: 1px;
    padding: 6px 14px; border-radius: 16px; cursor: pointer;
    transition: all 0.2s;
  }
  .cat-btn.active {
    border-color: var(--accent); color: var(--accent); background: transparent;
  }

  /* Circle timer */
  .timer-wrap { position: relative; width: 280px; height: 280px; margin: 0 auto 24px; }
  .timer-wrap svg { width: 100%; height: 100%; }
  .timer-center {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); text-align: center;
  }
  .timer-center .time-big { font-size: 52px; }
  .timer-status { font-size: 10px; letter-spacing: 3px; margin-top: 8px; }
  .timer-status.focus { color: var(--accent); }
  .timer-status.rest { color: var(--blue); }

  .hard-label {
    font-size: 12px; color: var(--red); letter-spacing: 2px; opacity: 0.7;
  }

  /* Quick note during session/break */
  .quick-note-wrap { margin-top: 16px; }
  .quick-note-toggle {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    padding: 8px 18px; font-size: 12px; cursor: pointer;
    font-family: inherit; letter-spacing: 1px; border-radius: 20px;
    transition: all 0.2s;
  }
  .quick-note-toggle:active { border-color: var(--accent); color: var(--accent); }
  .quick-note-input { margin-top: 10px; }
  .quick-note-field {
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); padding: 10px; font-size: 12px;
    font-family: inherit; resize: none; outline: none; line-height: 1.5;
  }
  .quick-note-field:focus { border-color: var(--accent); }
  .quick-note-actions { display: flex; gap: 8px; margin-top: 6px; justify-content: flex-end; }
  .quick-note-mic, .quick-note-save {
    background: var(--surface); border: 1px solid var(--border); color: var(--dim);
    padding: 6px 14px; font-size: 12px; cursor: pointer;
    font-family: inherit; border-radius: 4px; transition: all 0.2s;
  }
  .quick-note-save { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
  .quick-note-saved {
    font-size: 11px; color: var(--accent); margin-top: 6px; letter-spacing: 1px;
    opacity: 1; transition: opacity 0.5s;
  }

  /* Emergency stop */
  .emergency-btn {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    padding: 12px 24px; font-size: 12px; cursor: pointer;
    font-family: inherit; letter-spacing: 1px; border-radius: 4px;
    margin-top: 24px; transition: all 0.2s;
  }
  .emergency-btn:active { border-color: var(--red); color: var(--red); }

  /* Confirm overlay */
  .confirm-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 100;
    align-items: center; justify-content: center; padding: 20px;
  }
  .confirm-overlay.active { display: flex; }
  .confirm-box {
    background: var(--surface); border: 1px solid var(--red);
    border-radius: 8px; padding: 28px; max-width: 340px; width: 100%;
    text-align: center;
  }
  .confirm-box h3 { font-size: 16px; color: var(--red); margin-bottom: 12px; font-weight: 700; }
  .confirm-box p { font-size: 12px; color: var(--dim); line-height: 1.6; margin-bottom: 24px; }
  .confirm-btns { display: flex; gap: 12px; }
  .confirm-btns button {
    flex: 1; padding: 12px; font-size: 12px; cursor: pointer;
    font-family: inherit; border-radius: 4px; letter-spacing: 1px;
  }
  .btn-cancel { background: transparent; border: 1px solid var(--border); color: var(--dim); }
  .btn-confirm-stop { background: var(--red); border: none; color: #fff; font-weight: 700; }
  .diag-issue {
    padding: 12px; margin-bottom: 8px;
    background: var(--surface2); border-radius: 6px;
    border-left: 3px solid var(--red); text-align: left;
  }
  .diag-issue-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
  .diag-issue-hint { font-size: 11px; color: var(--dim); margin-bottom: 8px; line-height: 1.4; }
  .diag-fix-btn {
    padding: 6px 16px; font-size: 11px; font-weight: 700;
    background: transparent; border: 1px solid var(--accent); color: var(--accent);
    border-radius: 4px; cursor: pointer; font-family: inherit; letter-spacing: 1px;
  }

  /* Note view */
  .note-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; margin: 0 auto 24px; font-size: 28px; color: var(--note-icon-text);
  }
  .note-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
  .note-sub { font-size: 12px; color: var(--dim); margin-bottom: 24px; }
  .note-textarea {
    width: 100%; min-height: 100px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); padding: 14px; font-size: 13px;
    font-family: inherit; resize: vertical; outline: none; line-height: 1.5;
  }
  .note-textarea:focus { border-color: var(--accent); }
  .note-btns { display: flex; gap: 12px; margin-top: 20px; }
  .btn-skip {
    flex: 1; background: transparent; border: 1px solid var(--border);
    color: var(--dim); padding: 14px; font-size: 12px; cursor: pointer;
    font-family: inherit; letter-spacing: 1px; border-radius: 4px;
  }
  .btn-save {
    flex: 2; background: var(--accent); color: var(--accent-text); border: none;
    padding: 14px; font-size: 12px; font-weight: 700; cursor: pointer;
    font-family: inherit; letter-spacing: 1px; border-radius: 4px;
  }

  /* Break hint */
  .break-hint {
    font-size: 14px; color: var(--dim); line-height: 1.6;
  }

  /* Done view */
  .done-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: rgba(240,66,66,0.12); border: 2px solid var(--red);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 24px; font-size: 32px; color: var(--red);
  }
  .done-title { font-size: 20px; font-weight: 700; color: var(--red); margin-bottom: 8px; }
  .done-sub { font-size: 13px; color: var(--dim); line-height: 1.6; margin-bottom: 8px; }
  .done-hours { font-size: 12px; color: var(--dim); opacity: 0.6; margin-bottom: 24px; }
  .done-message {
    font-size: 12px; color: var(--dim); line-height: 1.8; margin-bottom: 28px;
    padding: 16px; background: var(--surface); border-radius: 6px;
    border: 1px solid var(--border);
  }
  .btn-reset {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    padding: 10px 20px; font-size: 10px; cursor: pointer;
    font-family: inherit; letter-spacing: 1px; border-radius: 4px;
  }

  /* Stats */
  .stats-back {
    background: transparent; border: none; color: var(--dim);
    font-size: 12px; cursor: pointer; font-family: inherit;
    margin-bottom: 24px; padding: 0; text-align: left;
  }
  .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
  .stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 16px;
  }
  .stat-label { font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 8px; }
  .stat-value { font-size: 26px; font-weight: 200; }
  .stat-value span { font-size: 14px; color: var(--dim); }
  .stat-detail { font-size: 13px; color: var(--dim); margin-top: 4px; }

  .chart-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 20px; margin-bottom: 24px;
  }
  .chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 100px; }
  .chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .chart-bar-val { font-size: 11px; color: var(--dim); }
  .chart-bar-fill { width: 100%; border-radius: 2px; transition: height 0.3s; }
  .chart-bar-label { font-size: 11px; color: var(--dim); }
  .chart-bar-label.today { color: var(--accent); }

  /* Monthly heatmap */
  .heatmap-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 20px; margin-bottom: 24px;
  }
  .heatmap-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
  }
  .heatmap-nav {
    background: transparent; border: 1px solid var(--border); color: var(--dim);
    width: 28px; height: 28px; border-radius: 4px; cursor: pointer;
    font-family: inherit; font-size: 14px; display: flex; align-items: center; justify-content: center;
  }
  .heatmap-nav:active { background: var(--surface2); }
  .heatmap-title {
    font-size: 12px; color: var(--dim); letter-spacing: 2px; text-transform: uppercase;
  }
  .heatmap-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px;
  }
  .heatmap-weekday {
    font-size: 10px; color: var(--dim); text-align: center; opacity: 0.6;
  }
  .heatmap-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  }
  .heatmap-cell {
    aspect-ratio: 1; border-radius: 3px; position: relative;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--dim); cursor: default;
  }
  .heatmap-cell.empty { background: transparent; }
  .heatmap-cell.no-data { background: var(--surface2); opacity: 0.3; }
  .heatmap-cell.level-1 { background: var(--accent); opacity: 0.25; color: var(--text); }
  .heatmap-cell.level-2 { background: var(--accent); opacity: 0.5; color: var(--text); }
  .heatmap-cell.level-3 { background: var(--accent); opacity: 0.75; color: var(--text); }
  .heatmap-cell.level-4 { background: var(--accent); opacity: 1; color: var(--accent-text); font-weight: 600; }
  .heatmap-cell.today-cell { outline: 2px solid var(--accent); outline-offset: -1px; }
  .heatmap-cell.future { background: transparent; opacity: 0.15; }
  .heatmap-summary {
    display: flex; justify-content: space-between; margin-top: 16px;
    padding-top: 12px; border-top: 1px solid var(--border);
  }
  .heatmap-stat { text-align: center; flex: 1; }
  .heatmap-stat-val { font-size: 18px; font-weight: 200; }
  .heatmap-stat-label { font-size: 10px; color: var(--dim); letter-spacing: 1px; margin-top: 2px; }

  .notes-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 20px; text-align: left;
  }
  .notes-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .notes-item:last-child { border-bottom: none; }
  .notes-date { font-size: 12px; color: var(--dim); margin-bottom: 4px; }
  .notes-text { font-size: 14px; line-height: 1.5; opacity: 0.8; }

  .note-feed-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
  .note-feed-meta { font-size: 11px; color: var(--dim); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
  .note-feed-tag { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-text); font-weight: 700; }
  .note-feed-text { font-size: 13px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
  .note-feed-actions { display: flex; gap: 12px; margin-top: 8px; }
  .note-feed-actions button { background: none; border: none; color: var(--dim); font-family: inherit; font-size: 11px; cursor: pointer; padding: 2px 0; }
  .note-feed-actions button:hover { color: var(--text); }

  /* Settings */
  .setting-row {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 16px; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .setting-label { font-size: 14px; color: var(--dim); }
  .setting-ctrl { display: flex; align-items: center; gap: 14px; }
  .setting-btn {
    width: 40px; height: 40px; background: var(--surface2);
    border: 1px solid var(--border); color: var(--text);
    font-size: 20px; cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-family: inherit;
  }
  .setting-val { font-size: 22px; font-weight: 200; min-width: 44px; text-align: center; cursor: pointer; -webkit-tap-highlight-color: rgba(196,240,66,0.2); }
  .setting-hint {
    margin-top: 24px; font-size: 13px; color: var(--dim);
    line-height: 1.6; padding: 12px 0;
  }

  /* Presets */
  .alarm-box { animation: alarm-pulse 1s ease-in-out infinite; }
  @keyframes alarm-pulse {
    0%, 100% { border-color: var(--accent); box-shadow: 0 0 20px rgba(196,240,66,0.2); }
    50% { border-color: var(--red); box-shadow: 0 0 30px rgba(240,66,66,0.3); }
  }

  /* Presets */
  .presets { display: flex; flex-direction: column; gap: 8px; }
  .preset-btn {
    display: flex; align-items: center; gap: 14px;
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 14px 16px; cursor: pointer;
    font-family: inherit; text-align: left; transition: all 0.2s;
    color: var(--text);
  }
  .preset-btn:active { border-color: var(--accent); background: var(--surface2); }
  .preset-icon { font-size: 24px; flex-shrink: 0; }
  .preset-info { flex: 1; }
  .preset-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
  .preset-desc { font-size: 12px; color: var(--dim); }

  /* Science */
  .science-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 18px; margin-bottom: 12px;
  }
  .science-title {
    font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--text);
  }
  .science-text {
    font-size: 13px; color: var(--dim); line-height: 1.7;
  }

  /* Last note on home */
  .last-note {
    margin-top: 40px; padding: 16px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px; text-align: left;
  }
  .last-note-label { font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 8px; }
  .last-note-text { font-size: 14px; line-height: 1.5; opacity: 0.8; }

  /* Toast notification */
  .toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 20px; display: flex; align-items: center; gap: 16px;
    font-family: inherit; font-size: 13px; color: var(--text);
    z-index: 9999; opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .toast.visible { opacity: 1; pointer-events: auto; }
  .toast-undo {
    background: none; border: none; color: var(--accent); font-family: inherit;
    font-size: 13px; font-weight: 600; letter-spacing: 1px; cursor: pointer;
    padding: 0; white-space: nowrap;
  }
