@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=Libre+Baskerville:wght@400;700&family=Source+Serif+4:wght@400;600;700&family=Playfair+Display:wght@400;600;700&family=Crimson+Pro:wght@400;600;700&display=swap');

:root {
    /* App font — changeable via Settings */
    --app-font: 'Libre Baskerville', Georgia, serif;
    --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-scale: 1;

    /* Backgrounds — warm cream */
    --bg: #faf9f7;
    --panel: #ffffff;
    --panel-2: #f5f3f0;
    --panel-3: #eae7e2;

    /* Text */
    --text: #1a1a2e;
    --text-secondary: #4a4a5e;
    --muted: #8e8ea0;

    /* Borders */
    --line: #e8e6e1;
    --line-hover: #d4d1cc;

    /* Accent — Ascanti steel blue (Palette B) */
    --accent: #3E63DD;
    --accent-hover: #4A70E8;
    --accent-subtle: rgba(62, 99, 221, 0.09);
    --accent-border: rgba(62, 99, 221, 0.25);
    --accent-glow: rgba(62, 99, 221, 0.18);
    /* Brand stamp — tiny gold used only for wordmark accent + rule under hero titles */
    --brand-stamp: #C9A961;

    /* Semantic */
    --accent-2: #06d6a0;
    --success: #06d6a0;
    --success-subtle: rgba(6, 214, 160, 0.08);
    --success-border: rgba(6, 214, 160, 0.25);
    --warn: #fbbf24;
    --warn-subtle: rgba(251, 191, 36, 0.08);
    --warn-border: rgba(251, 191, 36, 0.25);
    --danger: #ef4444;
    --danger-subtle: rgba(239, 68, 68, 0.08);
    --danger-border: rgba(239, 68, 68, 0.25);

    /* Dimension colors — vivid */
    --dim-career: #7c3aed;
    --dim-health: #06d6a0;
    --dim-relationships: #f472b6;
    --dim-finance: #fbbf24;
    --dim-growth: #a78bfa;
    --dim-creative: #fb923c;
    /* Planner-aligned dimension aliases */
    --dim-body:        #06d6a0;
    --dim-mind:        #a78bfa;
    --dim-spirit:      #f472b6;
    --dim-love:        #fb7185;
    --dim-family:      #f59e0b;
    --dim-community:   #34d399;
    --dim-money:       #fbbf24;
    --dim-work:        #7c3aed;
    --dim-hobbies:     #fb923c;

    /* Calendar heat-map */
    --cal-high: rgba(6, 214, 160, 0.30);
    --cal-mid: rgba(62, 99, 221, 0.25);
    --cal-low: rgba(251, 191, 36, 0.20);
    --cal-poor: rgba(239, 68, 68, 0.15);

    /* Sidebar */
    --sidebar-bg: #f5f3f0;
    --sidebar-text: #1a1a2e;
    --sidebar-text-muted: #6c6c82;
    --sidebar-hover: rgba(62, 99, 221, 0.08);
    --sidebar-active: rgba(62, 99, 221, 0.15);
    --sidebar-border: #e8e6e1;

    /* Sizing */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  }

  /* --- Dark Theme Override --- */

  [data-theme="dark"] {
    /* Backgrounds — cool neutral, no purple tint */
    --bg: #131316;
    --panel: #1c1c20;
    --panel-2: #232328;
    --panel-3: #2b2b30;

    /* Text — softer than pure white, neutral undertone */
    --text: #e4e4e8;
    --text-secondary: #8b8b94;
    --muted: #4e4e56;

    /* Borders — near-invisible luminance lines */
    --line: rgba(255, 255, 255, 0.06);
    --line-hover: rgba(255, 255, 255, 0.10);

    /* Accent — indigo, the one vivid color */
    --accent: #818cf8;
    --accent-hover: #6e7bf0;
    --accent-subtle: rgba(129, 140, 248, 0.10);
    --accent-border: rgba(129, 140, 248, 0.20);
    --accent-glow: rgba(129, 140, 248, 0.15);

    /* Semantic — desaturated for dark backgrounds */
    --accent-2: #34d399;
    --success: #34d399;
    --success-subtle: rgba(52, 211, 153, 0.10);
    --success-border: rgba(52, 211, 153, 0.20);
    --warn: #fbbf24;
    --warn-subtle: rgba(251, 191, 36, 0.08);
    --warn-border: rgba(251, 191, 36, 0.20);
    --danger: #f87171;
    --danger-subtle: rgba(248, 113, 113, 0.08);
    --danger-border: rgba(248, 113, 113, 0.20);

    /* Dimension colors — slightly desaturated for dark */
    --dim-career: #a78bfa;
    --dim-health: #34d399;
    --dim-relationships: #f472b6;
    --dim-finance: #e5ab20;
    --dim-growth: #b4a0f0;
    --dim-creative: #e88a3a;

    /* Calendar heat-map */
    --cal-high: rgba(52, 211, 153, 0.25);
    --cal-mid: rgba(129, 140, 248, 0.20);
    --cal-low: rgba(251, 191, 36, 0.18);
    --cal-poor: rgba(248, 113, 113, 0.15);

    /* Sidebar — one step darker than main bg */
    --sidebar-bg: #0e0e12;
    --sidebar-text: #d0d0d8;
    --sidebar-text-muted: #5a5a64;
    --sidebar-hover: rgba(129, 140, 248, 0.08);
    --sidebar-active: rgba(129, 140, 248, 0.14);
    --sidebar-border: transparent;

    /* Shadows — softer, less muddy */
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.35);
  }

  [data-theme="planner"] {
    --bg: #F7F3E9;
    --panel: #FDFAF4;
    --panel-2: #EDE8DA;
    --panel-3: #E2DAC8;

    --text: #2C1D0E;
    --text-secondary: #5C4033;
    --muted: #9A8C7E;

    --line: rgba(160, 138, 110, 0.45);
    --line-hover: rgba(140, 110, 80, 0.65);

    --accent: #8B5E3C;
    --accent-hover: #6B4226;
    --accent-subtle: rgba(139, 94, 60, 0.10);
    --accent-border: rgba(139, 94, 60, 0.28);
    --accent-glow: rgba(139, 94, 60, 0.18);

    --accent-2: #5C7A52;
    --success: #5C7A52;
    --success-subtle: rgba(92, 122, 82, 0.12);
    --success-border: rgba(92, 122, 82, 0.30);
    --warn: #C9953A;
    --warn-subtle: rgba(201, 149, 58, 0.12);
    --warn-border: rgba(201, 149, 58, 0.30);
    --danger: #B34A3A;
    --danger-subtle: rgba(179, 74, 58, 0.10);
    --danger-border: rgba(179, 74, 58, 0.30);

    --dim-career: #7B5EA7;
    --dim-health: #5C7A52;
    --dim-relationships: #C47A8A;
    --dim-finance: #C9953A;
    --dim-growth: #8B6B9E;
    --dim-creative: #C4703A;

    --cal-high: rgba(92, 122, 82, 0.30);
    --cal-mid: rgba(139, 94, 60, 0.25);
    --cal-low: rgba(201, 149, 58, 0.22);
    --cal-poor: rgba(179, 74, 58, 0.18);

    --sidebar-bg: #1E1108;
    --sidebar-text: #D4C9B5;
    --sidebar-text-muted: #8B7A6A;
    --sidebar-hover: rgba(212, 195, 165, 0.10);
    --sidebar-active: rgba(212, 195, 165, 0.22);

    --shadow: 0 1px 2px rgba(44, 29, 14, 0.06);
    --shadow-md: 0 2px 8px rgba(44, 29, 14, 0.09), 0 1px 2px rgba(44, 29, 14, 0.05);
    --shadow-lg: 0 4px 16px rgba(44, 29, 14, 0.13);
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    font-family: var(--app-font, 'Libre Baskerville', Georgia, serif);
    font-size: calc(16px * var(--font-scale, 1));
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

  button {
    font: inherit;
  }

  /* --- Layout --- */

  .app-shell {
    display: flex;
    min-height: 100vh;
  }

  /* --- Planner full-viewport: hide sidebar + main padding --- */
  body.planner-active .sidebar { display: none; }
  body.planner-active .main-area { margin-left: 0; }

  /* --- Sidebar --- */

  .sidebar {
    font-family: var(--ui-font);
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-border, rgba(0, 0, 0, 0.08));
  }

  [data-theme="dark"] .sidebar {
    background: var(--sidebar-bg);
  }

  .sidebar-profile {
    padding: 24px 16px 16px;
    text-align: center;
    border-bottom: none;
  }

  .sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--dim-growth));
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
  }

  .sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
  }

  .sidebar-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--sidebar-text);
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    flex: 1;
  }

  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--sidebar-text-muted);
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s;
    font-family: inherit;
  }

  .sidebar-nav-item svg {
    flex-shrink: 0;
    opacity: 0.6;
  }

  .sidebar-nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
  }

  .sidebar-nav-item:hover svg {
    opacity: 0.9;
  }

  .sidebar-nav-item.active {
    background: var(--sidebar-active);
    color: var(--accent);
    font-weight: 600;
    box-shadow: none;
  }

  [data-theme="dark"] .sidebar-nav-item.active {
    color: #fff;
  }

  .sidebar-nav-item.active svg {
    opacity: 1;
  }

  .empty-state-action {
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 16px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
    text-align: center;
  }

  .empty-state-action:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--accent);
  }

  /* Collapsed sidebar */
  .sidebar.collapsed {
    width: 56px;
    min-width: 56px;
  }

  .sidebar.collapsed ~ .main-area {
    margin-left: 56px;
  }

  .sidebar.collapsed .sidebar-profile {
    padding: 16px 8px 12px;
  }

  .sidebar.collapsed .sidebar-name,
  .sidebar.collapsed .sidebar-section-label,
  .sidebar.collapsed .sidebar-badge,
  .sidebar.collapsed .notif-panel,
  .sidebar.collapsed .notif-bell {
    display: none;
  }

  .sidebar.collapsed .sidebar-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border-radius: 10px;
  }

  .sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 10px 0;
  }

  .sidebar.collapsed .sidebar-nav-item span:not(.sidebar-badge) {
    display: none;
  }

  .sidebar.collapsed .sidebar-nav-item svg {
    margin: 0;
  }

  .sidebar-collapse-btn {
    background: var(--sidebar-bg, #16132b);
    border: none;
    color: var(--sidebar-text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 16px;
    text-align: center;
    transition: color 0.15s;
    border-top: none;
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
  }

  .sidebar-collapse-btn:hover {
    color: var(--sidebar-text);
  }

  .sidebar-nav-item.sidebar-utility {
    font-size: 12px;
    padding: 6px 16px;
    opacity: 0.6;
  }

  .sidebar-nav-item.sidebar-utility svg {
    width: 14px;
    height: 14px;
  }

  .sidebar-nav-item.sidebar-utility:hover {
    opacity: 1;
  }

  .sidebar-nav-item.sidebar-utility.active {
    opacity: 1;
  }

  .sidebar-section-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-text-muted);
    opacity: 0.75;
    padding: 16px 16px 4px;
    margin: 0;
  }

  .sidebar-section-label:first-child {
    padding-top: 4px;
  }

  /* Kill all sidebar internal lines/borders */
  .sidebar-nav > * {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
  }

  .sidebar-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    line-height: 16px;
  }

  /* --- Main Area --- */

  .main-area {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
  }

  .top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.85);
  }

  [data-theme="dark"] .top-bar {
    background: rgba(19, 19, 22, 0.85);
  }

  .hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
  }

  .top-bar-prompt {
    flex: 1;
    color: var(--muted);
    font-size: 16px;
  }

  .top-bar-prompt input {
    color: var(--text) !important;
  }

  .top-bar-prompt input::placeholder {
    color: var(--muted);
    font-style: italic;
  }

  .top-bar-prompt input:focus {
    color: var(--text);
    font-style: normal;
  }

  .top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .content {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
  }

  .eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  h1, h2, h3 {
    font-family: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
    letter-spacing: -0.03em;
  }

  h1 {
    margin: 0 0 4px;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
  }

  h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.25;
  }

  h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
    line-height: 1.3;
  }

  .subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    max-width: 760px;
  }

  /* Old layout classes removed — see sidebar/main-area above */

  .view {
    display: none;
  }

  .view.active {
    display: block;
  }

  /* --- Cards --- */

  .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
  }

  .card + .card {
    margin-top: 8px;
  }

  .card h2,
  .card h3 {
    margin-top: 0;
  }

  /* --- Grid --- */

  .grid {
    display: grid;
    gap: 12px;
  }

  .grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* --- Metrics --- */

  .metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .metric-value {
    font-size: 26px;
    font-weight: 700;
  }

  .metric-label {
    color: var(--muted);
    font-size: 14px;
  }

  /* --- Lists --- */

  .list {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .list-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--panel-2);
    transition: border-color 0.1s;
  }

  .list-item:hover {
    border-color: var(--line-hover);
  }

  .list-item strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
  }

  /* --- Badges --- */

  .badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
  }

  .badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--ui-font);
    border: 1px solid var(--line);
    color: var(--text-secondary);
  }

  .badge.goal {
    color: var(--accent);
    border-color: var(--accent-border);
  }

  .badge.non-goal {
    color: var(--warn);
    border-color: var(--warn-border);
  }

  .badge.on-track {
    color: var(--success);
    border-color: var(--success-border);
  }

  .badge.at-risk {
    color: var(--danger);
    border-color: var(--danger-border);
  }

  .badge.in-progress-badge {
    color: var(--accent);
    border-color: var(--accent-border);
  }

  .badge.carry-badge {
    color: var(--warn);
    border-color: var(--warn-border);
  }

  /* --- Buttons --- */

  /* ── Theme swatches (Settings › Appearance) ── */
  .theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    transition: border-color 150ms, transform 100ms;
  }
  .theme-swatch:hover { border-color: var(--accent); transform: translateY(-1px); }
  .theme-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
  .theme-swatch-preview {
    width: 120px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
  }
  .theme-swatch-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
  }
  .theme-swatch.active .theme-swatch-label { color: var(--accent); }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    color: var(--text-secondary);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--ui-font);
    transition: all 0.15s;
  }

  .btn:hover {
    background: var(--panel-2);
    border-color: var(--line-hover);
    color: var(--text);
    box-shadow: var(--shadow);
  }

  .btn.primary {
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px var(--accent-glow);
  }

  .btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
  }

  .btn.primary:active {
    transform: translateY(0);
  }

  .btn.danger {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.3);
  }

  .btn.danger:hover {
    background: var(--danger-subtle);
  }

  /* --- Text --- */

  .muted {
    color: var(--muted);
    font-size: 15px;
  }

  .week-id {
    color: var(--muted);
    font-size: 15px;
    margin: 0 0 8px;
  }

  /* --- Forms --- */

  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  textarea,
  select {
    background: var(--panel);
    color: var(--text);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--ui-font);
    font-size: 14px;
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s;
  }

  input:focus,
  textarea:focus,
  select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
  }

  [data-theme="dark"] input[type="date"],
  [data-theme="dark"] input[type="time"],
  [data-theme="dark"] input[type="datetime-local"] {
    color-scheme: dark;
  }

  input::placeholder,
  textarea::placeholder {
    color: var(--muted);
  }

  /* --- Week Bar --- */

  .week-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .week-bar .week-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.1s;
  }

  .week-bar .week-chip:hover {
    background: var(--panel-2);
    color: var(--text);
  }

  .week-bar .week-chip.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
  }

  .week-bar .week-chip.current {
    border-color: rgba(74, 222, 128, 0.3);
  }

  .week-bar .week-chip.current.active {
    border-color: var(--accent-border);
  }

  .week-bar-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-right: 4px;
  }

  /* --- Progress --- */

  .progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--panel-3);
    border-radius: 3px;
    margin: 6px 0;
    overflow: hidden;
  }

  .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius: 3px;
    transition: width 0.3s ease;
  }

  .progress-bar.complete {
    background: var(--success);
  }

  .execution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
  }

  /* --- Trend chart --- */

  .trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding: 12px 0;
  }

  .trend-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 28px;
  }

  .trend-bar-track {
    width: 100%;
    max-width: 36px;
    height: 100px;
    background: var(--panel-2);
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
  }

  .trend-bar-fill {
    width: 100%;
    background: var(--accent);
    border-radius: var(--radius-sm);
    transition: height 0.3s ease;
    min-height: 2px;
  }

  .trend-bar-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
  }

  .trend-bar-value {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
  }

  /* --- Habit --- */

  .habit-count {
    font-size: 18px;
    font-weight: 700;
    min-width: 52px;
    text-align: center;
  }

  .habit-tap-btn {
    min-width: 48px;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .habit-tap-btn:active {
    transform: scale(0.95);
  }

  /* --- Habit 7-day grid --- */

  .habit-day-grid {
    display: flex;
    gap: 6px;
    justify-content: space-between;
    margin-bottom: 6px;
  }

  .habit-day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
  }

  .habit-day-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    padding: 0;
  }

  .habit-day-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
  }

  .habit-day-btn:active {
    transform: scale(0.9);
  }

  .habit-day-btn.active {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
  }

  .habit-day-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .habit-streak {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-subtle);
    border: 1px solid var(--success-border);
    border-radius: 999px;
    padding: 1px 7px;
    white-space: nowrap;
  }

  /* --- Status cycling --- */

  .status-cycle-btn {
    cursor: pointer;
    font-size: 14px;
    padding: 4px 10px;
    transition: all 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .status-cycle-btn:active {
    transform: scale(0.95);
  }

  .item-done {
    opacity: 0.5;
  }

  .item-carry-warning {
    border-color: var(--warn-border) !important;
  }

  /* --- Alert --- */

  .alert {
    background: var(--warn-subtle);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--warn);
    font-size: 14px;
    font-weight: 500;
  }

  /* --- Phase banner --- */

  .phase-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 500;
  }

  .phase-planning {
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    color: var(--accent);
  }

  .phase-execution {
    background: var(--success-subtle);
    border: 1px solid rgba(74, 222, 128, 0.2);
    color: var(--success);
  }

  .phase-review {
    background: var(--warn-subtle);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--warn);
  }

  .phase-action {
    white-space: nowrap;
  }

  /* --- Quick-add --- */

  .quick-add {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
  }

  .quick-add input {
    flex: 1;
  }

  /* --- Goal health grid --- */

  .goal-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
  }

  .goal-health-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: var(--panel-2);
  }

  .goal-health-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
  }

  /* --- Goal tree hierarchy --- */

  .goal-tree-node {
    transition: margin-left 0.2s;
  }

  .goal-tree-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .goal-tree-header:hover {
    opacity: 0.85;
  }

  .goal-tree-chevron {
    font-size: 12px;
    transition: transform 0.2s;
    color: var(--muted);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
  }

  .goal-tree-chevron.expanded {
    transform: rotate(90deg);
  }

  .goal-tree-children {
    display: none;
  }

  .goal-tree-children.open {
    display: block;
  }

  .timeframe-badge {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
  }

  .timeframe-annual {
    background: var(--accent-subtle);
    color: var(--accent);
  }

  .timeframe-quarterly {
    background: var(--success-subtle);
    color: var(--success);
  }

  .timeframe-monthly {
    background: var(--warn-subtle);
    color: var(--warn);
  }

  /* --- Dimension cards --- */

  .dimension-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
  }

  .dimension-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--dim-color, var(--muted));
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
  }

  .dimension-card:hover {
    background: var(--panel-2);
    border-color: var(--line-hover);
    border-left-color: var(--dim-color, var(--muted));
  }

  .dimension-card.expanded {
    border-left-width: 3px;
    cursor: default;
  }

  .dimension-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .dimension-label {
    font-weight: 600;
    font-size: 16px;
  }

  .dimension-count {
    font-size: 14px;
    color: var(--muted);
  }

  .dimension-detail {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .dimension-prompts {
    font-size: 14px;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 10px;
  }

  .goal-cascade {
    margin-top: 8px;
  }

  .goal-cascade-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .goal-cascade-item:last-child {
    border-bottom: none;
  }

  .goal-cascade-children {
    padding-left: 16px;
    margin-top: 4px;
  }

  .goal-cascade-child {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 14px;
    color: var(--text-secondary);
  }

  .goal-cascade-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  /* --- Calendar view --- */

  .calendar-grid {
    display: grid;
    grid-template-columns: 44px repeat(5, 1fr) minmax(120px, 180px);
    gap: 2px;
    align-items: center;
  }

  .calendar-col-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 0;
  }

  .calendar-month-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 4px 0;
  }

  .calendar-week-cell {
    border-radius: var(--radius-sm);
    padding: 6px 2px;
    min-height: 32px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
  }

  .calendar-week-cell:hover {
    border-color: var(--accent);
  }

  .calendar-week-cell.empty {
    opacity: 0.15;
    cursor: default;
  }

  .calendar-week-cell.empty:hover {
    border-color: transparent;
  }

  .calendar-week-cell.current-week {
    border: 2px solid var(--accent);
  }

  .calendar-quarter-band {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: 15px;
  }

  .calendar-month-goals {
    font-size: 13px;
    padding: 2px 6px;
  }

  .mini-progress {
    height: 3px;
    border-radius: 2px;
    background: var(--panel-2);
    margin-top: 2px;
    overflow: hidden;
  }

  .mini-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--success);
    transition: width 0.3s;
  }

  .calendar-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  .calendar-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    margin-left: 6px;
  }

  /* --- Review prompts --- */

  .review-prompt {
    color: var(--muted);
    font-size: 14px;
    margin: 2px 0 6px;
    font-style: italic;
  }

  /* --- Toast --- */

  .toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
  }

  .toast.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .toast.success {
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--success);
  }

  .toast.error {
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--danger);
  }

  .toast-message {
    flex: 1;
  }

  .toast-action {
    background: none;
    border: 1px solid currentColor;
    color: inherit;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
  }

  .toast-action:hover {
    opacity: 0.8;
  }

  .toast-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    font-family: inherit;
  }

  .toast-close:hover {
    color: var(--text);
  }

  /* --- Empty state --- */

  .empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
  }

  .empty-state h3 {
    color: var(--text);
    margin-bottom: 6px;
  }

  .empty-state .btn {
    margin-top: 12px;
  }

  /* --- Dashboard header --- */

  .dash-header {
    margin-bottom: 4px;
  }

  /* --- Dashboard 3-column grid --- */

  .dashboard-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(340px, 1.5fr) minmax(220px, 1fr);
    gap: 16px;
    align-items: start;
  }

  .dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Goal widget cards */
  .goal-widget {
    padding: 12px 14px;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    transition: transform 0.1s, box-shadow 0.1s;
  }

  .goal-widget:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }

  .goal-widget .widget-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.3;
  }

  .goal-widget .widget-value {
    font-size: 26px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    line-height: 1;
    margin: 4px 0 2px;
  }

  .goal-widget .widget-target {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 10px;
  }

  /* Tasks card in dashboard */
  .dash-tasks-card {
    max-height: none;
  }

  .dash-tasks-card .list-item {
    padding: 8px 4px;
  }

  .dash-habits-card .list > div {
    padding: 6px 0;
  }

  /* Two-panel layout for filter views */
  .panel-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
  }

  .filter-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 76px;
  }

  .filter-panel h4 {
    margin: 0 0 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    font-family: 'Inter', sans-serif;
  }

  .filter-panel .filter-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 6px 10px;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-family: inherit;
    transition: background 0.1s;
  }

  .filter-panel .filter-item:hover {
    background: var(--panel-2);
  }

  .filter-panel .filter-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
  }

  /* Goal card with progress bar */
  .goal-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .goal-row:last-child {
    border-bottom: none;
  }

  .goal-row.sub-goal {
    padding-left: 40px;
  }

  .goal-progress-bar {
    width: 120px;
    height: 8px;
    background: var(--panel-2);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
  }

  .goal-progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 4px;
    transition: width 0.3s;
  }

  .goal-pct {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
  }

  /* Habit month calendar grid */
  .habit-month-grid {
    display: grid;
    grid-template-columns: 180px repeat(auto-fill, 28px);
    gap: 2px;
    align-items: center;
  }

  .habit-month-header {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    padding: 4px 0;
  }

  .habit-month-cell {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.1s;
  }

  .habit-month-cell:hover {
    background: var(--panel-2);
  }

  .habit-month-cell.checked {
    background: var(--success);
    color: white;
    font-weight: 600;
  }

  .habit-month-name {
    font-size: 15px;
    font-weight: 500;
    padding: 6px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .habit-month-name:hover .habit-edit-btn {
    opacity: 1 !important;
  }

  /* Journal */
  .journal-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
  }

  .journal-entry-card {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.1s;
  }

  .journal-entry-card:hover {
    background: var(--panel-2);
  }

  .journal-date-badge {
    width: 48px;
    height: 48px;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .journal-date-badge .day {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
  }

  .journal-date-badge .month {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--accent);
  }

  /* Goals page layout */
  .goals-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
  }

  @media (max-width: 900px) {
    .goals-layout { grid-template-columns: 1fr; }
  }

  .goals-filter-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 76px;
  }

  .goals-filter-panel h4 {
    margin: 0 0 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
  }

  .goals-filter-panel details[open] > summary .gf-chevron {
    transform: rotate(90deg);
  }

  .goals-filter-panel summary::-webkit-details-marker { display: none; }

  .gf-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
  }

  .gf-item:hover { background: var(--panel-2); }
  .gf-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }

  .gf-item .gf-count {
    background: var(--panel-3);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .gf-item.active .gf-count {
    background: var(--accent-subtle);
    color: var(--accent);
  }

  /* Goal row in list */
  .goal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    transition: background 0.1s;
    cursor: pointer;
    background: var(--panel);
  }

  .goal-item:hover { background: var(--panel-2); }
  .goal-item:last-child { border-bottom: none; }

  .goal-item.sub-goal { padding-left: 44px; background: var(--bg); }
  .goal-item.sub-sub-goal { padding-left: 64px; background: var(--bg); }

  .goal-status-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
  }

  .goal-status-icon.up { background: var(--success-subtle); color: var(--success); }
  .goal-status-icon.flat { background: var(--panel-3); color: var(--text-secondary); }
  .goal-status-icon.down { background: var(--danger-subtle); color: var(--danger); }
  .goal-status-icon.done { background: var(--success); color: white; }

  .goal-item-info { flex: 1; min-width: 0; }

  .goal-item-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
  }

  .goal-item.sub-goal .goal-item-title { font-size: 15px; font-weight: 500; color: var(--text-secondary); }

  .goal-item-meta {
    font-size: 14px;
    color: var(--text-secondary);
  }

  .goal-item-progress {
    width: 140px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .goal-item-progress .gip-bar {
    flex: 1;
    height: 18px;
    background: var(--panel-3);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
  }

  .goal-item-progress .gip-fill {
    height: 100%;
    background: var(--success);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    min-width: 20px;
    transition: width 0.3s;
  }

  .goal-children-group {
    border-left: 3px solid var(--accent-border);
    margin-left: 14px;
  }

  .goal-chevron-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
  }

  .goal-chevron-toggle:hover {
    background: var(--panel-3) !important;
    color: var(--text) !important;
  }

  .goal-item-progress .gip-pct {
    font-size: 14px;
    font-weight: 700;
    min-width: 32px;
    text-align: right;
    color: var(--text);
  }

  /* Goal edit form */
  .goal-edit-form {
    max-width: 700px;
  }

  .goal-edit-row {
    display: flex;
    align-items: start;
    gap: 16px;
    margin-bottom: 12px;
  }

  .goal-edit-row label {
    width: 120px;
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-top: 8px;
    text-align: right;
  }

  .goal-edit-row .field { flex: 1; }

  .goal-desc-tabs {
    display: flex;
    border-bottom: 2px solid var(--line);
    margin-bottom: 8px;
  }

  .goal-desc-tab {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
    transition: color 0.1s;
  }

  .goal-desc-tab:hover { color: var(--text); }
  .goal-desc-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* Task row overflow fix */
  .task-row {
    max-width: 100%;
    overflow: hidden;
    flex-wrap: wrap;
  }

  .task-row select {
    max-width: 70px;
  }

  .content {
    overflow-x: hidden;
    max-width: 100%;
  }

  .main-area {
    overflow-x: hidden;
  }

  /* Task filter bar responsive */
  .task-filters-bar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
  }

  @media (max-width: 900px) {
    .task-row .badge {
      display: none;
    }
    .task-row .task-assign-goal {
      display: none;
    }
    .task-row {
      gap: 4px !important;
      padding: 6px 2px !important;
    }
  }

  @media (max-width: 600px) {
    .task-row .task-focus-btn {
      display: none;
    }
  }

  /* Kanban board */
  .kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: start;
  }

  .kanban-column {
    background: var(--panel-2);
    border-radius: var(--radius);
    min-height: 120px;
  }

  .kanban-column-header {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .kanban-column-header .count {
    background: var(--panel-3);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
  }

  .kanban-card {
    margin: 6px 8px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: box-shadow 0.1s;
  }

  .kanban-card:hover {
    box-shadow: var(--shadow);
  }

  .kanban-card .kanban-priority {
    font-size: 12px;
    font-weight: 700;
  }

  .kanban-card .kanban-meta {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
  }

  /* Task calendar */
  .task-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }

  .task-cal-header {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 0;
  }

  .task-cal-day {
    min-height: 80px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px;
    font-size: 13px;
  }

  .task-cal-day.today {
    border-color: var(--accent);
    background: var(--accent-subtle);
  }

  .task-cal-day.other-month {
    opacity: 0.3;
  }

  .task-cal-day .day-number {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
  }

  .task-cal-item {
    padding: 2px 4px;
    margin-bottom: 2px;
    border-radius: 3px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }

  .task-cal-item[draggable="true"] {
    cursor: grab;
  }

  .task-cal-item[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.5;
  }

  .task-cal-item.p1 { background: var(--danger-subtle); color: var(--danger); }
  .task-cal-item.p2 { background: var(--warn-subtle); color: var(--warn); }
  .task-cal-item.p3 { background: var(--accent-subtle); color: var(--accent); }
  .task-cal-item.p4 { background: var(--panel-2); color: var(--text-secondary); }

  /* View mode toggles */
  .view-mode-btn {
    padding: 4px 10px;
    font-size: 13px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.1s;
  }

  .view-mode-btn:first-child { border-radius: 6px 0 0 6px; }
  .view-mode-btn:last-child { border-radius: 0 6px 6px 0; }
  .view-mode-btn:not(:first-child) { border-left: none; }

  .view-mode-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  /* Vision board */
  .vision-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .vision-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    position: relative;
  }

  .vision-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
  }

  .vision-card .vision-caption {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-secondary);
  }

  .vision-card .vision-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  .vision-card:hover .vision-delete {
    display: flex;
  }

  /* Reports metrics */
  .metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .metric-card {
    padding: 20px 16px;
    text-align: center;
    min-width: 0;
  }

  .metric-card .metric-icon {
    font-size: 26px;
    margin-bottom: 4px;
    opacity: 0.6;
  }

  .metric-card .metric-big {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
  }

  .metric-card .metric-desc {
    font-size: 14px;
    color: var(--text-secondary);
  }

  /* --- Goal Timeline --- */

  .timeline-node:hover {
    transform: scale(1.4);
    z-index: 2;
    box-shadow: 0 0 0 3px var(--panel), 0 0 8px rgba(0,0,0,0.15);
  }

  .timeline-lane:hover {
    background: var(--panel-2);
    border-radius: var(--radius-sm);
  }

  /* --- Goal Coach Chat --- */

  .coach-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
  }
  .coach-overlay.open { display: flex; }

  .coach-panel {
    width: 460px;
    max-width: 100vw;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  }

  .coach-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }

  .coach-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .coach-msg {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: calc(15px * var(--font-scale, 1));
    line-height: 1.6;
    word-wrap: break-word;
  }
  .coach-msg.assistant {
    align-self: flex-start;
    background: var(--panel-2);
    color: var(--text);
    border-bottom-left-radius: 4px;
  }
  .coach-msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
  }

  .coach-msg p { margin: 0 0 8px; }
  .coach-msg p:last-child { margin: 0; }
  .coach-msg strong { font-weight: 600; }

  .coach-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--panel-2);
    border-radius: 12px;
    font-size: 15px;
    color: var(--muted);
    display: none;
  }
  .coach-typing.active { display: block; }

  .coach-goal-card {
    background: var(--success-subtle);
    border: 1px solid var(--success-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
  }
  .coach-goal-card h4 {
    margin: 0 0 6px;
    font-size: 16px;
    color: var(--success);
  }
  .coach-goal-card .goal-detail {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 2px 0;
  }

  .coach-input-area {
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
  }
  .coach-input-area input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--line);
    font-size: 15px;
    background: var(--bg);
  }
  .coach-input-area input:focus {
    outline: none;
    border-color: var(--accent);
  }
  .coach-input-area button {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
  }
  .coach-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  @media (max-width: 600px) {
    .coach-panel { width: 100vw; }
  }

  /* --- Goal Workshop Wizard --- */

  .wizard {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .wizard-progress {
    text-align: center;
    padding: 4px 0;
  }

  .wizard-progress-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 6px;
  }

  .wizard-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--panel-2);
    color: var(--muted);
    border: 2px solid var(--line);
    transition: all 0.2s;
  }

  .wizard-step-dot.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  .wizard-step-dot.completed {
    background: var(--success-subtle);
    color: var(--success);
    border-color: rgba(74, 222, 128, 0.3);
  }

  .wizard-step-connector {
    width: 28px;
    height: 2px;
    background: var(--line);
    flex-shrink: 0;
  }

  .wizard-step-connector.completed {
    background: rgba(74, 222, 128, 0.3);
  }

  .wizard-step-label {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
  }

  .wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
  }

  .wizard-coaching {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
  }

  .wizard-exit {
    font-size: 14px;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
  }

  .wizard-exit:hover {
    color: var(--danger);
  }

  /* Assessment bars */
  .assessment-row {
    display: grid;
    grid-template-columns: 140px 1fr 32px;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .assessment-row:last-child {
    border-bottom: none;
  }

  .assessment-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
  }

  .assessment-dim-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .assessment-bar-track {
    height: 8px;
    background: var(--panel-2);
    border-radius: 4px;
    overflow: hidden;
  }

  .assessment-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.2s ease;
    min-width: 2px;
  }

  .assessment-score {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    min-width: 28px;
  }

  .assessment-slider {
    grid-column: 2;
    width: 100%;
    accent-color: var(--accent);
    margin: 0;
  }

  /* Focus area selection cards */
  .focus-card {
    padding: 12px 16px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .focus-card:hover {
    border-color: var(--line-hover);
    background: var(--panel-2);
  }

  .focus-card.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
  }

  /* SMARTER coaching list */
  .smarter-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
  }

  .smarter-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
  }

  .smarter-letter {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    background: var(--panel-2);
    color: var(--muted);
    flex-shrink: 0;
  }

  .smarter-letter.checked {
    background: var(--success-subtle);
    color: var(--success);
  }

  .smarter-letter.nudge {
    background: var(--warn-subtle);
    color: var(--warn);
  }

  /* Wizard goal summary cards */
  .wizard-goal-summary {
    border-left: 3px solid var(--dim-color, var(--accent));
    padding: 12px 16px;
    background: var(--panel-2);
    border-radius: var(--radius);
    margin-bottom: 8px;
  }

  .wizard-goal-summary h4 {
    margin: 0 0 4px;
    font-size: 16px;
  }

  /* --- Responsive --- */

  @media (max-width: 900px) {
    .sidebar {
      transform: translateX(-100%);
      transition: transform 0.25s ease;
    }

    .sidebar.open {
      transform: translateX(0);
    }

    .sidebar-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.4);
      z-index: 99;
      display: none;
    }

    .sidebar-backdrop.open {
      display: block;
    }

    .main-area {
      margin-left: 0;
    }

    .hamburger {
      display: flex;
    }

    .content {
      padding: 16px;
    }

    .dashboard-grid {
      grid-template-columns: 1fr;
    }

    .panel-layout {
      grid-template-columns: 1fr;
    }

    .journal-layout {
      grid-template-columns: 1fr;
    }

    .filter-panel {
      position: static;
    }

    .grid.two,
    .grid.three {
      grid-template-columns: 1fr;
    }

    h1 {
      font-size: 24px;
    }

    .week-bar {
      padding: 8px 10px;
      gap: 4px;
    }

    .trend-chart {
      height: 120px;
    }

    .toast {
      left: 12px;
      right: 12px;
      bottom: 16px;
    }

    .dimension-grid {
      grid-template-columns: 1fr;
    }

    .commitment-row .grid.two {
      grid-template-columns: 1fr;
    }

    .habit-month-grid {
      grid-template-columns: 120px repeat(auto-fill, 24px);
    }

    .habit-month-cell {
      width: 24px;
      height: 24px;
      font-size: 12px;
    }

    /* Kanban: horizontal scroll on mobile */
    .kanban-board {
      grid-template-columns: 1fr;
    }

    .kanban-column {
      min-height: auto;
    }

    /* Calendar: smaller cells on mobile */
    .task-cal-day {
      min-height: 50px;
      font-size: 12px;
    }

    .task-cal-item {
      font-size: 11px;
      padding: 1px 3px;
    }

    .task-cal-header {
      font-size: 12px;
    }

    /* Better touch targets */
    .sidebar-nav-item {
      padding: 12px 14px;
    }

    .btn {
      min-height: 36px;
      padding: 8px 14px;
    }

    /* Top bar compact */
    .top-bar {
      padding: 8px 12px;
    }

    .top-bar-prompt {
      font-size: 14px;
    }

    .search-bar input {
      width: 100px;
    }

    /* Vision grid: 2 columns on mobile */
    .vision-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }

    .vision-card img {
      height: 100px;
    }

    /* Radar chart responsive */
    .card svg {
      max-width: 100%;
      height: auto;
    }

    /* Assessment sliders: full width */
    .wizard-dim-section {
      margin-top: 8px !important;
    }

    /* Goal widget compact */
    .goal-widget .widget-value {
      font-size: 22px;
    }

    /* Metrics row */
    .metrics-row {
      gap: 8px;
    }

    .metric-card .metric-big {
      font-size: 24px;
    }

    /* View mode buttons */
    .view-mode-btn {
      padding: 6px 8px;
      font-size: 12px;
    }
  }

  /* --- Animations (4d) --- */

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .fade-in {
    animation: fadeIn 0.25s ease-out;
  }

  .view {
    display: none;
    transition: opacity 0.15s ease;
  }

  .view.active {
    display: block;
  }

  .badge {
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }

  /* --- Drag and drop (3e) --- */

  .drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 16px;
    user-select: none;
    flex-shrink: 0;
    line-height: 1;
  }

  .drag-handle:active {
    cursor: grabbing;
  }

  .commitment-row.dragging {
    opacity: 0.4;
  }

  .commitment-row.drag-over {
    border-color: var(--accent);
    border-top: 2px solid var(--accent);
  }

  .commitment-row[draggable="true"] {
    touch-action: none;
  }

  /* --- Mood selector (3b) --- */

  .mood-btn {
    font-size: 24px;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    line-height: 1;
  }

  .mood-btn:hover {
    background: var(--panel-3);
    transform: scale(1.1);
  }

  .mood-btn.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
  }

  /* --- Week bar earlier dropdown (3f) --- */

  .week-bar-earlier-wrap {
    position: relative;
  }

  .week-earlier-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    min-width: 140px;
    margin-top: 4px;
  }

  .week-earlier-dropdown.open {
    display: block;
  }

  .week-earlier-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: background 0.1s;
  }

  .week-earlier-item:last-child {
    border-bottom: none;
  }

  .week-earlier-item:hover {
    background: var(--panel-2);
  }

  /* --- Week bar scroll (4b) --- */

  .week-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .week-bar::-webkit-scrollbar {
    display: none;
  }

  /* --- Sticky quick-add --- */

  .sticky-quick-add {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--panel);
    padding: 8px 0;
  }

  /* --- Daily quote --- */

  .daily-quote {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-secondary);
    border-left: 2px solid var(--accent-border);
    line-height: 1.5;
  }

  /* --- Plan summary on dashboard --- */

  .plan-summary {
    border-left: 3px solid var(--accent);
  }

  .plan-success-callout {
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 15px;
  }

  .plan-priority-list, .plan-risk-list {
    margin: 4px 0 0 16px;
    padding: 0;
    font-size: 15px;
  }

  .plan-priority-list li, .plan-risk-list li {
    margin-bottom: 2px;
  }

  .plan-risk-list li {
    color: var(--warn);
  }

  /* --- Daily focus panel --- */

  .daily-focus-panel {
    max-width: 640px;
    margin: 0 auto;
  }

  .daily-focus-panel h2 {
    margin: 0 0 4px;
  }

  .focus-context-section {
    margin-top: 12px;
  }

  .focus-context-section h4 {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .focus-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 15px;
  }

  .focus-item.done {
    opacity: 0.5;
    text-decoration: line-through;
  }

  .focus-item input[type="checkbox"] {
    flex-shrink: 0;
  }

  .focus-item span {
    flex: 1;
  }

  .focus-item .focus-remove {
    cursor: pointer;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    border: none;
    background: none;
    padding: 0 4px;
  }

  .focus-pull-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 14px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.1s;
  }

  .focus-pull-item:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
  }

  .focus-pull-item.already-added {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
  }

  /* --- Focus mode --- */

  body.focus-mode .sidebar,
  body.focus-mode .top-bar {
    display: none !important;
  }

  body.focus-mode .main-area {
    margin-left: 0;
  }

  body.focus-mode .content {
    max-width: 640px;
    margin: 0 auto;
  }

  .focus-exit-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    background: var(--panel);
    color: var(--text-secondary);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    font-family: inherit;
    transition: background 0.1s, color 0.1s;
  }

  .focus-exit-btn:hover {
    background: var(--panel-2);
    color: var(--text);
  }

  /* --- Sparklines --- */

  .sparkline {
    flex-shrink: 0;
    vertical-align: middle;
  }

  /* --- Search --- */

  .search-bar input {
    width: 160px;
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 20px;
    transition: width 0.2s;
  }

  .search-bar input:focus {
    width: 240px;
  }

  .search-results {
    display: none;
    position: fixed;
    left: 260px;
    right: 16px;
    top: 56px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 950;
    padding: 12px;
  }

  @media (max-width: 900px) {
    .search-results {
      left: 16px;
    }
  }

  .search-results.open {
    display: block;
  }

  .search-result-item {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background 0.1s;
    border-radius: var(--radius-sm);
  }

  .search-result-item:last-child {
    border-bottom: none;
  }

  .search-result-item:hover {
    background: var(--panel-2);
  }

  .search-result-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }

  @media (max-width: 900px) {
    .search-bar input {
      width: 100px;
    }
    .search-bar input:focus {
      width: 160px;
    }
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  #commandBarWrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle), 0 0 20px var(--accent-glow);
  }

  /* === MOBILE PHONE OPTIMIZATIONS === */

  @media (max-width: 480px) {
    /* Safe area insets for notch/home indicator */
    .main-area {
      padding-top: env(safe-area-inset-top);
      padding-bottom: calc(env(safe-area-inset-bottom) + 60px); /* room for bottom nav */
    }

    .top-bar {
      padding: 8px 12px;
      padding-top: calc(8px + env(safe-area-inset-top));
    }

    .content {
      padding: 12px;
      gap: 10px;
      overflow-x: hidden;
    }

    /* Cards: tighter padding */
    .card {
      padding: 14px;
      border-radius: 10px;
    }

    /* Dashboard: force single column */
    .dashboard-grid {
      grid-template-columns: 1fr !important;
      gap: 10px;
    }

    .dashboard-col {
      gap: 8px;
    }

    /* Goal widgets: compact */
    .goal-widget {
      padding: 12px !important;
    }
    .goal-widget .widget-title {
      font-size: 13px !important;
    }
    .goal-widget .widget-value {
      font-size: 24px !important;
    }

    /* Goals layout: no sidebar filter on phone */
    .goals-layout {
      grid-template-columns: 1fr !important;
    }
    .goals-filter-panel {
      position: static !important;
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding: 10px;
      flex-wrap: nowrap;
    }
    .goals-filter-panel > div {
      display: flex;
      gap: 4px;
      flex-shrink: 0;
    }
    .goals-filter-panel > div > div:first-child {
      display: none; /* hide section labels */
    }
    .gf-item {
      white-space: nowrap;
      padding: 6px 10px;
      font-size: 14px;
    }

    /* Goal items: tighter */
    .goal-item {
      padding: 10px;
      gap: 8px;
    }
    .goal-item.sub-goal { padding-left: 28px; }
    .goal-item.sub-sub-goal { padding-left: 42px; }

    .goal-item-progress {
      width: 80px !important;
    }

    /* Typography: min readable sizes */
    h1 { font-size: 22px; }
    h2 { font-size: 20px; }
    h3 { font-size: 15px; }

    /* Buttons: larger touch targets */
    .btn {
      min-height: 36px;
      padding: 8px 14px;
      font-size: 15px;
    }

    /* Inputs: larger for touch */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    textarea,
    select {
      min-height: 40px;
      font-size: 16px !important;
      padding: 10px 12px;
    }

    /* Checkboxes: bigger */
    input[type="checkbox"] {
      width: 20px;
      height: 20px;
    }

    /* Metrics row */
    .metrics-row {
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }
    .metric-card .metric-big { font-size: 20px; }
    .metric-card .metric-desc { font-size: 12px; }

    /* Coach panel: full screen */
    .coach-panel {
      width: 100vw !important;
    }
    .coach-header {
      padding-top: calc(12px + env(safe-area-inset-top));
    }
    .coach-input-area {
      padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    /* Timeline: smaller nodes */
    .timeline-node {
      width: 10px !important;
      height: 10px !important;
    }

    /* Prevent any horizontal overflow */
    .view, .view > * {
      max-width: 100%;
      overflow-x: hidden;
    }
    .view .card {
      overflow-x: auto;
    }

    /* Execution grid on goal detail */
    .execution-grid {
      grid-template-columns: repeat(3, 1fr) !important;
      gap: 6px;
    }

    /* Hide sidebar completely on phone (use bottom nav) */
    .sidebar {
      display: none !important;
    }
    .main-area {
      margin-left: 0 !important;
    }

    /* Bottom tab bar */
    .bottom-nav {
      display: flex !important;
    }
  }

  /* Bottom navigation bar (hidden by default, shown on mobile) */
  .bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
    justify-content: space-around;
    align-items: center;
  }

  .bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    flex: 1;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-tab svg {
    width: 22px;
    height: 22px;
  }

  .bottom-tab.active {
    color: var(--accent);
    font-weight: 600;
  }

  .bottom-tab:active {
    transform: scale(0.95);
  }

  .more-menu {
    display: none;
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom));
    right: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 201;
    padding: 6px;
    min-width: 160px;
  }
  .more-menu.open { display: block; }

  .more-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
  }
  .more-menu-item:active {
    background: var(--panel-2);
  }

  /* === Dashboard D: Cockpit + Hero === */
  .d-hero {
    background: linear-gradient(135deg, var(--panel) 0%, var(--accent-subtle) 100%);
    border: 1px solid var(--accent-border);
    border-radius: 16px;
    padding: 22px 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
  }
  .d-hero-left { flex: 1; min-width: 240px; }
  .d-hero-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
  .d-hero-title { font-family: var(--app-font); font-size: 22px; font-weight: 400; margin: 0 0 8px; }
  .d-hero-sub { font-size: 13px; color: var(--text-secondary); display: flex; gap: 14px; flex-wrap: wrap; }
  .d-hero-right { display: flex; gap: 8px; }
  .d-hero-btn { padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; font-family: var(--ui-font); cursor: pointer; border: none; }
  .d-hero-btn.primary { background: var(--accent); color: #fff; }
  .d-hero-btn.secondary { background: var(--panel); border: 1px solid var(--line); color: var(--text); }

  .d-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }
  .d-metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .d-metric-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
  }
  .d-metric-body { flex: 1; min-width: 0; }
  .d-metric-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
  .d-metric-val { font-size: 18px; font-weight: 700; font-family: var(--app-font); line-height: 1.1; }

  .d-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 14px;
  }
  .d-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
  }
  .d-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .d-card-title { font-size: 13px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-secondary); }
  .d-card-link { font-size: 11px; color: var(--accent); text-decoration: none; font-weight: 600; }

  .d-task { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
  .d-task:last-child { border: none; }
  .d-task-cb { width: 16px; height: 16px; border: 1.5px solid var(--line-hover); border-radius: 4px; flex-shrink: 0; }
  .d-task-time { font-size: 10px; color: var(--muted); margin-left: auto; }
  .d-task-pri { width: 3px; height: 16px; border-radius: 2px; flex-shrink: 0; }

  .d-habits {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .d-habit {
    aspect-ratio: 1;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    padding: 4px;
    transition: all 0.15s;
    overflow: hidden;
  }
  .d-habit:hover { border-color: var(--accent-border); }
  .d-habit.done {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    color: var(--accent);
  }
  .d-habit-icon { font-size: 22px; margin-bottom: 4px; line-height: 1; }
  .d-habit-label {
    font-size: 11px;
    line-height: 1.15;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    padding: 0 2px;
  }

  .e-capture-row { display: flex; gap: 6px; }
  .e-capture-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    font-size: 12px;
    font-family: var(--ui-font);
    color: var(--text);
    outline: none;
  }
  .e-capture-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  @media (max-width: 768px) {
    .d-metrics { grid-template-columns: repeat(2, 1fr); }
    .d-grid { grid-template-columns: 1fr; }
    .d-hero { flex-direction: column; align-items: stretch; }
    .d-hero-right { width: 100%; }
    .d-hero-btn { flex: 1; }
  }
