/* ─── FloBox app styles — tokens from floforgelabs.com/ds/css/ffl.css ── */

/* ─── Map legacy tokens to ffl tokens ───────────────────────── */
:root,
[data-theme="dark"],
[data-theme="light"] {
    --bg: var(--ffl-bg);
    --panel: var(--ffl-panel);
    --ink: var(--ffl-ink);
    --muted: var(--ffl-muted);
    --line: var(--ffl-line);
    --accent: var(--ffl-accent);
    --accent-soft: var(--ffl-accent-soft);
    --baby-blue: var(--ffl-blue);
    --done: var(--ffl-done);
    --sb-bg: var(--ffl-sb-bg);
    --sb-text: var(--ffl-sb-text);
    --sb-text-muted: var(--ffl-sb-muted);
    --sb-hover: var(--ffl-sb-hover);
    --sb-active-bg: var(--ffl-sb-active);
    --sb-border: var(--ffl-sb-border);
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background: var(--ffl-line-strong);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ffl-muted);
}

/* ─── Base ───────────────────────────────────────────────────── */
body {
    font-family: "Inter", sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
    transition:
        background 0.2s,
        color 0.2s;
}
button {
    font-family: inherit;
    cursor: pointer;
}
.logo-font {
    font-family: "Barlow Condensed", sans-serif;
    letter-spacing: 0.01em;
}

/* ─── Auth screen ────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sb-bg);
    padding: 1rem;
}
.auth-card {
    background: var(--panel);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--ffl-shadow-lg);
}
.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.auth-logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 0.625rem;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.auth-logo-name {
    font-family: "Barlow Condensed", sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.01em;
    line-height: 1;
}
.auth-logo-sub {
    font-size: 0.75rem;
    color: var(--muted);
}
.auth-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--ink);
}
.auth-field {
    margin-bottom: 1rem;
}
.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.375rem;
}
.auth-field input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg);
    transition: border-color 0.15s;
}
.auth-field input:focus {
    outline: none;
    border-color: var(--ffl-focus);
}
.auth-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-top: 0.5rem;
    transition: opacity 0.15s;
}
.auth-btn:hover {
    opacity: 0.88;
}
.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--muted);
}
.auth-switch a {
    color: var(--ffl-link);
    text-decoration: none;
    font-weight: 500;
}
.auth-switch a:hover {
    text-decoration: underline;
}
.auth-error {
    background: var(--accent-soft);
    border: 1px solid #fca5a5;
    color: var(--accent-ink);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}
.auth-error.visible {
    display: block;
}
.auth-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}
.auth-error.visible {
    display: block;
}
.auth-trial-note {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 1rem;
}

/* ─── App shell ──────────────────────────────────────────────── */
.app-wrap {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: 256px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
}
@media (min-width: 768px) {
    .sidebar {
        position: static;
        transform: none;
    }
}
.sidebar.open {
    transform: translateX(0);
}
.sb-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--sb-border);
}
.sb-logo-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sb-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sb-logo-name {
    font-family: "Barlow Condensed", sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--sb-text);
    letter-spacing: 0.01em;
    line-height: 1;
}
.sb-logo-sub {
    font-size: 0.7rem;
    color: var(--sb-text-muted);
    margin-top: 0.15rem;
}
.sb-ws {
    padding: 0.75rem;
    position: relative;
}
.sb-ws-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--sb-hover);
    border: none;
    color: var(--sb-text);
    font-size: 0.875rem;
    font-weight: 500;
}
.sb-ws-btn:hover {
    background: var(--ffl-sb-hover);
    filter: brightness(1.1);
}
.sb-ws-menu {
    display: none;
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: 100%;
    background: var(--sb-bg);
    border: 1px solid var(--sb-border);
    border-radius: 0.5rem;
    box-shadow: var(--ffl-shadow-md);
    padding: 0.25rem;
    z-index: 50;
}
.sb-ws-menu.open {
    display: block;
}
.sb-ws-menu button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: none;
    background: none;
    color: var(--sb-text);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sb-ws-menu button:hover {
    background: var(--sb-hover);
}
.sb-ws-menu .ws-add {
    color: var(--sb-text);
    border-top: 1px solid var(--sb-border);
    margin-top: 0.25rem;
    padding-top: 0.5rem;
}
.sb-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}
.sb-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ffl-sb-muted);
    padding: 0 0.5rem;
    margin-bottom: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sb-section-label button {
    border: none;
    background: none;
    color: var(--sb-text-muted);
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
}
.sb-section-label button:hover {
    color: var(--sb-text);
    background: var(--sb-hover);
}
.sb-divider {
    margin: 0.75rem 0;
    border: none;
    border-top: 1px solid var(--sb-border);
}
.sb-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: none;
    background: none;
    color: var(--sb-text);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-item:hover {
    background: var(--sb-hover);
}
.sb-item.active {
    background: var(--sb-active-bg);
    color: #fff;
}
.sb-item.sys.active {
    background: transparent;
    color: var(--accent-ink);
    border-left: 3px solid var(--accent);
    border-radius: 0 0.5rem 0.5rem 0;
    padding-left: calc(0.75rem - 3px);
}
.sb-item.active svg {
    opacity: 1;
}
.sb-item.sys.active svg {
    opacity: 1;
    color: var(--accent-ink);
}
.sb-item svg {
    opacity: 0.6;
    flex-shrink: 0;
}
.sb-item.active.recur {
    background: var(--sb-hover);
    border-left: 3px solid var(--accent);
    color: var(--sb-text);
}
.sb-item.active.recur svg {
    color: var(--accent-ink);
    opacity: 1;
}
.sb-item.sys:not(.active) {
    color: var(--sb-text);
}
[data-theme="dark"] .sb-item.sys.active {
    color: var(--ffl-blue);
    border-left-color: var(--ffl-blue);
}
[data-theme="dark"] .sb-item.sys.active svg {
    color: var(--ffl-blue);
}
[data-theme="dark"] .sb-item.active.recur {
    border-left-color: var(--ffl-blue);
}

/* ─── Backdrop ───────────────────────────────────────────────── */
.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 30;
}
.backdrop.open {
    display: block;
}

/* ─── Main ───────────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--sb-border);
    background: var(--sb-bg);
}
@media (min-width: 768px) {
    .mobile-bar {
        display: none;
    }
}
.mobile-bar button {
    border: none;
    background: none;
    color: #cbd5e1;
    padding: 0.25rem;
    border-radius: 0.25rem;
}
.mobile-bar .mb-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mobile-bar .mb-logo-mark {
    width: 24px;
    height: 24px;
    border-radius: 0.3rem;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-bar .mb-logo-name {
    font-family: "Barlow Condensed", sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--sb-text);
}

/* ─── Trial banner ───────────────────────────────────────────── */
.trial-banner {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding: 0.5rem 1.5rem;
    font-size: 0.8125rem;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
[data-theme="dark"] .trial-banner {
    background: #1c1000;
    border-bottom-color: #92400e;
    color: #fbbf24;
}

/* ─── Quick-add / search bar ─────────────────────────────────── */
.quick-bar {
    border-bottom: 1px solid var(--line);
    padding: 0.875rem 1.5rem;
    background: var(--panel);
    position: relative;
}
.quick-bar textarea {
    width: 100%;
    resize: none;
    background: transparent;
    border: none;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--ink);
    outline: none;
}
.quick-bar textarea::placeholder {
    color: var(--muted);
}
.quick-menu {
    display: none;
    position: absolute;
    left: 1.5rem;
    right: 1.5rem;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.625rem;
    box-shadow: var(--ffl-shadow-md);
    padding: 0.25rem;
    z-index: 30;
    max-width: 400px;
}
.quick-menu.open {
    display: block;
}
.quick-menu button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: none;
    background: none;
    font-size: 0.875rem;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.quick-menu button:hover {
    background: var(--bg);
}

/* ─── View ───────────────────────────────────────────────────── */
.view {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}
@media (max-width: 767px) {
    .view {
        padding: 1rem;
    }
}
.view-header {
    margin-bottom: 1.5rem;
}
.view-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.view-header p {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ─── List cards ─────────────────────────────────────────────── */
.list-card {
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    transition:
        opacity 0.2s,
        border-color 0.2s;
}
.list-card:hover {
    border-color: var(--accent);
}
.list-card.reminder {
    background: var(--accent-soft);
    border-color: #fca5a5;
}
.list-card-body {
    flex: 1;
    min-width: 0;
}
.list-card-body .title {
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
}
.list-card .task-cb {
    margin-top: calc((1.40625rem - 1rem) / 2);
}
.list-card-body .sub {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.125rem;
}
.list-card-body .sub .open-link {
    color: var(--accent-ink);
}

/* ─── Section label ──────────────────────────────────────────── */
.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}
.section-label.accent {
    color: var(--accent-ink);
}

/* ─── Project view ───────────────────────────────────────────── */
.project-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    color: var(--muted);
}
.project-dates input[type="date"] {
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--ink);
    margin-left: 0.375rem;
}
.project-name {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.375rem;
    outline: none;
}
.project-name:focus {
    box-shadow: 0 1px 0 var(--accent);
}
.project-desc {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
    outline: none;
    max-width: 640px;
    line-height: 1.6;
}
.project-desc:focus {
    box-shadow: 0 1px 0 var(--accent);
}

/* ─── Task rows ──────────────────────────────────────────────── */
/* Action bar inside an open task */
.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px dashed var(--line);
    width: 100%;
}
.task-action-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    border: 1px solid var(--line);
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    transition:
        color 0.12s,
        border-color 0.12s,
        background 0.12s;
    white-space: nowrap;
}
.task-action-btn:hover {
    color: var(--ink);
    border-color: var(--line-strong);
    background: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .task-action-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}
.task-action-btn.danger {
    color: var(--accent-ink);
    border-color: var(--accent-soft);
}
.task-action-btn.danger:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.task-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.task-action-btn:disabled:hover {
    color: var(--muted);
    border-color: var(--line);
    background: none;
}
.task-box {
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    transition:
        opacity 0.2s,
        border-color 0.2s;
}
.task-box.has-desc {
    align-items: flex-start;
}

/* ─── Control alignment ──────────────────────────────────────────
   No description → box centers everything (clean single line).
   Has description → top-align, and nudge controls onto the first line. */
.task-box .task-cb {
    margin-top: calc((1.40625rem - 1rem) / 2);
} /* 16px checkbox */
.task-box.subtask .task-cb {
    margin-top: calc((1.3125rem - 1rem) / 2);
} /* .875rem titles */
.task-grip {
    display: flex;
    align-items: center;
    cursor: move;
}
.task-box .task-grip {
    height: 1.40625rem;
}
.task-grip:active {
    cursor: move;
}
.dragging,
.dragging * {
    cursor: move !important;
}
.task-box .task-icon-btn {
    margin-top: -0.0625rem;
} /* 23px buttons */
.task-box:not(.done):not(.subtask) {
    border-color: var(--line);
}
.task-box.subtask {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ffl-blue);
    padding: 0.5rem 0.75rem;
    margin-left: 0.75rem;
}
[data-theme="dark"] .task-box.subtask {
    background: var(--ffl-panel-raised);
    border-left-color: var(--ffl-blue);
}
.task-box.done {
    opacity: 0.5;
    border-color: var(--line);
}
/* Unified hover: every task surface borders brand red on hover. */
.task-box:not(.done):hover,
.recur-box:not(.done):hover {
    border-color: var(--accent);
}
/* …but keep the subtask's blue left marker on hover. */
.task-box.subtask:not(.done):hover {
    border-left-color: var(--ffl-blue);
}
.task-col {
    flex: 1;
    min-width: 0;
}
/* Task-tree indentation is CSS-driven (via the --depth var set in taskRow) so it can
   flex down on narrow screens instead of the old flat depth*40px inline margin. */
.task-node {
    margin-left: calc(var(--depth, 0) * 40px);
}
/* ─── Mobile task rows ───────────────────────────────────────────
   On phones the row was cramped: a flat 40px-per-level indent, desktop
   gaps/padding, and 5–6 controls left almost no room for the title. Halve
   the indent, tighten spacing, and give the content column priority. */
@media (max-width: 600px) {
    .task-node {
        margin-left: calc(var(--depth, 0) * 14px);
    }
    .task-box {
        gap: 0.375rem;
        padding: 0.625rem 0.5625rem;
    }
    .task-box.subtask {
        margin-left: 0.25rem;
        padding: 0.5rem 0.5625rem;
    }
    .task-actions {
        gap: 0.3125rem;
    }
    /* Drag-reorder is unreliable on touch; reclaim the grip's width for content. */
    .task-grip {
        display: none;
    }
    /* A subtask-less task's chevron is just a hidden placeholder for desktop alignment;
       collapse it on mobile so the title column matches the (good-looking) standalone rows. */
    .task-chev-empty {
        display: none;
    }
}
.task-title {
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
    color: var(--ink);
}
.task-title.subtask {
    font-size: 0.875rem;
}
.task-title.done {
    text-decoration: line-through;
    color: var(--done);
}
.task-desc {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.2rem;
    overflow-wrap: anywhere;
}
.task-edit-input {
    width: 100%;
    font-size: 0.9375rem;
    border: 1px solid var(--line);
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg);
}
.task-edit-input:focus {
    outline: none;
    border-color: var(--ffl-focus);
}
.task-edit-textarea {
    width: 100%;
    font-size: 0.8125rem;
    border: 1px solid var(--line);
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-family: inherit;
    color: var(--muted);
    resize: vertical;
    margin-top: 0.375rem;
    background: var(--bg);
}
.task-edit-textarea:focus {
    outline: none;
    border-color: var(--ffl-focus);
}
.task-edit-btns {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.375rem;
}
.task-edit-btns button {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    border: none;
}
.btn-save {
    background: var(--accent);
    color: #fff;
}
.btn-cancel {
    color: var(--muted);
    background: var(--bg);
}
.task-badges {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-top: 0.375rem;
}
.badge-muted {
    background: var(--line);
    color: var(--muted);
}
.badge {
    font-size: 0.6875rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
}
.badge-due {
    background: #eef2ff;
    color: #4338ca;
}
.badge-blocked {
    background: var(--accent-soft);
    color: var(--accent-ink);
    cursor: pointer;
}
.badge-tickler {
    background: #f0fdf4;
    color: #15803d;
}
.badge-baby-blue {
    background: var(--ffl-blue-soft);
    color: var(--ffl-blue-text);
}
[data-theme="dark"] .badge-due {
    background: #1e1b4b;
    color: #a5b4fc;
}
[data-theme="dark"] .badge-tickler {
    background: #052e16;
    color: #4ade80;
}

@keyframes notif-pulse {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(196, 30, 30, 0.4);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 0 4px rgba(196, 30, 30, 0);
    }
}
.task-icon-btn {
    border: none;
    background: none;
    padding: 0.25rem 0.375rem;
    border-radius: 0.375rem;
    color: var(--muted);
    flex-shrink: 0;
}
.task-icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--ink);
}
[data-theme="dark"] .task-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}
.add-task-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted);
    background: none;
    border: none;
    margin-top: 0.75rem;
    padding: 0.25rem 0;
}
.add-task-btn:hover {
    opacity: 0.7;
}

/* ─── Drag ───────────────────────────────────────────────────── */
.dragging {
    opacity: 0.35;
}
.drag-over-top {
    box-shadow: 0 -2px 0 var(--accent);
}
.drag-over-bottom {
    box-shadow: 0 2px 0 var(--accent);
}

/* ─── Recurring rows ─────────────────────────────────────────── */
.recur-box {
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    transition:
        opacity 0.2s,
        border-color 0.2s;
}
.recur-box.done {
    opacity: 0.5;
    border-color: var(--line);
}
.recur-box.highlight-pulse,
.task-box.highlight-pulse {
    opacity: 1 !important;
}
.recur-status {
    font-size: 0.6875rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
}
.recur-status.due {
    background: var(--accent-soft);
    color: var(--accent-ink);
}
.recur-status.done {
    background: #f0fdf4;
    color: #15803d;
}
[data-theme="dark"] .recur-status.done {
    background: #052e16;
    color: #4ade80;
}

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, 0.38);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}
.modal-overlay.open {
    display: flex;
}
.modal-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.875rem;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--ffl-shadow-lg);
    animation: modal-in 0.2s ease;
}
@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.modal-head h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}
.modal-head button {
    border: none;
    background: none;
    color: var(--muted);
    padding: 0.25rem;
    border-radius: 0.25rem;
}
.modal-head button:hover {
    background: var(--bg);
}
.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}
.modal-foot button {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    opacity: 0.88;
}
.btn-ghost {
    color: var(--muted);
    background: none;
}
.btn-ghost:hover {
    background: var(--bg);
}
.btn-danger {
    color: var(--accent-ink);
    background: none;
}
.btn-danger:hover {
    background: var(--accent-soft);
}
.modal-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.375rem;
}
.modal-field input,
.modal-field textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--bg);
    resize: none;
}
.modal-field input:focus,
.modal-field textarea:focus {
    outline: none;
    border-color: var(--ffl-focus);
}

/* ─── Float menu ─────────────────────────────────────────────── */
.float-menu {
    position: fixed;
    z-index: 40;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.625rem;
    box-shadow: var(--ffl-shadow-md);
    padding: 0.25rem;
    width: 192px;
}
.float-menu button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: none;
    background: none;
    font-size: 0.8125rem;
    color: var(--ink);
}
.float-menu button:hover {
    background: var(--bg);
}
.float-menu .fm-danger {
    color: var(--accent-ink);
    border-top: 1px solid var(--line);
    margin-top: 0.25rem;
    padding-top: 0.5rem;
}
.float-menu .fm-danger:hover {
    background: var(--accent-soft);
}

/* ─── Highlight / fade ───────────────────────────────────────── */
.highlight-pulse {
    animation: hlpulse 0.85s ease-in-out 3 !important;
}
@keyframes hlpulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 var(--accent);
    }
    50% {
        box-shadow: 0 0 0 4px var(--accent);
    }
}
.fade-in {
    animation: fi 0.2s ease both;
}
@keyframes fi {
    from {
        opacity: 0;
        transform: translateY(3px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ─── Settings ───────────────────────────────────────────────── */

.settings-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 1.5rem;
    max-width: 480px;
    margin-bottom: 1.5rem;
}
.settings-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.settings-field {
    margin-bottom: 0.875rem;
}
.settings-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.375rem;
}
.settings-field input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
}
.settings-field input:focus {
    outline: none;
    border-color: var(--ffl-focus);
}

/* ─── Help & About ───────────────────────────────────────────── */
.help-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 1.5rem;
    max-width: 680px;
    margin-bottom: 1.5rem;
}
.help-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--ink);
}
.help-section p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 0.75rem;
}
.help-section ol,
.help-section ul {
    padding-left: 1.25rem;
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.8;
}
.help-section .ffl-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--sb-bg);
    color: #fff;
    padding: 0.375rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* ─── Search results ─────────────────────────────────────────── */
#searchResults {
    background: var(--panel) !important;
    border-color: var(--line) !important;
}

/* ─── Home dashboard ─────────────────────────────────────────── */
.home-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 600px) {
    .home-stats {
        grid-template-columns: 1fr;
    }
}
.home-stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    text-align: center;
}
.home-stat-num {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}
.home-stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.375rem;
}
.home-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.home-card h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 0.25rem;
}
.home-empty {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.5rem 0;
}
.home-task {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    margin-top: 0.375rem;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}
.home-task:hover {
    background: var(--bg);
    border-color: var(--ffl-blue);
}
.home-proj {
    padding: 0.625rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}
.home-proj:hover {
    background: var(--bg);
    border-color: var(--ffl-blue);
}
.home-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 999px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.home-bar-fill {
    height: 100%;
    background: var(--ffl-blue);
    border-radius: 999px;
    transition: width 0.3s;
}

/* ─── AI assistant box ───────────────────────────────────────── */
.ai-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1rem 1.1rem 0.9rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.ai-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.75rem;
}
.ai-spark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--ffl-blue-soft);
    font-size: 0.9rem;
}
.ai-log {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    padding-right: 0.15rem;
}
.ai-hint {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    padding: 0.25rem 0;
}
/* Empty state */
.ai-empty {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.25rem 0 0.5rem;
}
.ai-empty-text {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.55;
}
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.ai-chip {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
    font-family: inherit;
    transition:
        border-color 0.12s,
        background 0.12s,
        color 0.12s;
}
.ai-chip:hover {
    border-color: var(--ffl-blue);
    background: var(--ffl-blue-soft);
    color: var(--ffl-blue-text);
}
/* Conversation rows */
.ai-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}
.ai-row-user {
    justify-content: flex-end;
}
.ai-row-asst {
    justify-content: flex-start;
}
.ai-avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--ffl-blue-soft);
    font-size: 0.78rem;
    margin-top: 0.1rem;
}
.ai-msg {
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 0.55rem 0.8rem;
    border-radius: 1rem;
    max-width: 85%;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    animation: aiFade 0.18s ease;
}
.ai-user {
    background: var(--ffl-blue);
    color: #fff;
    border-bottom-right-radius: 0.35rem;
}
.ai-asst {
    background: var(--bg);
    color: var(--ink);
    border: 1px solid var(--line);
    border-bottom-left-radius: 0.35rem;
}
@keyframes aiFade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.ai-thinking {
    opacity: 0.7;
    font-style: italic;
}
/* Composer — textarea + circular send button in one rounded pill */
.ai-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 0.4rem 0.4rem 0.4rem 0.85rem;
    transition:
        border-color 0.12s,
        box-shadow 0.12s;
}
.ai-composer:focus-within {
    border-color: var(--ffl-blue);
    box-shadow: 0 0 0 3px var(--ffl-blue-soft);
}
.ai-input {
    flex: 1;
    min-width: 0;
    resize: none;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink);
    outline: none;
    padding: 0.3rem 0;
    max-height: 160px;
    overflow-y: auto;
}
.ai-send-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: var(--ffl-red);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        filter 0.12s,
        transform 0.05s;
}
.ai-send-btn:hover {
    filter: brightness(1.08);
}
.ai-send-btn:active {
    transform: scale(0.94);
}
/* Text CTA button kept for the no-key "Add your API key" state */
.ai-send {
    align-self: flex-start;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--ffl-red);
    color: #fff;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.ai-send:hover {
    filter: brightness(1.05);
}
.ai-footer {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.6rem;
}
.ai-reset {
    font-size: 0.75rem;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.ai-reset:hover {
    color: var(--ink);
    text-decoration: underline;
}

/* ─── Header primary action button ───────────────────────────── */
.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--ffl-red);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: filter 0.12s;
}
.header-action-btn:hover {
    filter: brightness(1.05);
}
.header-action-btn svg {
    width: 16px;
    height: 16px;
}
/* Muted header action — sits next to the title (global FloForge page-header
   pattern). Subtle by default; brand-red only on hover. Replaces the loud
   .header-action-btn in viewHeader(). */
.header-add {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 0.5rem;
    padding: 0.3rem 0.7rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition:
        border-color 0.12s,
        color 0.12s;
}
.header-add:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
}
.header-add svg {
    width: 15px;
    height: 15px;
}
/* ─── Settings pages: JS masonry columns ─────────────────────── */
/* Hide the view until masonry has placed the cards, so the un-packed
   stack is never painted (kills the entry flash). offsetHeight still
   measures correctly under visibility:hidden. */
#view.masonry-pending {
    visibility: hidden;
}
.masonry-cols {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    margin-top: 0.25rem;
}
.masonry-cols > div {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.masonry-cols .settings-card {
    max-width: none;
    width: 100%;
    margin-bottom: 0;
}
/* Drag handle — keep the grab cursor visible over the icon */
.task-grip svg {
    pointer-events: none;
}
.task-grip {
    cursor: move;
}
.task-grip:active {
    cursor: move;
}
