/* main.css — Core variables, reset, and layout */

:root {
    /* Color Palette — Premium dark, inspired by Linear/Plane */
    --bg-base: #09090b;
    --bg-surface: rgba(20, 20, 24, 0.75);
    --bg-surface-2: rgba(28, 28, 34, 0.85);
    --bg-surface-hover: rgba(38, 38, 46, 0.9);
    --bg-panel: rgba(15, 15, 18, 0.6);
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-overlay: rgba(0, 0, 0, 0.7);

    --border-color: rgba(255, 255, 255, 0.07);
    --border-highlight: rgba(255, 255, 255, 0.14);
    --border-focus: rgba(94, 106, 210, 0.6);

    --text-primary: #efefef;
    --text-secondary: #94949e;
    --text-muted: #828291;
    /* Improved contrast from #5a5a68 */

    --accent-primary: #5e6ad2;
    --accent-primary-glow: rgba(94, 106, 210, 0.3);
    --accent-primary-hover: #4a54ab;
    --accent-success: #22c55e;
    --accent-success-bg: rgba(34, 197, 94, 0.18);
    --accent-warning: #f59e0b;
    --accent-warning-bg: rgba(245, 158, 11, 0.18);
    --accent-danger: #ef4444;
    --accent-danger-bg: rgba(239, 68, 68, 0.18);
    --accent-info: #38bdf8;
    --accent-info-bg: rgba(56, 189, 248, 0.18);
    --accent-purple: #a78bfa;
    --accent-purple-bg: rgba(167, 139, 250, 0.18);
    --accent-teal: #2dd4bf;
    --accent-teal-bg: rgba(45, 212, 191, 0.18);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Elevation */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 12px rgba(0, 0, 0, 0.38), 0 2px 4px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 14px 32px rgba(0, 0, 0, 0.45), 0 6px 12px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 28px 56px rgba(0, 0, 0, 0.55), 0 8px 16px rgba(0, 0, 0, 0.25);
    --shadow-premium: 0 3px 6px rgba(0, 0, 0, 0.12), 0 14px 28px rgba(0, 0, 0, 0.22), 0 28px 56px rgba(0, 0, 0, 0.28);
    --blur: blur(24px) saturate(180%);
    --blur-sm: blur(12px) saturate(140%);

    /* Layout */
    --sidebar-width: 256px;
    --topbar-height: 56px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 34px;

    /* M3.5 playful shapes */
    --shape-xs: 10px;
    --shape-sm: 14px;
    --shape-md: 20px;
    --shape-lg: 30px;
    --shape-xl: 40px;
    --state-hover: color-mix(in srgb, var(--accent-primary) 11%, transparent);
    --state-pressed: color-mix(in srgb, var(--accent-primary) 20%, transparent);
    --surface-tonal: color-mix(in srgb, var(--bg-surface-2) 82%, var(--accent-primary) 18%);
    --surface-tonal-soft: color-mix(in srgb, var(--bg-surface) 90%, var(--accent-primary) 10%);

    /* Transitions — Playful Bouncy */
    --ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 180ms;
    --dur-med: 280ms;
    --dur-slow: 420ms;
}

[data-theme="light"] {
    /* M3 Light — Blue-violet seed, WCAG AA compliant */
    --bg-base: #f2f2f7;
    --bg-surface: #ffffff;
    --bg-surface-2: #f7f7fc;
    --surface-tonal: #e8e7f5;
    --surface-tonal-soft: #f0eff9;
    --bg-surface-hover: #eeedf8;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --bg-input: #ffffff;
    --bg-overlay: rgba(20, 20, 40, 0.45);

    --border-color: #d9d8ef;
    --border-highlight: #b9b7df;
    --border-focus: #5e6ad2;

    /* WCAG AA: 7:1 contrast on white */
    --text-primary: #1a1a2e;
    --text-secondary: #3d3a5c;
    --text-muted: #6b6894;

    --accent-primary: #5e6ad2;
    --accent-primary-glow: rgba(94, 106, 210, 0.15);
    --accent-primary-hover: #4a54ab;
    --accent-teal: #0d9488;

    --shadow-sm: 0 1px 3px rgba(30, 27, 80, 0.08);
    --shadow-md: 0 4px 12px rgba(30, 27, 80, 0.1);
    --shadow-lg: 0 8px 24px rgba(30, 27, 80, 0.13);
}

[data-theme="rosel"] {
    /* Outrun/Synthwave — deep space, neon grid */
    --bg-base: #07050f;
    --bg-surface: #110d1e;
    --bg-surface-2: #18122b;
    --bg-surface-hover: #221a38;
    --bg-panel: #0b0915;
    --bg-input: rgba(255, 0, 255, 0.06);
    --bg-overlay: rgba(0, 0, 0, 0.9);

    --border-color: rgba(0, 229, 255, 0.2);
    --border-highlight: rgba(255, 0, 255, 0.4);
    --border-focus: #00e5ff;

    /* Readable neon: not pure #00FFFF, slightly softened for eye comfort */
    --text-primary: #e0f7ff;
    --text-secondary: #ff8fff;
    --text-muted: #9d7fbf;

    --accent-primary: #f000ff;
    --accent-primary-glow: rgba(240, 0, 255, 0.45);
    --accent-primary-hover: #cc00dd;
    --accent-teal: #00e5ff;

    --font-family: 'Orbitron', var(--font-mono);
    --shadow-md: 0 0 12px rgba(0, 229, 255, 0.25), 0 0 4px rgba(240, 0, 255, 0.2);
    --shadow-lg: 0 0 24px rgba(240, 0, 255, 0.3), 0 0 8px rgba(0, 229, 255, 0.2);
    --shadow-xl: 0 0 40px rgba(240, 0, 255, 0.35), 0 0 16px rgba(0, 229, 255, 0.25);
}

/* CRT Scanlines and Perspective Grid for Rosel */
[data-theme="rosel"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.6;
}

[data-theme="celada"] {
    /* Adventure Time "Nightosphere/Lumpy Space" — Dark, bouncy, vibrant */
    --bg-base: #160f1e;
    --bg-surface: #22182e;
    --bg-surface-2: #2d203d;
    --bg-surface-hover: #3a2a4d;
    --bg-panel: #1a1224;
    --bg-input: rgba(255, 255, 255, 0.08);
    --bg-overlay: rgba(12, 8, 16, 0.92);

    /* Bolder borders for that cartoon "Ink" feel */
    --border-color: rgba(180, 140, 255, 0.25);
    --border-highlight: rgba(180, 140, 255, 0.5);
    --border-focus: #bd93f9;

    /* High contrast Lumpy Space violet text */
    --text-primary: #f8f0ff;
    --text-secondary: #d8c0ff;
    --text-muted: #9b8bb8;

    /* Bouncy Accents: LSP Purple & Flame Princess Violet */
    --accent-primary: #bd93f9;
    --accent-primary-glow: rgba(189, 147, 249, 0.4);
    --accent-primary-hover: #caadff;
    --accent-teal: #50fa7b;

    --font-family: 'Nunito', 'Inter', sans-serif;

    /* Bouncy Cartoon Shapes (Slightly irregular but M3 large) */
    --radius-sm: 14px 10px 14px 10px / 10px 14px 10px 14px;
    --radius-md: 22px 18px 22px 18px / 18px 22px 18px 22px;
    --radius-lg: 32px 28px 32px 28px / 28px 32px 28px 32px;
    --radius-xl: 44px 38px 44px 38px / 38px 44px 38px 44px;
    
    --shape-sm: 14px;
    --shape-md: 22px;
    --shape-lg: 32px;

    --surface-tonal: color-mix(in srgb, var(--accent-primary) 15%, var(--bg-surface-2));
    --surface-tonal-soft: color-mix(in srgb, var(--accent-primary) 8%, var(--bg-surface));

    /* Bouncy, slightly offset "Cartoon" shadows but with M3 softness */
    --shadow-sm: 2px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 4px 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 6px 6px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 8px 8px 40px rgba(0, 0, 0, 0.6);
}

/* Organic magic background for Celada */
[data-theme="celada"] body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 40%, rgba(208, 132, 240, 0.1) 0%, transparent 45%),
        radial-gradient(circle at 80% 20%, rgba(167, 139, 250, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 85%, rgba(74, 222, 128, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="zen"] {
  /* M3 Light — Warm parchment, ink-red seed. Legible, calm, professional. */
  --bg-base: #f6f3ec;
  --bg-surface: #faf7f0;
  --bg-surface-2: #f0ede5;
  --surface-tonal: #e9e3d4;
  --surface-tonal-soft: #f3f0e8;
  --bg-surface-hover: #e4dfd0;
  --bg-panel: rgba(250, 247, 240, 0.9);
  --bg-input: #ffffff;
  --bg-overlay: rgba(26, 22, 16, 0.5);

  --border-color: #ddd7c8;
  --border-highlight: #c9c0ae;
  --border-focus: #9b3537;

  /* WCAG AA contrast on parchment bg */
  --text-primary: #18140e;
  --text-secondary: #3f3830;
  --text-muted: #6b6054;

  /* Ink-red (M3 primary on warm bg) */
  --accent-primary: #9b3537;
  --accent-primary-glow: rgba(155, 53, 55, 0.15);
  --accent-primary-hover: #7e2b2d;
  /* Slate-blue as complementary */
  --accent-teal: #2d5f8a;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 1px 4px rgba(30, 20, 10, 0.1);
  --shadow-md: 0 4px 12px rgba(30, 20, 10, 0.13);
  --shadow-lg: 0 10px 28px rgba(30, 20, 10, 0.15);
}

/* Sumi-e Background for Zen */
[data-theme="zen"] body::after {
    content: '';
    position: fixed;
    inset: 0;
    /* background-image: url('assets/zen-bg.png'); (Missing asset, removed to prevent 404) */
    background-size: cover;
    background-position: center bottom;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

[data-theme="zen"] h1,
[data-theme="zen"] h2,
[data-theme="zen"] .brand-text {
    font-family: 'Nunito', serif;
    font-weight: 800;
}

/* ── New Themes ──────────────────────────────────────────────────────────── */

[data-theme="analog-horror"] {
    /* Lo-fi horror — crushing blacks, blood-red signal, distorted grain */
    --bg-base: #080808;
    --bg-surface: #111111;
    --bg-surface-2: #1a1a1a;
    --bg-surface-hover: #242424;
    --bg-panel: #0a0a0a;
    --bg-input: rgba(180, 0, 0, 0.06);
    --bg-overlay: rgba(0, 0, 0, 0.97);

    --border-color: rgba(200, 20, 20, 0.22);
    --border-highlight: rgba(220, 30, 30, 0.45);
    --border-focus: #cc1111;

    /* Much more legible — moved from grey to near-white */
    --text-primary: #e8e8e8;
    --text-secondary: #aaaaaa;
    --text-muted: #666666;

    --accent-primary: #cc1111;
    --accent-primary-glow: rgba(204, 17, 17, 0.45);
    --accent-primary-hover: #aa0000;
    --accent-teal: #1aaa1a;

    --font-family: 'Courier New', Courier, monospace;
    --blur: blur(1.5px);

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.7);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.8), 0 0 6px rgba(204, 17, 17, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.85), 0 0 12px rgba(204, 17, 17, 0.15);
}

[data-theme="analog-horror"] body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
    background-size: 100% 3px, 3px 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.35;
    animation: analog-flicker 0.15s infinite;
}

@keyframes analog-flicker {
    0% { opacity: 0.32; }
    50% { opacity: 0.38; }
    100% { opacity: 0.32; }
}

[data-theme="moomins"] {
    /* Moomins — soft Finnish magic. Improved contrast on teal palette. */
    --bg-base: #eaf3ef;
    --bg-surface: #f4faf7;
    --bg-surface-2: #e0ece6;
    --bg-surface-hover: #d2e4dc;
    --bg-panel: rgba(244, 250, 247, 0.92);
    --bg-input: #ffffff;
    --bg-overlay: rgba(40, 70, 60, 0.4);

    --border-color: #c0d9cf;
    --border-highlight: #a4c5b9;
    --border-focus: #3d8a73;

    /* WCAG AA: increased from low-contrast #4a5c54 */
    --text-primary: #1f3a2e;
    --text-secondary: #2d5244;
    --text-muted: #5c7d72;

    --accent-primary: #3d8a73;
    --accent-primary-glow: rgba(61, 138, 115, 0.2);
    --accent-primary-hover: #2d6f5a;
    --accent-teal: #7ab5a5;

    --font-family: 'Quicksand', 'Nunito', sans-serif;
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;

    --shadow-sm: 0 1px 4px rgba(40, 70, 60, 0.1);
    --shadow-md: 0 4px 12px rgba(40, 70, 60, 0.12);
    --shadow-lg: 0 8px 24px rgba(40, 70, 60, 0.15);
}

[data-theme="pokemon"] {
    /* Game Boy — 4-color palette, pixel-perfect */
    --bg-base: #8bac0f;
    --bg-surface: #9bbc0f;
    --bg-surface-2: #8bac0f;
    --bg-surface-hover: #a8c520;
    --bg-panel: #8bac0f;
    --bg-input: #c4d856;
    --bg-overlay: rgba(15, 56, 15, 0.6);

    --border-color: #306230;
    --border-highlight: #0f380f;
    --border-focus: #0f380f;

    /* Game Boy dark green — maximum contrast on the green bg */
    --text-primary: #0f380f;
    --text-secondary: #1e4a1e;
    --text-muted: #306230;

    --accent-primary: #0f380f;
    --accent-primary-glow: rgba(15, 56, 15, 0.3);
    --accent-primary-hover: #1e4a1e;
    --accent-teal: #306230;

    --font-family: 'Courier New', monospace;
    --radius-sm: 0px;
    --radius-md: 0px;
    --radius-lg: 0px;
    --radius-xl: 0px;
    --shadow-md: 3px 3px 0px #0f380f;
    --shadow-lg: 4px 4px 0px #0f380f;
}

[data-theme="zelda"] {
    /* Hyrule — dark forest, gold triforce, earthy parchment text */
    --bg-base: #0e1a0e;
    --bg-surface: #162616;
    --bg-surface-2: #1e3420;
    --bg-surface-hover: #274427;
    --bg-panel: rgba(12, 22, 12, 0.88);
    --bg-input: rgba(255, 210, 80, 0.05);
    --bg-overlay: rgba(0, 0, 0, 0.88);

    --border-color: rgba(201, 166, 107, 0.35);
    --border-highlight: rgba(229, 193, 133, 0.6);
    --border-focus: #ffd700;

    /* Warm parchment — excellent on dark forest bg */
    --text-primary: #f0e6c8;
    --text-secondary: #c8b48a;
    --text-muted: #8a7a60;

    /* Triforce gold */
    --accent-primary: #d4a843;
    --accent-primary-glow: rgba(212, 168, 67, 0.35);
    --accent-primary-hover: #e8c060;
    --accent-teal: #4a8a4a;

    --font-family: 'Spectral', 'Georgia', serif;

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5), 0 0 8px rgba(212, 168, 67, 0.1);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 16px rgba(212, 168, 67, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(212, 168, 67, 0.2);
}

[data-theme="ukiyo-e"] {
    /* Woodblock print — rice paper, indigo, vermilion */
    --bg-base: #f5ede0;
    --bg-surface: #fdf5e8;
    --bg-surface-2: #ece2d0;
    --bg-surface-hover: #e0d3be;
    --bg-panel: rgba(253, 245, 232, 0.92);
    --bg-input: #fdf5e8;
    --bg-overlay: rgba(30, 24, 18, 0.5);

    /* Ink-dark borders — architectural, crisp */
    --border-color: rgba(48, 40, 30, 0.25);
    --border-highlight: rgba(48, 40, 30, 0.5);
    --border-focus: #8c2020;

    /* Full ink-black for maximum legibility on rice paper */
    --text-primary: #1e1812;
    --text-secondary: #3a3028;
    --text-muted: #6a5e50;

    /* Torii vermilion */
    --accent-primary: #8c2020;
    --accent-primary-glow: rgba(140, 32, 32, 0.2);
    --accent-primary-hover: #a83030;
    /* Indigo-teal as secondary */
    --accent-teal: #2a4a5e;

    --font-family: 'Noto Serif JP', serif;

    --shadow-sm: 0 1px 4px rgba(30, 24, 18, 0.12);
    --shadow-md: 0 4px 12px rgba(30, 24, 18, 0.16);
    --shadow-lg: 0 8px 24px rgba(30, 24, 18, 0.2);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

ul,
ol {
    list-style: none;
}

button,
input,
textarea,
select {
    font: inherit;
    background: none;
    border: none;
    outline: none;
    color: inherit;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.55;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle animated background gradient */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(94, 106, 210, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 85% 90%, rgba(45, 212, 191, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

@keyframes viewIn {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.view-inner {
    animation: viewIn var(--dur-med) var(--ease);
}

.playful-pop:active, .pop-active {
    transform: scale(0.95) !important;
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr 0px;
    grid-template-rows: 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    z-index: 1;
    transition: grid-template-columns var(--dur-med) var(--ease);
}

.app-container.show-details {
    grid-template-columns: var(--sidebar-width) 1fr 400px;
}


.app-container.collapsed-sidebar {
    --sidebar-width: 68px;
}

/* Glassmorphism Refined 2.0 */
.glass-panel {
    background: var(--surface-tonal-soft);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid color-mix(in srgb, var(--border-highlight) 85%, var(--accent-primary) 15%);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: all var(--dur-med) var(--ease);
}

/* ── Universal Card Playful ────────────────────────────────────────────── */
.card, .project-card, .cycle-card, .decision-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all var(--dur-med) var(--ease);
    position: relative;
    overflow: hidden;
}

.card:hover, .project-card:hover, .cycle-card:hover, .decision-card:hover {
    transform: translateY(-5px) scale(1.015);
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.25),
        0 0 15px color-mix(in srgb, var(--accent-primary) 20%, transparent);
    border-color: color-mix(in srgb, var(--border-highlight) 60%, var(--accent-primary) 40%);
    background: var(--bg-surface-hover);
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    border-right: 1px solid color-mix(in srgb, var(--border-color) 76%, var(--accent-primary) 24%);
    z-index: 20;
    transition: transform var(--dur-med) var(--ease);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 10px;
    /* Reduced by 10px each side to account for toggle margin */
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 76%, var(--accent-primary) 24%);
    gap: 8px;
    justify-content: space-between;
}

.btn-sidebar-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--text-muted);
    transition: all var(--dur-fast);
    cursor: pointer;
    margin: 10px;
    /* Expand touch area */
}

.btn-sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.collapsed-sidebar .brand-text {
    display: none;
}

.collapsed-sidebar .btn-sidebar-toggle i {
    transform: rotate(180deg);
}

.workspace-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    flex: 1;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    width: 28px;
    height: 28px;
    background: var(--accent-primary-glow);
    border-radius: var(--shape-sm);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-primary) 44%, transparent);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-highlight) transparent;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-label {
    padding: 0 10px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 100px; /* MD3 fully rounded pills */
    color: var(--text-secondary);
    font-size: 0.86rem; /* Slightly larger text for MD3 */
    font-weight: 500;
    transition: all var(--dur-fast) var(--ease-out);
    cursor: pointer;
    border: 1px solid transparent;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collapsed-sidebar .nav-item span,
.collapsed-sidebar .nav-label {
    display: none;
}

.collapsed-sidebar .nav-item {
    justify-content: center;
    padding: 10px 0; /* Keep uniform for circular shape */
    border-radius: 50%;
    margin: 0 4px; /* Maintain horizontal breathing room */
}

.nav-item:hover {
    background: var(--state-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
    font-weight: 600;
}

.nav-item.active::after {
    content: "";
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--accent-primary) 18%, var(--bg-surface)); /* Stronger tint for MD3 active state */
    border-radius: 100px;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 20%, transparent); /* Subtle outline instead of strong border */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    z-index: -1;
}

.collapsed-sidebar .nav-item.active::after {
    border-radius: 50%;
}

.nav-item i {
    width: 20px; /* Increased from 15px to 20px for MD3 proportions */
    height: 20px;
    flex-shrink: 0;
}

.nav-item .nav-count {
    margin-left: auto;
    font-size: 0.7rem;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border-radius: 10px;
    padding: 1px 6px;
    font-weight: 600;
}

.project-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid color-mix(in srgb, var(--border-color) 76%, var(--accent-primary) 24%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* ──────────────────────────────────────────────────────────────────────────
   Document Editor (Notion-style)
   ────────────────────────────────────────────────────────────────────────── */
.doc-editor {
    max-width: 800px;
    margin: 0 auto;
    min-height: 400px;
    padding-bottom: 100px;
}

.doc-block {
    position: relative;
    margin-bottom: 4px;
}

.doc-block:hover .block-actions {
    opacity: 1;
}

.block-actions {
    position: absolute;
    left: -40px;
    top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-block-heading {
    font-size: 1.8rem;
    font-weight: 700;
    border: none;
    background: none;
    width: 100%;
    color: var(--text-primary);
    resize: none;
    overflow: hidden;
}

.doc-block-heading2 {
    font-size: 1.4rem;
    font-weight: 600;
    border: none;
    background: none;
    width: 100%;
    color: var(--text-primary);
    resize: none;
    overflow: hidden;
    margin-top: 1.2rem;
}

.doc-block-paragraph {
    font-size: 1rem;
    line-height: 1.6;
    border: none;
    background: none;
    width: 100%;
    color: var(--text-secondary);
    resize: none;
    overflow: hidden;
}

.doc-block-callout {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-surface-2);
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
    margin: 12px 0;
}

.doc-block-code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: #1a1a1a;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    width: 100%;
    border: none;
    resize: none;
    margin: 8px 0;
}

.slash-menu {
    position: fixed;
    z-index: 2000;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    width: 220px;
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}

.slash-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.slash-item:hover,
.slash-item.selected {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.slash-item i {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-surface);
}

.sync-state-label {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    line-height: 1;
}

.sync-state-label.status-online {
    color: var(--accent-success);
    border-color: color-mix(in srgb, var(--accent-success) 40%, var(--border-color));
}

.sync-state-label.status-offline {
    color: var(--text-muted);
}

.sync-state-label.status-syncing {
    color: var(--accent-primary);
    border-color: color-mix(in srgb, var(--accent-primary) 40%, var(--border-color));
}

.sync-state-label.status-error {
    color: var(--accent-danger);
    border-color: color-mix(in srgb, var(--accent-danger) 40%, var(--border-color));
}

.status-online {
    background: var(--accent-success);
}

.status-offline {
    background: var(--text-muted);
}

.status-syncing {
    background: var(--accent-primary);
    animation: pulse-sync 1.5s infinite;
}

.status-error {
    background: var(--accent-danger);
}

@keyframes pulse-sync {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

.theme-switcher {
    display: flex;
    justify-content: center;
}

.btn-theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    transition: all var(--dur-fast);
    cursor: pointer;
}

.btn-theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

.collapsed-sidebar .user-info {
    display: none;
}

.collapsed-sidebar .sidebar-footer {
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--dur-fast);
}

.user-profile:hover {
    background: var(--bg-surface-hover);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    letter-spacing: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: env(safe-area-inset-top) 32px 0 32px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 10;
    gap: 20px;
    backdrop-filter: var(--blur-sm);
    -webkit-backdrop-filter: var(--blur-sm);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
}

.breadcrumbs i {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.breadcrumbs .current {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Content View ───────────────────────────────────────────────────────────── */
.content-view {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-highlight) transparent;
    display: flex;
    flex-direction: column;
}

#app-root {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.view-inner {
    padding: 56px 72px;
    max-width: 1400px;
    margin: 0 auto;
}

.view-header {
    margin-bottom: 36px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.view-header-text h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.view-header-text .view-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.view-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.c-blue {
    color: var(--accent-info);
}

.c-purple {
    color: var(--accent-purple);
}

.c-green {
    color: var(--accent-success);
}

.c-teal {
    color: var(--accent-teal);
}

.c-warn {
    color: var(--accent-warning);
}

.c-danger {
    color: var(--accent-danger);
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.font-mono {
    font-family: var(--font-mono);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scroll restore */
.content-view {
    scroll-behavior: smooth;
}

/* Divider - subtle space-based separation */
.divider {
    height: 1px;
    background: transparent;
    border-top: 1px solid var(--border-color);
    margin: 48px 0;
    opacity: 0.6;
}

/* Section label */
.section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 12px;
}

/* View fade-in animation */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-inner {
    animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Premium Cascade Entrance */
.animate-cascade>*:nth-child(1) {
    animation-delay: 0.05s;
}

.animate-cascade>*:nth-child(2) {
    animation-delay: 0.10s;
}

.animate-cascade>*:nth-child(3) {
    animation-delay: 0.15s;
}

.animate-cascade>*:nth-child(4) {
    animation-delay: 0.20s;
}

.animate-cascade>*:nth-child(5) {
    animation-delay: 0.25s;
}

.animate-cascade>*:nth-child(6) {
    animation-delay: 0.30s;
}

.animate-cascade>*:nth-child(7) {
    animation-delay: 0.35s;
}

.animate-cascade>*:nth-child(8) {
    animation-delay: 0.40s;
}

.animate-cascade>* {
    animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.d-mobile-only {
    display: none !important;
}

/* Mobile responsive layout */
@media (max-width: 850px) {
    .view-inner {
        padding: 20px 24px;
    }
}

@media (max-width: 768px) {
    .d-mobile-only {
        display: flex !important;
    }

    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 1000;
        background: var(--bg-base);
        /* solid bg on mobile to prevent overlap issues */
        border-right: 1px solid var(--border-highlight);
        box-shadow: var(--shadow-xl);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--bg-overlay);
        backdrop-filter: var(--blur-sm);
        -webkit-backdrop-filter: var(--blur-sm);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--dur-med) var(--ease);
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Prevent closed overlay from blocking clicks */
    .sidebar-overlay {
        pointer-events: none;
    }

    .view-inner {
        padding: 20px 16px;
    }

    .topbar {
        padding: env(safe-area-inset-top) 16px 0 16px;
    }

    .sync-state-label {
        display: none;
    }

    /* Compact footer action buttons so all fit in one row */
    .sidebar-footer .footer-actions {
        gap: 4px;
    }

    .sidebar-footer .btn-icon,
    .sidebar-footer .btn-theme-toggle {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .sidebar-footer .btn-icon [data-feather],
    .sidebar-footer .btn-theme-toggle [data-feather] {
        width: 16px;
        height: 16px;
    }

}

/* -- Mobile: Additional responsive breakpoints ----------------------- */
@media (max-width: 768px) {

    /* Backlog table: hide lower-priority columns */
    .list-table th:nth-child(5),
    .list-table th:nth-child(6),
    .list-table td:nth-child(5),
    .list-table td:nth-child(6) {
        display: none;
    }

    /* Cycles and projects grids: single column */
    .cycles-grid,
    .projects-grid {
        grid-template-columns: 1fr;
    }

    /* Toast container: full width */
    #toast-container {
        left: 16px;
        right: 16px;
        max-width: 100%;
    }

    /* Prevent hover lift on touch devices */
    .card:hover,
    .project-card:hover {
        transform: none;
    }

    /* Force visibility of quick actions on touch devices */
    .task-quick-delete {
        opacity: 1 !important;
        background: var(--bg-surface-hover);
        border: 1px solid var(--border-color);
        padding: 4px !important;
    }
}

/* -- Active nav-count + iOS safe area ------------------------------------------ */
.nav-item.active .nav-count {
    background: rgba(94, 106, 210, 0.2);
    color: var(--accent-primary);
}

.sidebar-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Main content safe area for notch/home bar */
.main-content {
    padding-bottom: env(safe-area-inset-bottom);
}

/* -- Scroll helper improvements ---------------------------------------------- */
.main-content {
    scroll-behavior: smooth;
}

/* -- User profile avatar glow ------------------------------------------------ */
.user-avatar {
    transition: box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}

.user-profile:hover .user-avatar {
    box-shadow: 0 0 0 2px var(--accent-primary), 0 0 12px var(--accent-primary-glow);
    transform: scale(1.05);
}

/* -- View header mobile fix ---------------------------------------------------- */
@media (max-width: 600px) {
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .view-header-text h1 {
        font-size: 1.3rem;
    }

    .view-inner {
        padding: 16px 12px;
    }

    .doc-block-heading {
        font-size: 1.4rem;
    }

    .doc-block-heading2 {
        font-size: 1.1rem;
    }

    .topbar {
        padding: env(safe-area-inset-top) 12px 0 12px;
    }

    .view-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .view-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Hide pagination/filter label text on mobile */
    .btn-sm span.label {
        display: none;
    }
}

/* -- Better focus visible ring (keyboard nav) --------------------------------- */
.btn:focus-visible,
.nav-item:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ── Auth Overlay ────────────────────────────────────────────────────────────── */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-base);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-med) var(--ease);
}

.auth-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.auth-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.25);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

/* ── Drag & Drop ────────────────────────────────────────────────────────────── */
.nav-item.drag-over {
    background: rgba(var(--accent-primary-rgb), 0.1) !important;
    border-top: 2px solid var(--accent-primary);
}

.sidebar-project-item {
    cursor: grab;
}

.sidebar-project-item:active {
    cursor: grabbing;
}

/* -- Details Panel (Right Sidebar) ----------------------------------------- */
.details-panel {
    grid-column: 3;
    height: 100%;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
    background: var(--surface-tonal-soft);
    backdrop-filter: var(--blur);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    transition: transform var(--dur-med) var(--ease);
}

.app-container.show-details .details-panel {
    transform: translateX(0);
}

/* Notion Property Grid */
.property-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.property-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.property-label i {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.property-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.property-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
    opacity: 0.5;
}

.details-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-body {
    padding: 24px;
    flex: 1;
}

.details-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.details-title-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding: 0;
    letter-spacing: -0.01em;
}

.details-title-input:focus {
    outline: none;
}

.details-field-group {
    margin-bottom: 20px;
}

.details-field-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 8px;
}

.details-field-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Fluidity fixes */
.main-content {
    transition: all var(--dur-med) var(--ease);
}

/* -- Fluid UI Polish ------------------------------------------------------- */
.board-card {
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.board-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

/* Kanban Card Modernization */
.kanban-card-project {
    font-size: 0.68rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.project-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kanban-card-tags {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kanban-card-meta .task-quick-delete {
    opacity: 0;
    transition: opacity 0.2s;
    padding: 2px;
    color: var(--text-muted);
}

.kanban-card:hover .task-quick-delete {
    opacity: 1;
}

.kanban-card-meta .member-avatar-xs {
    width: 20px;
    height: 20px;
    font-size: 0.6rem;
    background: var(--accent-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-table tbody tr {
    transition: background-color 0.15s var(--ease);
    cursor: pointer;
}

.list-table tbody tr:hover {
    background-color: var(--bg-surface-hover);
}

.details-panel > * {
    animation: fadeIn 0.3s var(--ease-out);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar refinement */
.details-panel::-webkit-scrollbar {
    width: 6px;
}

.details-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.details-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Workspace Mode Toggle ───────────────────────────────────────────────── */
.workspace-mode-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-panel) 80%, var(--accent-primary) 4%);
    flex-shrink: 0;
}

.mode-pill {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: var(--shape-sm);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--dur-fast) var(--ease);
    font-family: var(--font-family);
    white-space: nowrap;
}

.mode-pill i {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.mode-pill:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.mode-pill.active {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    border-color: color-mix(in srgb, var(--accent-primary) 35%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 18%, transparent) inset;
}

/* Collapsed sidebar: only show icons */
.collapsed-sidebar .mode-pill span {
    display: none;
}
.collapsed-sidebar .workspace-mode-bar {
    padding: 8px 4px;
    gap: 2px;
}
.collapsed-sidebar .mode-pill {
    padding: 6px 4px;
}

/* ── Nav visibility by mode ──────────────────────────────────────────────── */

/* Solo-only items are hidden in team mode */
body[data-workspace-mode="team"] .nav-item[data-scope="solo"] {
    display: none;
}

/* Team-only items are hidden in solo mode */
body[data-workspace-mode="solo"] .nav-item[data-scope="team"] {
    display: none;
}

/* Section label switching */
body[data-workspace-mode="solo"] .nav-label-default { display: none; }
body[data-workspace-mode="solo"] .nav-label-solo-only { display: block !important; }
body[data-workspace-mode="solo"] .nav-label-team-only { display: none !important; }

body[data-workspace-mode="team"] .nav-label-default { display: none; }
body[data-workspace-mode="team"] .nav-label-team-only { display: block !important; }
body[data-workspace-mode="team"] .nav-label-solo-only { display: none !important; }

/* Hide nav-sections that become entirely empty in team mode
   (those that only contain solo-scoped items, e.g. Escritura + Médico) */
body[data-workspace-mode="team"] .nav-section:not(:has(.nav-item:not([data-scope="solo"]))) {
    display: none;
}

/* ── Team mode: teal accent override ────────────────────────────────────── */
body[data-workspace-mode="team"] {
    --accent-primary: #2dd4bf;
    --accent-primary-glow: rgba(45, 212, 191, 0.22);
    --accent-primary-hover: #14b8a6;
    --border-focus: rgba(45, 212, 191, 0.55);
    --surface-tonal: color-mix(in srgb, var(--bg-surface-2) 82%, #2dd4bf 18%);
}

/* ── Mode badge in topbar breadcrumb area ───────────────────────────────── */
.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 40%, transparent);
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    margin-left: 8px;
    vertical-align: middle;
    transition: all var(--dur-med) var(--ease);
}

.mode-badge i {
    width: 10px;
    height: 10px;
}

/* ══════════════════════════════════════════════════════════════════════════
   MODERNIZATION PATCH — Hierarchy · Contrast · Sync · Quick-delete
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar hierarchy: vertical guide lines ─────────────────────────────── */
.nested-project-wrapper {
    position: relative;
}

/* Vertical guide line from parent to children */
.nested-project-wrapper > .project-children:not(:empty) {
    position: relative;
}

.nested-project-wrapper > .project-children:not(:empty)::before {
    content: '';
    position: absolute;
    left: 21px;
    top: 0;
    bottom: 8px;
    width: 1px;
    background: linear-gradient(to bottom, var(--border-highlight), transparent);
    pointer-events: none;
}

/* Horizontal connector tick for sub-items */
.project-children .sidebar-project-item::before {
    content: '';
    position: absolute;
    left: calc(var(--depth-offset, 16px) - 9px);
    top: 50%;
    width: 7px;
    height: 1px;
    background: var(--border-highlight);
    pointer-events: none;
}

.project-children .sidebar-project-item {
    position: relative;
}

/* Stronger dot for root projects */
.nested-project-wrapper:not(.project-children > .nested-project-wrapper) > .sidebar-project-item .project-dot {
    width: 9px;
    height: 9px;
    box-shadow: 0 0 6px currentColor;
}

/* Sub-project dot — smaller, inherits hierarchy color */
.project-children .sidebar-project-item .project-dot {
    width: 6px;
    height: 6px;
    opacity: 0.85;
}

/* Task count badge — make more visible */
.nav-item .nav-count {
    background: color-mix(in srgb, var(--accent-primary) 18%, var(--bg-surface-hover) 82%);
    color: var(--accent-primary);
    border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
    font-weight: 700;
}

/* ── Subtask visual indentation ──────────────────────────────────────────── */
.task-item.is-subtask {
    margin-left: 24px;
    border-left: 2px solid var(--border-highlight);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: rgba(255, 255, 255, 0.015);
}

.task-item.is-subtask:hover {
    border-left-color: var(--accent-primary);
}

/* Sub-task depth indicator badge */
.task-depth-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Sync status dot in topbar ───────────────────────────────────────────── */
.sync-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.sync-status-dot.synced {
    background: var(--accent-success);
    box-shadow: 0 0 6px var(--accent-success);
}

.sync-status-dot.pending {
    background: var(--accent-warning);
    box-shadow: 0 0 6px var(--accent-warning);
    animation: pulse-dot 1.2s ease-in-out infinite;
}

.sync-status-dot.offline {
    background: var(--text-muted);
    box-shadow: none;
}

.sync-status-dot.error {
    background: var(--accent-danger);
    box-shadow: 0 0 6px var(--accent-danger);
    animation: pulse-dot 0.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ── Quick-delete hover button (shared pattern) ──────────────────────────── */
.quick-delete-btn {
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
    padding: 4px 6px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-delete-btn svg {
    width: 13px;
    height: 13px;
    stroke-width: 2;
}

.quick-delete-btn:hover {
    background: var(--accent-danger-bg);
    color: var(--accent-danger);
}

/* Reveal on parent hover */
*:hover > .quick-delete-btn,
.task-item:hover .quick-delete-btn,
.list-item:hover .quick-delete-btn,
tr:hover .quick-delete-btn {
    opacity: 1;
}

/* ── Status badge — stronger contrast (text labels) ──────────────────────── */
.status-capturado    { background: rgba(148,148,158,0.15); color: #a1a1aa; border: 1px solid rgba(148,148,158,0.3); }
.status-definido     { background: rgba(56,189,248,0.13);  color: var(--accent-info);    border: 1px solid rgba(56,189,248,0.3); }
.status-preparacion  { background: rgba(245,158,11,0.13);  color: var(--accent-warning); border: 1px solid rgba(245,158,11,0.3); }
.status-elaboracion  { background: rgba(94,106,210,0.15);  color: var(--accent-primary); border: 1px solid rgba(94,106,210,0.3); }
.status-revision     { background: rgba(167,139,250,0.15); color: var(--accent-purple);  border: 1px solid rgba(167,139,250,0.3); }
.status-espera       { background: rgba(245,158,11,0.1);   color: #e8b44e;               border: 1px solid rgba(245,158,11,0.25); }
.status-terminado    { background: rgba(34,197,94,0.13);   color: var(--accent-success); border: 1px solid rgba(34,197,94,0.3); }
.status-archivado    { background: rgba(148,148,158,0.08); color: var(--text-muted);     border: 1px solid var(--border-color); }

/* Generic status-pill component */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Priority contrast pills ─────────────────────────────────────────────── */
.priority-urgent { --pip-color: var(--accent-danger);   }
.priority-high   { --pip-color: var(--accent-warning);  }
.priority-medium { --pip-color: var(--accent-primary);  }
.priority-low    { --pip-color: var(--accent-success);  }

.priority-pip {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pip-color, var(--text-muted));
    flex-shrink: 0;
}

/* ── Profile / account header in sidebar ─────────────────────────────────── */
.user-profile-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-tonal-soft);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    width: 100%;
    text-align: left;
}

.user-profile-chip:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
}

.user-profile-chip .avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
    flex-shrink: 0;
}

.user-profile-chip-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.user-profile-chip-role {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Hierarchy breadcrumb inside views ───────────────────────────────────── */
.hierarchy-crumb {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 0;
}

.hierarchy-crumb-sep {
    color: var(--border-highlight);
    font-size: 0.7rem;
}

.hierarchy-crumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--dur-fast);
}

.hierarchy-crumb a:hover {
    color: var(--accent-primary);
}

/* ── Card delete/action overlay (shows on hover) ─────────────────────────── */
.card-actions-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--dur-fast);
    z-index: 2;
}

.card:hover .card-actions-overlay,
.project-card:hover .card-actions-overlay {
    opacity: 1;
}

/* ── Sync status widget in topbar ────────────────────────────────────────── */
#sync-status-widget {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface-2);
    cursor: pointer;
    transition: all var(--dur-fast);
    white-space: nowrap;
}

#sync-status-widget:hover {
    border-color: var(--border-highlight);
    color: var(--text-secondary);
}

/* Light theme overrides for new styles */
[data-theme="light"] .task-item.is-subtask {
    background: rgba(0,0,0,0.018);
}

[data-theme="light"] .nested-project-wrapper > .project-children:not(:empty)::before {
    background: linear-gradient(to bottom, var(--border-highlight), transparent);
}

/* ── Mention chip in chat ────────────────────────────────────────────────── */
.mention-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
    color: var(--accent-primary);
    border-radius: 4px;
    padding: 0 5px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: default;
}

/* ── Command Palette (Obsidian/Notion Style) ───────────────────────────── */
.command-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.command-palette {
    width: 100%;
    max-width: 600px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideDownFade 0.2s var(--ease-out);
}

@keyframes slideDownFade {
    from { opacity: 0; transform: translateY(-20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.palette-search-wrap {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.palette-search-wrap i {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.palette-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.palette-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.1s;
}

.palette-item:hover, .palette-item.selected {
    background: var(--bg-surface-hover);
}

.palette-item i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.palette-item-text {
    flex: 1;
    overflow: hidden;
}

.palette-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.palette-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.palette-footer {
    padding: 10px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.palette-footer kbd {
    background: var(--bg-input);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

/* ── Notion-Style Database Table (Backlog) ─────────────────────────────── */
.notion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
}

.notion-table th {
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.notion-table th .prop-icon {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 6px;
    opacity: 0.7;
}

.notion-table th i {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: text-bottom;
    opacity: 0.7;
}

.notion-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.notion-table tr {
    transition: background 0.1s;
}

.notion-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.notion-pill-select {
    appearance: none;
    background: var(--bg-surface-2);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 18px 2px 8px;
    font-size: 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='gray' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 10px;
    transition: all 0.15s;
}

.notion-pill-select:hover {
    background-color: var(--border-color);
}

.notion-pill-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

.hover-open-btn {
    opacity: 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: color-mix(in srgb, var(--accent-primary) 10%, transparent);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.notion-table tbody tr:hover .hover-open-btn {
    opacity: 1;
}

.hover-open-btn:hover {
    background: color-mix(in srgb, var(--accent-primary) 20%, transparent);
}

/* ── Enhanced Mobile Compatibility ──────────────────────────────────────────── */

/* Extra small devices (320px - 375px) */
@media (max-width: 375px) {
    .auth-box {
        padding: 24px 16px;
        max-width: 100%;
    }

    .sidebar {
        width: 260px !important;
    }

    .view-inner {
        padding: 12px 8px !important;
    }

    .topbar {
        padding: env(safe-area-inset-top) 8px 0 8px !important;
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    /* Better spacing for extra small screens */
    .nav-section {
        gap: 2px;
    }

    .nav-item span {
        font-size: 0.85rem;
    }
}

/* Small devices (376px - 480px) */
@media (min-width: 376px) and (max-width: 480px) {
    .auth-box {
        padding: 28px 20px;
        max-width: 100%;
        margin: 16px;
    }

    .sidebar {
        width: 270px;
    }

    .view-inner {
        padding: 14px 12px !important;
    }

    .topbar {
        padding: env(safe-area-inset-top) 12px 0 12px !important;
    }

    /* Stack buttons on mobile */
    .form-group {
        width: 100%;
    }
}

/* Medium mobile (481px - 600px) */
@media (min-width: 481px) and (max-width: 600px) {
    .view-inner {
        padding: 16px 14px !important;
    }

    /* Better grid for small cards */
    .task-grid,
    .card-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Improved touch targets across all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch target sizes */
    .btn,
    .nav-item,
    .task-item,
    .form-input,
    .form-select {
        min-height: 48px;
    }

    /* Better spacing for touch */
    .btn {
        padding: 12px 18px;
    }

    .nav-item {
        padding: 12px 16px;
        gap: 14px;
    }

    .task-item {
        padding: 12px 16px;
    }

    /* Hide hover effects on touch */
    .card:hover {
        transform: none !important;
    }

    .btn:hover {
        background-color: var(--bg-surface-hover);
    }

    /* Improve form input usability */
    .form-input,
    .form-select {
        font-size: 16px;
        padding: 12px 14px;
    }

    /* Prevent zoom on input focus (iOS) */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
    }

    /* Better select dropdown on mobile */
    select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 20px;
        padding-right: 36px;
    }
}

/* Landscape orientation optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .topbar {
        padding: env(safe-area-inset-top) 12px 0 8px !important;
        min-height: 48px;
    }

    .auth-box {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .sidebar {
        width: 240px;
    }

    h1 {
        font-size: 1.2rem;
    }

    /* Reduce padding in landscape */
    .view-inner {
        padding: 12px !important;
    }
}

/* Optimizations for devices with notch/safe area */
@media (screen-spanning: single-fold-vertical) {
    .app-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .sidebar {
        width: 100%;
        position: static;
    }

    .main-content {
        width: 100%;
    }
}

/* Better modal handling on small screens */
@media (max-height: 500px) {
    .auth-box,
    .modal-content,
    [role="dialog"] {
        max-height: 95vh;
        overflow-y: auto;
    }
}

/* Optimize scrolling performance */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    html {
        scroll-behavior: auto;
    }

    /* Enable hardware acceleration for better performance */
    .sidebar,
    .details-panel,
    .modal-content {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* Improve icon visibility on mobile */
@media (max-width: 600px) {
    [data-feather] {
        min-width: 20px;
        min-height: 20px;
    }

    .btn-icon [data-feather] {
        width: 20px;
        height: 20px;
    }
}

/* Safe area adjustments for all mobile devices */
.topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

.sidebar {
    padding-left: max(0, env(safe-area-inset-left));
    padding-right: max(0, env(safe-area-inset-right));
}

.main-content {
    padding-left: max(0, env(safe-area-inset-left));
    padding-right: max(0, env(safe-area-inset-right));
}
