/* ==========================================================================
   Life OS - Stylesheet
   Dark-first design with light theme support.
   Design tokens from architecture spec Section 9.2.
   ========================================================================== */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Theme Tokens ---- */
[data-theme="dark"] {
    --bg: #0D0E13;
    --surface: #14161F;
    --surface2: #1A1D28;
    --surface3: #222533;
    --border: #252836;
    --border-light: #2E3244;
    --text: #DDE1F5;
    --text-secondary: #9CA3C4;
    --muted: #5A6080;
    --accent: #4F6EF7;
    --accent-hover: #6380FF;
    --accent-soft: rgba(79,110,247,.12);
    --green: #22C98A;
    --green-soft: rgba(34,201,138,.12);
    --amber: #F5A623;
    --amber-soft: rgba(245,166,35,.12);
    --red: #F05252;
    --red-soft: rgba(240,82,82,.12);
    --purple: #9B7FF5;
    --purple-soft: rgba(155,127,245,.12);
    --shadow: 0 2px 8px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
}

[data-theme="light"] {
    --bg: #F0F2F8;
    --surface: #FFFFFF;
    --surface2: #F7F8FC;
    --surface3: #EEF0F6;
    --border: #E3E6F0;
    --border-light: #ECEEF5;
    --text: #171926;
    --text-secondary: #555B78;
    --muted: #8892B0;
    --accent: #4F6EF7;
    --accent-hover: #3A5BE0;
    --accent-soft: rgba(79,110,247,.10);
    --green: #10B981;
    --green-soft: rgba(16,185,129,.10);
    --amber: #F59E0B;
    --amber-soft: rgba(245,158,11,.10);
    --red: #DC2626;
    --red-soft: rgba(220,38,38,.10);
    --purple: #7C3AED;
    --purple-soft: rgba(124,58,237,.10);
    --shadow: 0 2px 8px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.1);
}

/* ---- Typography ---- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 52px;
    --transition: 150ms ease;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Layout Shell ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sidebar-logo span {
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0 8px;
    margin-bottom: 4px;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 12px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    font-size: 0.80rem;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

/* Domain tree */
.domain-group { margin-top: 4px; }

.domain-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 0.80rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.domain-header:hover { background: var(--surface2); }

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

.domain-children {
    padding-left: 12px;
}

.area-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 10px 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.project-link {
    display: block;
    padding: 4px 10px 4px 18px;
    font-size: 0.80rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-link:hover {
    background: var(--surface2);
    color: var(--text);
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-env {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--amber-soft);
    color: var(--amber);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.topbar-spacer { flex: 1; }

.page-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-count {
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 8px;
    font-weight: 400;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
    background: var(--surface2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); }

.btn-danger {
    background: var(--red-soft);
    color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }
.btn-capture { min-height: 44px; font-size: 0.95rem; padding: 10px 20px; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* ---- Tables / List Rows ---- */
.list-table {
    width: 100%;
    border-collapse: collapse;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.list-row:hover {
    background: var(--surface2);
}

.list-row.completed .row-title {
    text-decoration: line-through;
    color: var(--muted);
}

.row-check {
    flex-shrink: 0;
}

.row-check input[type="checkbox"] {
    display: none;
}

.row-check label {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.row-check label:hover {
    border-color: var(--accent);
}

.row-check input[type="checkbox"]:checked + label {
    background: var(--green);
    border-color: var(--green);
}

.row-check input[type="checkbox"]:checked + label::after {
    content: "\2713";
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

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

.priority-1 { background: var(--red); }
.priority-2 { background: var(--amber); }
.priority-3 { background: var(--accent); }
.priority-4 { background: var(--muted); }

.row-title {
    flex: 1;
    font-size: 0.80rem;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-title a { color: var(--text); }
.row-title a:hover { color: var(--accent); }

.row-meta {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.row-tag {
    font-size: 0.72rem;
    background: var(--surface2);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.row-domain-tag {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.row-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.list-row:hover .row-actions { opacity: 1; }

.overdue { color: var(--red) !important; font-weight: 600; }

/* ---- Filters Bar ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-select {
    font-family: var(--font-body);
    font-size: 0.82rem;
    padding: 6px 10px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---- Forms ---- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 9px 12px;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

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

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    grid-column: 1 / -1;
}

/* ---- Quick Add ---- */
.quick-add {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-add input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 0.92rem;
    padding: 9px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.quick-add input:focus {
    outline: none;
    border-color: var(--accent);
}

.quick-add input::placeholder { color: var(--muted); }

/* ---- Progress Bar ---- */
.progress-bar {
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 300ms ease;
}

.progress-text {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ---- Tabs ---- */
.tab-strip {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab-item {
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.tab-item:hover { color: var(--text); }

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---- Status Badges ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    text-transform: capitalize;
}

.status-open { background: var(--accent-soft); color: var(--accent); }
.status-active { background: var(--green-soft); color: var(--green); }
.status-in_progress { background: var(--amber-soft); color: var(--amber); }
.status-blocked { background: var(--red-soft); color: var(--red); }
.status-done { background: var(--green-soft); color: var(--green); }
.status-completed { background: var(--green-soft); color: var(--green); }
.status-cancelled { background: var(--surface2); color: var(--muted); }
.status-on_hold { background: var(--purple-soft); color: var(--purple); }
.status-archived { background: var(--surface2); color: var(--muted); }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* ---- Detail Header ---- */
.detail-header {
    margin-bottom: 24px;
}

.detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.detail-body {
    line-height: 1.75;
    color: var(--text);
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.detail-body p { margin-bottom: 1em; }
.detail-body h1, .detail-body h2, .detail-body h3 { margin: 1.2em 0 0.6em; font-weight: 600; }
.detail-body code { font-family: var(--font-mono); background: var(--surface2); padding: 1px 5px; border-radius: 3px; }
.detail-body pre { background: var(--surface2); padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 1em 0; }
.detail-body pre code { background: none; padding: 0; }

/* ---- Dashboard Widgets ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.stat-card-link .stat-card {
    transition: border-color 0.15s;
}

.stat-card-link:hover .stat-card {
    border-color: var(--accent);
    cursor: pointer;
}

.stat-card-link:hover {
    color: inherit;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ---- Capture Items ---- */
.capture-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.capture-text {
    flex: 1;
    font-size: 0.80rem;
}

.capture-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ---- Focus Items ---- */
.focus-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.focus-item:hover { background: var(--surface2); }
.focus-item.completed { opacity: 0.6; }
.focus-item.completed .focus-title { text-decoration: line-through; }

.focus-title { flex: 1; font-size: 0.80rem; font-weight: 500; }
.focus-meta { font-size: 0.78rem; color: var(--muted); }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
}
.alert-warning {
    background: var(--amber-soft);
    color: var(--amber);
    border: 1px solid var(--amber);
}

/* ---- Utility ---- */
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none; }

/* ---- Search Trigger (Topbar) ---- */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 200px;
}
.search-trigger:hover { border-color: var(--accent); color: var(--text-secondary); }
.search-trigger kbd {
    margin-left: auto;
    padding: 1px 6px;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--muted);
}

/* ---- Quick Capture (Topbar) ---- */
.quick-capture-form {
    display: flex;
    align-items: center;
    position: relative;
}

.quick-capture-icon {
    position: absolute;
    left: 10px;
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
}

.quick-capture-input {
    width: 250px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    padding: 6px 12px 6px 26px;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.quick-capture-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    border-left-color: var(--accent);
}

.quick-capture-input::placeholder {
    color: var(--muted);
}

.quick-capture-submit {
    display: none;
}

/* ---- Search Modal ---- */
.search-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    padding-top: 15vh;
}
.search-modal.hidden { display: none; }
.search-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.55);
}
.search-modal-content {
    position: relative;
    width: 560px;
    max-height: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.search-modal-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.search-modal-icon { color: var(--muted); flex-shrink: 0; }
.search-modal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
}
.search-modal-input::placeholder { color: var(--muted); }
.search-modal-esc {
    padding: 2px 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.72rem;
    color: var(--muted);
    cursor: pointer;
}
.search-results {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}
.search-group-label {
    padding: 8px 16px 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: background var(--transition);
}
.search-result-item:hover,
.search-result-item.active { background: var(--surface2); }
.search-result-name { font-weight: 500; flex: 1; }
.search-result-context { font-size: 0.78rem; color: var(--muted); }
.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---- Search Type Badges ---- */
.search-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}
.search-type-tasks { background: var(--accent-soft); color: var(--accent); }
.search-type-projects { background: var(--green-soft); color: var(--green); }
.search-type-notes { background: var(--purple-soft); color: var(--purple); }
.search-type-contacts { background: var(--amber-soft); color: var(--amber); }
.search-type-links { background: var(--surface2); color: var(--text-secondary); }
.search-type-lists { background: var(--accent-soft); color: var(--accent); }
.search-type-capture { background: var(--surface2); color: var(--muted); }
.search-type-domains { background: var(--green-soft); color: var(--green); }
.search-type-areas { background: var(--surface2); color: var(--text-secondary); }
.search-type-daily_focus { background: var(--amber-soft); color: var(--amber); }
.search-type-meetings { background: var(--purple-soft); color: var(--purple); }
.search-type-decisions { background: var(--green-soft); color: var(--green); }
.search-type-files { background: var(--surface2); color: var(--text-secondary); }

/* Impact badges */
.impact-high { background: var(--red-soft); color: var(--red); }
.impact-medium { background: var(--amber-soft); color: var(--amber); }
.impact-low { background: var(--surface2); color: var(--muted); }

/* ---- Search Page Form ---- */
.search-page-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

/* ---- Weblinks Layout ---- */
.weblinks-layout {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}
.weblinks-folders {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 0;
    align-self: flex-start;
}
.weblink-folder-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.weblink-folder-item:hover { background: var(--surface2); color: var(--text); }
.weblink-folder-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.weblinks-content { flex: 1; min-width: 0; }

/* ---- Project Progress Mini Bar (dashboard) ---- */
.project-progress-mini {
    width: 60px;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.project-progress-bar {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.3s;
}

/* ---- Focus Domain Toggle ---- */
.focus-domain-header:hover td { background: var(--surface3); }

/* ---- Focus Drag-and-Drop ---- */
.focus-drag-row { cursor: grab; }
.focus-drag-row.dragging { opacity: 0.4; background: var(--accent-soft); }
.focus-drag-row.drag-over { box-shadow: 0 -2px 0 0 var(--accent) inset; }

/* ---- Reorder Grip Handle ---- */
.reorder-grip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-right: 4px;
    opacity: 0.3;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.reorder-grip:hover { opacity: 0.9; }
.reorder-grip form { display: block; margin: 0; padding: 0; line-height: 0; }
.grip-btn {
    display: block;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 10px;
    width: 12px;
    height: 10px;
    padding: 0;
    line-height: 10px;
    transition: color 0.15s;
    text-align: center;
}
.grip-btn:hover { color: var(--accent); }

/* ---- Link Picker & Inline Edit ---- */
.link-picker {
    padding: 4px 8px;
    font-size: 0.8rem;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.link-picker:hover { border-color: var(--accent); color: var(--text); }

.inline-edit-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.inline-edit-form input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    font-size: 0.85rem;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.inline-edit-form input[type="text"]:focus {
    border-color: var(--accent);
    outline: none;
}

/* ---- Autolinked URLs in list items ---- */
.autolink {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--accent-soft);
    text-underline-offset: 2px;
    transition: text-decoration-color var(--transition);
}
.autolink:hover {
    text-decoration-color: var(--accent);
    color: var(--accent);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    body { padding-bottom: 60px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; padding-bottom: 72px; }
    /* Topbar: stack vertically on mobile */
    .topbar {
        height: auto;
        min-height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 12px;
        gap: 8px;
    }

    .topbar-env {
        align-self: flex-start;
    }

    .topbar-spacer {
        display: none;
    }

    .quick-capture-form {
        order: unset;
        width: 100%;
        flex: unset;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0;
    }

    .quick-capture-icon {
        display: none;
    }

    .quick-capture-input {
        flex: 1;
        width: auto;
        height: 36px;
        min-height: auto;
        background: var(--surface2);
        border: 1px solid var(--border);
        border-left: 1px solid var(--border);
        border-radius: 4px;
        padding: 0 10px;
        font-size: 16px;
    }

    .quick-capture-submit {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 4px;
        font-size: 1.2rem;
        font-weight: 700;
        cursor: pointer;
        flex-shrink: 0;
        margin-left: 0;
    }

    .quick-capture-submit:hover {
        background: var(--accent-hover);
    }

    .search-trigger {
        width: 100%;
        min-width: unset;
    }

    /* Capture form mobile */
    .capture-form-card { padding: 12px; }
    .capture-form-card .form-textarea {
        font-size: 16px; /* prevents iOS zoom */
        min-height: 80px;
    }
    .capture-form-card .btn-capture {
        width: 100%;
        min-height: 44px;
        font-size: 1rem;
    }

    /* Capture items stack on mobile */
    .capture-item {
        flex-direction: column;
        gap: 8px;
    }
    .capture-actions {
        flex-wrap: wrap;
    }
}
.search-type-appointments { background: var(--amber-soft); color: var(--amber); }

/* Timer buttons on task rows */
.row-timer {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.timer-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
}

.timer-btn:hover {
    transform: scale(1.15);
}

.timer-btn-play {
    background: var(--green, #22c55e)22;
    color: var(--green, #22c55e);
}

.timer-btn-play:hover {
    background: var(--green, #22c55e)44;
}

.timer-btn-stop {
    background: var(--red, #ef4444)22;
    color: var(--red, #ef4444);
}

.timer-btn-stop:hover {
    background: var(--red, #ef4444)44;
}

/* Highlight row with active timer */
.list-row.timer-active {
    border-left: 3px solid var(--green, #22c55e);
    background: var(--green, #22c55e)08;
}

/* Timer button on task detail page */
.timer-detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.timer-detail-play {
    background: var(--green, #22c55e)18;
    color: var(--green, #22c55e);
    border: 1px solid var(--green, #22c55e)44;
}

.timer-detail-play:hover {
    background: var(--green, #22c55e)33;
}

.timer-detail-stop {
    background: var(--red, #ef4444)18;
    color: var(--red, #ef4444);
    border: 1px solid var(--red, #ef4444)44;
}

.timer-detail-stop:hover {
    background: var(--red, #ef4444)33;
}

/* ---- Calendar View ---- */
.cal-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.cal-month-label {
    font-size: 1.15rem;
    font-weight: 700;
    min-width: 180px;
    text-align: center;
}

.cal-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.78rem;
    color: var(--muted);
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.cal-dot-appointment { background: var(--amber); }
.cal-dot-meeting { background: var(--purple); }
.cal-dot-task { background: var(--accent); }

.cal-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cal-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}

.cal-header-cell {
    padding: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-align: center;
}

.cal-week-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 100px;
}

.cal-week-row + .cal-week-row {
    border-top: 1px solid var(--border);
}

.cal-day-cell {
    padding: 4px;
    border-right: 1px solid var(--border);
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.cal-day-cell:last-child {
    border-right: none;
}

.cal-day-empty {
    background: var(--surface2);
    min-height: 100px;
}

.cal-day-today {
    background: var(--accent-soft);
}

.cal-day-num {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 2px 4px;
    text-align: right;
}

.cal-day-today .cal-day-num {
    color: var(--accent);
    font-weight: 700;
}

.cal-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.cal-event {
    display: block;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    line-height: 1.3;
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: opacity var(--transition);
}

.cal-event:hover {
    opacity: 0.8;
}

.cal-event-appointment {
    background: var(--amber-soft);
    color: var(--amber);
    border-left: 2px solid var(--amber);
}

.cal-event-meeting {
    background: var(--purple-soft);
    color: var(--purple);
    border-left: 2px solid var(--purple);
}

.cal-event-task {
    background: var(--accent-soft);
    color: var(--accent);
    border-left: 2px solid var(--accent);
}

.cal-event-time {
    font-weight: 600;
    margin-right: 2px;
}

.cal-event-title {
    font-weight: 500;
}

@media (max-width: 768px) {
    .cal-week-row { min-height: 60px; }
    .cal-day-cell { min-height: 60px; padding: 2px; }
    .cal-day-empty { min-height: 60px; }
    .cal-day-num { font-size: 0.72rem; }
    .cal-event { font-size: 0.65rem; padding: 1px 2px; }
    .cal-event-time { display: none; }
    .cal-month-label { font-size: 1rem; min-width: 140px; }
}

/* ---- Eisenhower Matrix ---- */
.eisenhower-grid {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
}

.eisenhower-y-label {
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.eisenhower-x-spacer {
    /* empty cell under the y-labels */
}

.eisenhower-x-label {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 4px 0;
}

.eisenhower-quadrant {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.eisenhower-q1 { border-top: 3px solid var(--red); }
.eisenhower-q2 { border-top: 3px solid var(--accent); }
.eisenhower-q3 { border-top: 3px solid var(--amber); }
.eisenhower-q4 { border-top: 3px solid var(--muted); }

.eisenhower-quadrant-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.eisenhower-quadrant-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.eisenhower-quadrant-subtitle {
    font-size: 0.72rem;
    color: var(--muted);
}

.eisenhower-task-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.eisenhower-task {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.82rem;
    transition: background var(--transition);
}

.eisenhower-task:hover {
    background: var(--surface2);
    color: var(--text);
}

.eisenhower-task-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.eisenhower-task-due {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

.eisenhower-task-due.overdue {
    color: var(--red);
    font-weight: 600;
}

.eisenhower-task-project {
    font-size: 0.68rem;
    color: var(--muted);
    background: var(--surface2);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.eisenhower-empty {
    color: var(--muted);
    font-size: 0.82rem;
    padding: 12px;
    text-align: center;
}

.badge-red { background: var(--red); color: #fff; }
.badge-amber { background: var(--amber); color: #fff; }
.badge-accent { background: var(--accent); color: #fff; }
.badge-muted { background: var(--muted); color: #fff; }

@media (max-width: 768px) {
    .eisenhower-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        min-height: auto;
    }
    .eisenhower-y-label,
    .eisenhower-x-label,
    .eisenhower-x-spacer { display: none; }
    .eisenhower-quadrant { min-height: 120px; }
}

/* === MOBILE NAV BAR === */
.mob-nav {
    display: none !important;
}

@media (max-width: 768px) {
    .mob-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 56px !important;
        background: var(--surface) !important;
        border-top: 1px solid var(--border) !important;
        z-index: 9999 !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-around !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .mob-nav__item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: 20% !important;
        height: 56px !important;
        padding: 6px 0 !important;
        margin: 0 !important;
        color: var(--muted) !important;
        text-decoration: none !important;
        background: none !important;
        border: none !important;
        font-family: inherit !important;
        font-size: 10px !important;
        font-weight: 500 !important;
        line-height: 1 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        gap: 2px !important;
    }

    .mob-nav__item svg {
        width: 22px !important;
        height: 22px !important;
        flex-shrink: 0 !important;
    }

    .mob-nav__item span {
        font-size: 10px !important;
        line-height: 1 !important;
    }

    .mob-nav__item--active {
        color: var(--accent) !important;
    }

    .mob-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0,0,0,0.5) !important;
        z-index: 10000 !important;
    }

    .mob-overlay.open {
        display: block !important;
    }

    .mob-more {
        display: none !important;
        position: fixed !important;
        bottom: 56px !important;
        left: 0 !important;
        right: 0 !important;
        background: var(--surface) !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 12px 12px 0 0 !important;
        z-index: 10001 !important;
        padding: 16px !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .mob-more.open {
        display: grid !important;
    }

    .mob-more__item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 12px 4px !important;
        color: var(--text) !important;
        text-decoration: none !important;
        font-size: 0.78rem !important;
        font-weight: 500 !important;
        border-radius: 8px !important;
    }

    .mob-more__item:hover {
        background: var(--surface2) !important;
    }

    .mob-more__item svg {
        width: 22px !important;
        height: 22px !important;
        color: var(--muted) !important;
    }
}
