  :root {
    --bg: #0e0e0f;
    --surface: #161618;
    --surface2: #1e1e21;
    --border: #2a2a2e;
    --text: #e8e8ea;
    --muted: #6b6b72;
    --green: #4ade80;
    --green-dim: rgba(74,222,128,0.12);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251,191,36,0.12);
    --red: #f87171;
    --red-dim: rgba(248,113,113,0.12);
    --accent: #e8e8ea;
    --sidebar-w: 220px;
    --header-h: 56px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* HEADER */
  header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    z-index: 10;
  }

  .logo {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--text);
    text-transform: uppercase;
  }

  .time-bar {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .time-readout {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--muted);
  }

  .time-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s;
  }

  .time-status.green { background: var(--green-dim); color: var(--green); }
  .time-status.yellow { background: var(--yellow-dim); color: var(--yellow); }
  .time-status.red { background: var(--red-dim); color: var(--red); }

  .status-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
  }

  .date-display {
    font-size: 12px;
    color: var(--muted);
  }

  /* LAYOUT */
  .app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  /* SIDEBAR */
  aside {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
  }

  .sidebar-section {
    padding: 16px 12px 8px;
  }

  .sidebar-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
    padding: 0 8px;
    margin-bottom: 6px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 8px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
    transition: all 0.15s;
    user-select: none;
    gap: 8px;
  }

  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active { background: var(--surface2); color: var(--text); }

  .nav-item-left { display: flex; align-items: center; gap: 8px; }

  .nav-icon {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    flex-shrink: 0;
  }

  .nav-item.active .nav-icon { opacity: 1; }

  .nav-badge {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .nav-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
  }

  .add-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    margin: 0 12px 12px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    transition: all 0.15s;
    border: 1px dashed var(--border);
  }

  .add-tab-btn:hover { color: var(--text); border-color: var(--muted); }

  /* MAIN */
  main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg);
  }

  .view { display: none; }
  .view.active { display: block; }

  /* HOME VIEW */
  .home-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
  }

  .home-title {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
  }

  .day-label {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
  }

  .progress-bar-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .progress-label {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }

  .progress-track {
    flex: 1;
    height: 3px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--green);
    transition: width 0.4s ease;
  }

  .progress-fill.yellow { background: var(--yellow); }
  .progress-fill.red { background: var(--red); }

  .progress-pct {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }

  /* LIST SECTIONS */
  .list-section {
    margin-bottom: 20px;
  }

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .section-name {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
  }

  .section-time {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  /* TASK ITEM */
  .task-item {
    display: flex;
    flex-direction: column;
    padding: 2px 0;
    border-radius: 5px;
    transition: background 0.1s;
  }

  .task-item:hover { background: var(--surface); }

  .task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    cursor: pointer;
    user-select: none;
  }

  .checkbox {
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }

  .checkbox.checked {
    background: var(--text);
    border-color: var(--text);
  }

  .checkbox.checked::after {
    content: '';
    width: 8px;
    height: 5px;
    border-left: 1.5px solid var(--bg);
    border-bottom: 1.5px solid var(--bg);
    transform: rotate(-45deg) translateY(-1px);
    display: block;
  }

  .task-name {
    flex: 1;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    transition: color 0.15s;
  }

  .task-item.done .task-name {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: var(--border);
  }

  .task-duration {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .task-color-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .task-color-dot.green { background: var(--green); }
  .task-color-dot.yellow { background: var(--yellow); }
  .task-color-dot.red { background: var(--red); }
  .task-color-dot.none { background: transparent; }

  .task-expand-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.1s;
  }

  .task-delete-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.1s, color 0.1s;
  }

  .task-delete-btn:hover { color: var(--red); }

  .task-edit-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 13px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.1s, color 0.1s;
  }

  .task-edit-btn:hover { color: var(--text); }

  .task-item:hover .task-expand-btn,
  .task-item:hover .task-delete-btn,
  .task-item:hover .task-edit-btn { opacity: 1; }

  .reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
  }

  .reorder-btns button {
    background: none;
    border: none;
    color: var(--border);
    cursor: pointer;
    font-size: 10px;
    padding: 1px 3px;
    line-height: 1;
    transition: color 0.1s;
    border-radius: 2px;
  }

  .reorder-btns button:hover:not(:disabled) { color: var(--muted); }
  .reorder-btns button:disabled { opacity: 0.2; cursor: default; }

  /* ROUTINE BLOCKS */
  .routine-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--surface);
  }

  .routine-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
  }

  .routine-block-header:hover { background: var(--surface2); }

  .routine-block-left { display: flex; flex-direction: column; gap: 2px; }

  .routine-block-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
  }

  .routine-block-range {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .routine-block-badge {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .routine-block-tasks {
    padding: 4px 0;
  }

  /* TIME BLOCK HEADERS in home */
  .time-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0 10px;
    margin-bottom: 4px;
  }

  .time-block-label {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .time-block-range {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .time-block-note { color: var(--yellow); }

  /* ROUTINE VIEW */
  .routine-view-type {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    margin-left: 8px;
  }

  .disabled-nav { opacity: 0.5; }

  /* ANALYTICS */
  .analytics-subnav {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
  }

  .analytics-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: all 0.15s;
  }

  .analytics-tab:hover { color: var(--text); }
  .analytics-tab.active { color: var(--text); border-bottom-color: var(--text); }

  /* WEEK VIEW */
  .week-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 180px;
    margin-bottom: 16px;
    padding: 0 4px;
  }

  .week-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
    gap: 6px;
  }

  .week-bar-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    position: relative;
  }

  .week-bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    background: var(--green);
    transition: height 0.4s ease;
    min-height: 2px;
    position: relative;
  }

  .week-bar.today { background: var(--text); }
  .week-bar.no-data { background: var(--surface2); }

  .week-bar-pct {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 2px;
  }

  .week-bar-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
  }

  .week-bar-label.today { color: var(--text); }

  .week-average-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-top: 1px solid var(--border);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .week-average-line span { color: var(--text); font-weight: 500; }

  /* TABS CHART */
  .tabs-chart { margin-top: 28px; }

  .tabs-chart-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
  }

  .tab-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }

  .tab-bar-name {
    font-size: 12px;
    color: var(--text);
    width: 100px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tab-bar-track {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
  }

  .tab-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 0.4s ease;
  }

  .tab-bar-pct {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
  }

  /* MONTH VIEW */
  .month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .month-nav-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
  }

  .month-nav-btn:hover { color: var(--text); border-color: var(--muted); }

  .month-nav-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    min-width: 120px;
    text-align: center;
  }

  .month-avg {
    font-family: 'DM Mono', monospace;
    font-size: 22px;
    font-weight: 500;
    color: var(--text);
  }

  .month-avg-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 2px;
  }

  .month-grid-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 4px;
  }

  .month-day-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-align: center;
    padding: 4px 0;
  }

  .month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
  }

  .month-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    position: relative;
    cursor: default;
  }

  .month-cell.has-data { cursor: default; }
  .month-cell.empty { background: transparent; }
  .month-cell.no-data { background: var(--surface); }
  .month-cell.today-cell { outline: 1px solid var(--text); border-radius: 3px; }

  /* YEAR VIEW */
  .year-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }

  .year-avg {
    font-family: 'DM Mono', monospace;
    font-size: 22px;
    font-weight: 500;
    color: var(--text);
  }

  .year-avg-label {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 2px;
  }

  .year-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
  }

  .year-cell {
    border-radius: 6px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .year-cell-month {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
  }

  .year-cell-pct {
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    font-weight: 500;
  }

  .year-nav-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
  }

  .year-nav-btn:hover { color: var(--text); border-color: var(--muted); }

  /* MISSED TASKS */
  .missed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .missed-sort {
    display: flex;
    gap: 4px;
  }

  .missed-sort-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
  }

  .missed-sort-btn.active { color: var(--text); border-color: var(--muted); }

  .missed-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 5px;
    border: 1px solid var(--border);
    margin-bottom: 6px;
    background: var(--surface);
  }

  .missed-rank {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    width: 20px;
    flex-shrink: 0;
  }

  .missed-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
  }

  .missed-tab {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .missed-stats {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
  }

  .missed-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
  }

  .missed-stat-val {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
  }

  .missed-stat-val.bad { color: var(--red); }
  .missed-stat-val.good { color: var(--green); }

  .missed-stat-label {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
  }

  .analytics-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 13px;
  }

  .analytics-empty-icon { font-size: 28px; margin-bottom: 10px; opacity: 0.3; }
  .analytics-empty-sub { font-size: 12px; margin-top: 6px; opacity: 0.6; }

  /* MISSED by list */
  .missed-list-group { margin-bottom: 24px; }

  .missed-list-header {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .missed-list-avg {
    font-size: 10px;
    color: var(--red);
  }

  /* LOG VIEW */
  .log-week-group {
    margin-bottom: 28px;
  }

  .log-week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .log-week-label {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text);
  }

  .log-week-stats {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    font-weight: 500;
  }

  .log-week-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .log-day-group {
    padding-left: 12px;
    border-left: 2px solid var(--border);
  }

  .log-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .log-day-header > span:first-child {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
  }

  .log-day-stats {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .log-list-group {
    margin-bottom: 8px;
    padding-left: 12px;
  }

  .log-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
  }

  .log-list-name {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .log-list-stats {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .log-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
  }

  .log-entry:hover { background: var(--surface2); }

  .log-entry.missed .log-entry-name {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: var(--border);
  }

  .log-status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .log-status-dot.completed { background: var(--green); }
  .log-status-dot.missed { background: var(--red); }

  .log-entry-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
  }

  .log-entry-tab {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    color: var(--muted);
  }

  .log-entry-duration {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .task-note {
    display: none;
    padding: 4px 8px 8px 33px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
    font-style: italic;
  }

  .task-note.open { display: block; }

  /* TAB VIEW */
  .tab-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
  }

  .tab-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .tab-actions {
    display: flex;
    gap: 8px;
  }

  .btn {
    padding: 7px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: 'DM Sans', sans-serif;
  }

  .btn-ghost {
    background: none;
    color: var(--muted);
    border: 1px solid var(--border);
  }

  .btn-ghost:hover { color: var(--text); border-color: var(--muted); }

  .btn-primary {
    background: var(--text);
    color: var(--bg);
  }

  .btn-primary:hover { opacity: 0.85; }

  /* ADD TASK */
  .add-task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin-top: 6px;
    border-radius: 5px;
    border: 1px dashed var(--border);
    cursor: text;
    transition: all 0.15s;
  }

  .add-task-row:hover { border-color: var(--muted); }

  .add-task-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    placeholder-color: var(--muted);
  }

  .add-task-input::placeholder { color: var(--muted); }

  .add-task-duration {
    width: 60px;
    background: none;
    border: none;
    outline: none;
    color: var(--muted);
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    text-align: right;
  }

  .add-task-duration::placeholder { color: var(--border); }

  /* MODAL */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
  }

  .modal-overlay.open { display: flex; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    width: 380px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  }

  .modal-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
  }

  .input-field {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 9px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.15s;
  }

  .input-field:focus { border-color: var(--muted); }

  .modal-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
  }

  .modal-row .input-field { margin-bottom: 0; }

  .select-field {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 9px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    cursor: pointer;
    appearance: none;
  }

  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
  }

  /* EMPTY STATE */
  .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 13px;
  }

  .empty-state-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.4;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* SETTINGS BUTTON */
  .settings-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 6px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s;
  }
  .settings-btn:hover { color: var(--text); border-color: var(--muted); }

  /* REMINDERS */
  .reminders-wrap { position: relative; }

  .reminders-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 4px;
    background: var(--yellow-dim);
    border: 1px solid rgba(251,191,36,0.2);
    color: var(--yellow);
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s;
  }

  .reminders-btn:hover { background: rgba(251,191,36,0.2); }

  .reminders-count {
    font-size: 11px;
  }

  .reminders-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    z-index: 200;
    overflow: hidden;
  }

  .reminders-panel.open { display: block; }

  .reminders-panel-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
  }

  .reminder-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }

  .reminder-item:last-child { border-bottom: none; }

  .reminder-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--yellow);
    margin-top: 5px;
    flex-shrink: 0;
  }

  .reminder-dot.confirm { background: var(--green); }

  .reminder-text {
    flex: 1;
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
  }

  .reminder-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
  }

  .reminder-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
  }

  .reminder-btn {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all 0.12s;
  }

  .reminder-btn:hover { color: var(--text); border-color: var(--muted); }
  .reminder-btn.confirm { background: var(--green-dim); color: var(--green); border-color: rgba(74,222,128,0.3); }
  .reminder-btn.dismiss { background: var(--surface2); }

  /* DAY WINDOW DISPLAY */
  .day-window-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 14px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--muted);
  }

  .day-window-bar span { color: var(--text); }
  .day-window-sep { color: var(--border); }

  /* SETTINGS SECTIONS */
  .settings-section-title {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
    margin-top: 16px;
  }

  .settings-section-title:first-child { margin-top: 0; }

  .settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }

  .settings-row label {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
  }

  .settings-row .input-field {
    margin-bottom: 0;
    width: auto;
    flex: 1;
    text-align: right;
  }

  .reminder-config-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 8px 10px;
    margin-bottom: 8px;
  }

  .reminder-config-name {
    font-size: 12px;
    color: var(--text);
    margin-bottom: 4px;
  }

  .reminder-config-sub {
    font-size: 11px;
    color: var(--muted);
  }

  .add-reminder-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 5px;
    border: 1px dashed var(--border);
    background: none;
    color: var(--muted);
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s;
  }

  .add-reminder-btn:hover { color: var(--text); border-color: var(--muted); }

  .day-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    transition: all 0.12s;
  }

  .day-chip input { display: none; }
  .day-chip.selected { background: var(--surface2); color: var(--text); border-color: var(--muted); }

  /* Toggle switch */
  .toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
  }

  .toggle {
    width: 28px;
    height: 16px;
    background: var(--surface2);
    border-radius: 8px;
    position: relative;
    border: 1px solid var(--border);
    transition: background 0.2s;
    flex-shrink: 0;
  }

  .toggle.on { background: var(--green); border-color: var(--green); }

  .toggle-knob {
    width: 10px;
    height: 10px;
    background: var(--muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
  }

  .toggle.on .toggle-knob { left: 14px; background: var(--bg); }

  .tab-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
  }

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE STYLES
   Breakpoints: 768px (tablet), 480px (phone)
═══════════════════════════════════════════ */

/* ── HAMBURGER BUTTON (hidden on desktop) ── */
.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  color: var(--muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-direction: column;
  transition: all 0.15s;
  flex-shrink: 0;
}

.hamburger-btn:hover { color: var(--text); border-color: var(--muted); }

.hamburger-line {
  display: block;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transition: all 0.2s;
}

/* ── SIDEBAR OVERLAY (mobile backdrop) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.25s;
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.15s;
  padding: 0 4px;
}

.mobile-nav-btn svg {
  width: 18px;
  height: 18px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.mobile-nav-btn.active {
  color: var(--text);
}

.mobile-nav-btn.active svg {
  opacity: 1;
}

/* ── TABLET (≤ 768px) ── */
@media (max-width: 768px) {

  :root {
    --sidebar-w: 240px;
    --header-h: 52px;
  }

  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  /* Header adjustments */
  header {
    padding: 0 14px;
    gap: 10px;
  }

  .hamburger-btn {
    display: flex;
  }

  .date-display {
    display: none;
  }

  /* Sidebar becomes a slide-over drawer */
  aside {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  aside.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }

  /* Main takes full width */
  main {
    width: 100%;
    padding: 16px 14px;
    padding-bottom: 80px; /* space for bottom nav */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Show mobile bottom nav */
  .mobile-bottom-nav {
    display: block;
  }

  /* Progress bar: stack on small screens */
  .progress-bar-wrap {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .progress-label {
    width: 100%;
    font-size: 10px;
  }

  .progress-track {
    order: 3;
    flex: none;
    width: 100%;
  }

  .progress-pct {
    margin-left: auto;
    font-size: 10px;
  }

  /* Home title */
  .day-label {
    font-size: 18px;
  }

  /* Section headers */
  .section-name {
    font-size: 10px;
  }

  /* Task rows */
  .task-row {
    padding: 8px 8px;
  }

  .task-name {
    font-size: 13px;
  }

  /* Always show edit/delete on mobile (no hover state) */
  .task-expand-btn,
  .task-delete-btn,
  .task-edit-btn {
    opacity: 0.7;
  }

  /* Log view */
  .log-day-group {
    padding-left: 8px;
  }

  .log-list-group {
    padding-left: 8px;
  }

  /* Analytics: week chart */
  .week-chart {
    height: 140px;
    gap: 6px;
  }

  .week-bar-pct {
    font-size: 9px;
  }

  /* Analytics: year grid — 4 cols on tablet */
  .year-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  /* Month grid */
  .month-cell {
    font-size: 9px;
  }

  /* Missed rows */
  .missed-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .missed-name {
    width: calc(100% - 40px);
  }

  .missed-tab {
    display: none;
  }

  /* Routine blocks */
  .routine-block-header {
    padding: 12px 12px;
  }

  /* Tab views */
  .tab-view-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }

  .tab-actions {
    flex-wrap: wrap;
  }

  .tab-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Modals: larger on tablet */
  .modal {
    width: calc(100vw - 48px);
    max-width: 400px;
  }

  /* Modal row: stack fields */
  .modal-row {
    flex-wrap: wrap;
  }

  .modal-row .input-field,
  .modal-row .select-field {
    flex: none;
    width: 100%;
  }

  /* Reminders panel */
  .reminders-panel {
    right: -14px;
    width: 260px;
  }

  /* Time status: shorter label */
  .time-status {
    padding: 4px 8px;
    font-size: 10px;
  }

  /* Analytics subnav: scrollable */
  .analytics-subnav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0;
    gap: 0;
    scrollbar-width: none;
  }

  .analytics-subnav::-webkit-scrollbar { display: none; }

  .analytics-tab {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 11px;
  }
}

/* ── PHONE (≤ 480px) ── */
@media (max-width: 480px) {

  :root {
    --header-h: 50px;
  }

  header {
    padding: 0 12px;
    gap: 8px;
  }

  .logo {
    font-size: 12px;
  }

  .time-readout {
    font-size: 11px;
  }

  /* Hide time status text on very small screens, keep dot only */
  #timeStatusText {
    display: none;
  }

  .time-status {
    padding: 5px 8px;
  }

  .settings-btn {
    display: none;
  }

  /* Main padding tighter */
  main {
    padding: 12px 12px 80px;
  }

  /* Progress bar */
  .progress-bar-wrap {
    padding: 8px 10px;
    margin-bottom: 14px;
  }

  /* Home header */
  .home-header {
    margin-bottom: 16px;
  }

  .day-label {
    font-size: 16px;
  }

  /* List sections */
  .list-section {
    margin-bottom: 16px;
  }

  /* Task items: larger tap targets */
  .task-row {
    padding: 10px 6px;
    min-height: 44px;
  }

  .checkbox {
    width: 18px;
    height: 18px;
  }

  /* Reorder buttons: hide on phone (too small) */
  .reorder-btns {
    display: none;
  }

  /* Week chart: compact */
  .week-chart {
    height: 120px;
    gap: 4px;
    padding: 0;
  }

  .week-bar-label {
    font-size: 9px;
  }

  /* Year grid: 3 cols on phone */
  .year-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .year-cell {
    padding: 8px 6px;
  }

  .year-cell-pct {
    font-size: 13px;
  }

  .year-cell-month {
    font-size: 9px;
  }

  /* Month view header: stack */
  .month-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Missed tasks: full width stat columns */
  .missed-stats {
    gap: 16px;
  }

  .missed-stat-val {
    font-size: 12px;
  }

  /* Tab view header */
  .tab-title {
    font-size: 16px;
  }

  /* Modals: full-width bottom sheet on phone */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
    padding: 20px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    /* Drag handle indicator */
    background-image: linear-gradient(var(--muted) 3px, transparent 3px);
    background-size: 36px 3px;
    background-repeat: no-repeat;
    background-position: center 10px;
    padding-top: 24px;
  }

  .modal-title {
    font-size: 14px;
    margin-top: 4px;
  }

  /* Input fields: larger touch target */
  .input-field, .select-field {
    padding: 12px 12px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Buttons: full width in footer on phone */
  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    padding: 13px;
    text-align: center;
    font-size: 13px;
  }

  /* Reminders panel: full width */
  .reminders-panel {
    position: fixed;
    top: auto;
    bottom: 70px;
    left: 12px;
    right: 12px;
    width: auto;
  }

  /* Sidebar: full width on small phones */
  :root {
    --sidebar-w: calc(100vw - 48px);
  }

  /* Log view: tighter */
  .log-week-group {
    margin-bottom: 20px;
  }

  .log-day-group {
    border-left-width: 1.5px;
  }

  .log-entry {
    padding: 6px 4px;
    min-height: 36px;
  }

  /* Analytics subnav: even smaller */
  .analytics-tab {
    padding: 8px 10px;
    font-size: 11px;
  }

  /* Time block headers */
  .time-block-label {
    font-size: 10px;
  }

  /* Add task row */
  .add-task-row {
    padding: 10px 8px;
    min-height: 44px;
  }

  .add-task-input {
    font-size: 14px;
  }

  /* Routine block */
  .routine-block-header {
    padding: 12px 10px;
    min-height: 48px;
  }

  .routine-block-name {
    font-size: 13px;
  }

  /* Day chips: bigger tap area */
  .day-chip {
    padding: 7px 10px;
    font-size: 12px;
  }

  /* Mobile bottom nav: safe area */
  .mobile-bottom-nav {
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav-btn {
    font-size: 8px;
    gap: 3px;
  }
}

/* ── LANDSCAPE PHONE ── */
@media (max-width: 768px) and (orientation: landscape) {
  main {
    padding-bottom: 70px;
  }

  .mobile-bottom-nav {
    height: 50px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal {
    width: calc(100vw - 40px);
    max-width: 500px;
    border-radius: 10px;
    padding: 16px;
    background-image: none;
    padding-bottom: 16px;
  }

  .modal-footer {
    flex-direction: row;
  }

  .modal-footer .btn {
    width: auto;
  }
}
