/* Case Manager Dashboard */

/* -----------------------------------------------------------------------
   Design tokens
   ----------------------------------------------------------------------- */
:root {
    --bg: #f3f4f6;
    --surface: #fff;
    --border: #e0e0e0;
    --border-light: #ebebeb;
    --text: #1a1a1a;
    --text-muted: #666;
    --accent: #2563eb;
    --red: #dc2626;
    --orange: #ea580c;
    --green: #16a34a;
    --gray: #9ca3af;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --transition: 0.2s ease;
}

/* -----------------------------------------------------------------------
   Typography
   ----------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "mundial-narrow-variable", sans-serif;
    font-variation-settings: "wght" 400;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

h1, h2, h3,
.kanban-card-client,
.nav-brand {
    font-family: "proforma", serif;
    font-weight: 700;
}

/* -----------------------------------------------------------------------
   Navigation
   ----------------------------------------------------------------------- */
.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.nav-brand { font-size: 1.15rem; letter-spacing: -0.01em; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-variation-settings: "wght" 450;
    transition: color var(--transition), background var(--transition);
}
.nav-links a:hover {
    color: var(--text);
    background: var(--bg);
}
.nav-links a.active {
    color: var(--accent);
    background: #eff6ff;
    font-variation-settings: "wght" 550;
}

.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }

h1 { margin-bottom: 1.25rem; font-size: 1.5rem; letter-spacing: -0.02em; }

/* -----------------------------------------------------------------------
   Task sections (agenda) — cardless ledger layout
   ----------------------------------------------------------------------- */
.task-section { margin-bottom: 2rem; }
.section-title {
    font-size: 0.8rem;
    font-variation-settings: "wght" 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--border);
}
.section-title.overdue { color: var(--red); border-color: var(--red); }

/* Overdue section emphasis */
.overdue-section {
    background: #fef2f2;
    border-left: 4px solid var(--red);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
}
.overdue-section .section-title {
    border-bottom-color: rgba(220, 38, 38, 0.2);
}
.overdue-section .task-card {
    background: var(--surface);
}

/* Task rows — borderless with dividers */
.task-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    border-left: 4px solid hsl(var(--case-hue, 220), 50%, 65%);
    border-radius: 0;
    margin-bottom: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
}
.task-card:last-child { border-bottom: none; }
.task-card.completed { opacity: 0.45; }
.task-card.completed .task-name { text-decoration: line-through; }
.task-card.blocked { opacity: 0.55; background: #f9fafb; }
.task-card.overdue { border-left-color: var(--red); }

/* Completing animation */
@keyframes complete-flash {
    0% { background: transparent; }
    30% { background: #f0fdf4; }
    100% { background: transparent; }
}
.task-card.completing {
    animation: complete-flash 0.4s ease;
}

.task-info { flex: 1; min-width: 0; }
.task-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.task-link:hover .task-name { color: var(--accent); }
.task-link:hover .task-case { color: var(--accent); }
.task-name {
    display: block;
    font-size: 0.95rem;
    font-variation-settings: "wght" 500;
}
.task-case {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variation-settings: "wght" 400;
    margin-top: 0.1rem;
}

.task-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Complete button */
.complete-btn {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--border); background: none;
    cursor: pointer; font-size: 0.85rem; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.complete-btn:hover {
    border-color: var(--green);
    color: var(--green);
    background: #f0fdf4;
    transform: scale(1.1);
}
.complete-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.complete-indicator { width: 28px; text-align: center; color: var(--green); flex-shrink: 0; font-size: 1rem; }
.blocked-indicator { width: 28px; text-align: center; color: var(--orange); font-size: 0.6rem; flex-shrink: 0; }
.pending-indicator { width: 28px; text-align: center; color: var(--gray); flex-shrink: 0; }

/* Priority badges */
.priority-badge {
    font-size: 0.65rem;
    font-variation-settings: "wght" 600;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.priority-asap { background: #fef2f2; color: var(--red); }
.priority-high { background: #fff7ed; color: var(--orange); }
.priority-medium { background: #eff6ff; color: var(--accent); }
.priority-low { background: #f3f4f6; color: var(--gray); }

.deadline { font-size: 0.8rem; color: var(--text-muted); font-variation-settings: "wght" 450; }
.deadline.overdue { color: var(--red); font-variation-settings: "wght" 600; }

.blocked-badge { font-size: 0.65rem; color: var(--orange); border: 1px solid var(--orange); padding: 0.1rem 0.35rem; border-radius: 3px; }
.compressed-badge { font-size: 0.65rem; color: var(--red); border: 1px solid var(--red); padding: 0.1rem 0.35rem; border-radius: 3px; }
.duration { font-size: 0.75rem; color: var(--text-muted); }

/* Anchor date badge (agenda) — prominent */
.anchor-date {
    font-size: 0.7rem;
    font-variation-settings: "wght" 550;
    color: hsl(var(--case-hue, 220), 50%, 30%);
    background: hsl(var(--case-hue, 220), 45%, 92%);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid hsl(var(--case-hue, 220), 40%, 85%);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}
.empty-hint {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.5rem;
}

/* -----------------------------------------------------------------------
   Kanban board (cases page)
   ----------------------------------------------------------------------- */
.kanban-board {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 1.25rem;
    align-items: start;
}

.kanban-column { min-width: 0; }

.kanban-column-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-variation-settings: "wght" 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}
.column-count {
    font-size: 0.7rem;
    font-variation-settings: "wght" 450;
    color: var(--gray);
    background: var(--bg);
    padding: 0.05rem 0.4rem;
    border-radius: 10px;
}
.column-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: hsl(var(--dot-hue, 220), 55%, 50%);
    flex-shrink: 0;
}

/* Kanban cards — shadow-based, clickable units */
.kanban-card {
    display: block;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--surface);
    border: none;
    border-left: 4px solid hsl(var(--case-hue, 220), 55%, 50%);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    position: relative;
    overflow: hidden;
}
.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.kanban-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.kanban-card-client {
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -0.01em;
}
.kanban-card-stage {
    font-size: 0.78rem;
    color: hsl(var(--case-hue, 220), 50%, 35%);
    margin-top: 0.25rem;
    font-variation-settings: "wght" 500;
}
.kanban-card-task {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.3;
}
.kanban-card-deadline {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-variation-settings: "wght" 450;
}
.kanban-card-overdue {
    font-size: 0.72rem;
    color: var(--red);
    font-variation-settings: "wght" 600;
    margin-top: 0.2rem;
}

/* Progress bar at card bottom */
.kanban-card-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg);
}
.kanban-card-progress-fill {
    height: 100%;
    background: hsl(var(--case-hue, 220), 55%, 50%);
    transition: width 0.3s ease;
    border-radius: 0 3px 0 0;
}

.kanban-empty {
    font-size: 0.8rem;
    color: var(--gray);
    text-align: center;
    padding: 2rem 0.75rem;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
}

.kanban-sidebar {
    min-width: 190px;
    max-width: 260px;
}
.kanban-sidebar .kanban-card {
    padding: 0.6rem 0.75rem;
}
.kanban-sidebar .kanban-card-client {
    font-size: 0.88rem;
}
.kanban-sidebar .kanban-card-task {
    font-size: 0.72rem;
}

@media (max-width: 768px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
    .kanban-sidebar {
        max-width: none;
    }
}

/* -----------------------------------------------------------------------
   Template badge (colored variant)
   ----------------------------------------------------------------------- */
.template-badge {
    font-size: 0.68rem;
    font-variation-settings: "wght" 500;
    background: #f3f4f6;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: var(--text-muted);
    white-space: nowrap;
}
.template-badge.colored {
    background: hsl(var(--case-hue, 220), 50%, 93%);
    color: hsl(var(--case-hue, 220), 50%, 30%);
    border: 1px solid hsl(var(--case-hue, 220), 40%, 85%);
}

/* -----------------------------------------------------------------------
   Case detail
   ----------------------------------------------------------------------- */
.case-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* Progress bar */
.case-progress {
    margin-bottom: 2rem;
    max-width: 480px;
}
.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}
.progress-fill {
    height: 100%;
    background: hsl(var(--case-hue, 220), 55%, 50%);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-text { font-size: 0.8rem; color: var(--text-muted); font-variation-settings: "wght" 450; }

/* Stage progression — hero element */
.stage-progression {
    display: flex;
    gap: 0;
    margin-bottom: 2.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    align-items: flex-start;
}
.stage-pip {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    position: relative;
    flex: 1;
}
/* Connecting line between pips */
.stage-pip:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 12px;
    left: calc(50% + 14px);
    right: calc(-50% + 14px);
    height: 2px;
    background: var(--border);
}
.stage-pip.completed:not(:last-child)::after {
    background: hsl(var(--stage-hue, 140), 55%, 45%);
}
.stage-pip.active:not(:last-child)::after {
    background: linear-gradient(to right, hsl(var(--stage-hue, 210), 65%, 50%), var(--border));
}
.pip-dot {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--surface);
    margin-bottom: 0.4rem;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: transparent;
    transition: all 0.2s ease;
}
.stage-pip.completed .pip-dot {
    background: hsl(var(--stage-hue, 140), 55%, 45%);
    border-color: hsl(var(--stage-hue, 140), 55%, 45%);
    color: white;
}
.stage-pip.active .pip-dot {
    background: hsl(var(--stage-hue, 210), 65%, 50%);
    border-color: hsl(var(--stage-hue, 210), 65%, 50%);
    animation: pip-pulse 2s ease-in-out infinite;
}
@keyframes pip-pulse {
    0%, 100% { box-shadow: 0 0 0 0 hsla(var(--stage-hue, 210), 65%, 50%, 0.4); }
    50% { box-shadow: 0 0 0 6px hsla(var(--stage-hue, 210), 65%, 50%, 0); }
}
.pip-label {
    font-size: 0.72rem;
    text-align: center;
    color: var(--text-muted);
    max-width: 100px;
    line-height: 1.2;
}
.stage-pip.active .pip-label {
    color: hsl(var(--stage-hue, 210), 65%, 35%);
    font-variation-settings: "wght" 600;
}

/* Stage sections */
.stage-section {
    margin-bottom: 2rem;
    padding-left: 1rem;
    border-left: 3px solid hsl(var(--stage-hue, 200), 30%, 85%);
}
.stage-section:has(.stage-title.active) {
    border-left-color: hsl(var(--stage-hue, 210), 55%, 50%);
}
.stage-section:has(.stage-title.completed) {
    border-left-color: hsl(var(--stage-hue, 140), 45%, 75%);
}
.stage-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stage-title.completed { color: var(--text-muted); }
.stage-status-badge {
    font-family: "mundial-narrow-variable", sans-serif;
    font-size: 0.6rem;
    font-variation-settings: "wght" 550;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stage-status-badge.completed {
    background: hsl(var(--stage-hue, 140), 45%, 95%);
    color: hsl(var(--stage-hue, 140), 45%, 40%);
}
.stage-status-badge.active {
    background: hsl(var(--stage-hue, 210), 55%, 93%);
    color: hsl(var(--stage-hue, 210), 55%, 35%);
}
.stage-status-badge.pending { background: #f3f4f6; color: var(--gray); }

/* Task cards in case detail get card treatment (within stage sections) */
.task-card.has-hue {
    background: var(--surface);
    border: none;
    border-left: 4px solid hsl(var(--case-hue, 220), 50%, 65%);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
    border-bottom: none;
}
.task-card.has-hue:last-child {
    border-bottom: none;
}
.task-card.has-hue.overdue {
    border-left-color: var(--red);
}

/* -----------------------------------------------------------------------
   Anchor dates — prominent display
   ----------------------------------------------------------------------- */
.anchors-section {
    margin-top: 2.5rem;
}
.anchors-section h2 {
    margin-bottom: 0.75rem;
}
.anchor-table { border-collapse: collapse; width: 100%; max-width: 480px; }
.anchor-table th, .anchor-table td {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-light);
    font-size: 0.88rem;
}
.anchor-table th {
    background: var(--bg);
    font-variation-settings: "wght" 600;
    text-align: left;
}
.anchor-table tr.anchor-imminent td {
    background: #fef2f2;
    color: var(--red);
    font-variation-settings: "wght" 550;
}
.anchor-table tr.anchor-soon td {
    background: #fffbeb;
    color: #92400e;
    font-variation-settings: "wght" 500;
}

/* -----------------------------------------------------------------------
   Task error message (inline, auto-dismiss)
   ----------------------------------------------------------------------- */
.task-error {
    color: var(--red);
    font-size: 0.72rem;
    font-variation-settings: "wght" 500;
    animation: fade-in-out 3s ease forwards;
}
@keyframes fade-in-out {
    0% { opacity: 0; }
    10% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* -----------------------------------------------------------------------
   Timekeeping
   ----------------------------------------------------------------------- */
.timekeeping-range {
    font-size: 0.85rem;
    font-variation-settings: "wght" 400;
    color: var(--text-muted);
}
.daily-total {
    font-family: "mundial-narrow-variable", sans-serif;
    font-size: 0.7rem;
    font-variation-settings: "wght" 500;
    color: var(--text-muted);
    margin-left: 0.5rem;
}
.timekeeping-total {
    font-variation-settings: "wght" 600;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--border);
    margin-top: 1rem;
    color: var(--text);
}

/* -----------------------------------------------------------------------
   Focus states for all interactive elements
   ----------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .stage-pip:not(:last-child)::after {
        display: none;
    }
    .stage-progression {
        gap: 0.25rem;
    }
}

/* -----------------------------------------------------------------------
   Notes
   ----------------------------------------------------------------------- */

/* Inline note input on agenda task cards */
.task-note-input {
    flex: 1 1 160px;
    min-width: 120px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.task-note-input:hover {
    opacity: 1;
}

.task-note-input:focus {
    opacity: 1;
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

.task-note-input::placeholder {
    font-style: italic;
    opacity: 0.6;
}

/* Notes section on case detail */
.notes-section {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    background: #fafafa;
    border-radius: 8px;
}

.notes-section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.notes-empty {
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}

.notes-empty code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0 0.25rem;
    border-radius: 3px;
    font-style: normal;
}

.notes-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.note-card {
    padding: 0.75rem 1rem;
    background: #fff;
    border-left: 3px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.note-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.note-source-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.06);
}

.note-source-badge.source-webhook {
    background: rgba(66, 133, 244, 0.12);
    color: #1a63c9;
}

.note-source-badge.source-cli {
    background: rgba(120, 120, 120, 0.12);
    color: #555;
}

.note-source-badge.source-dashboard {
    background: rgba(76, 175, 80, 0.14);
    color: #2e7031;
}

.note-task-link {
    font-style: italic;
}

.note-body {
    font-size: 0.95rem;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.4;
}

/* =======================================================================
   v3 Design Tokens — dim/light theme + inset-shadow system
   Activated by data-theme="dim" or data-theme="light" on <html>.
   Token names mirror the round3 Claude Design prototype so per-component
   rules can be ported one consumer at a time. Existing tokens above stay
   in place until each consumer is re-pointed (Unit 3 of dashboard v3).
   Fonts intentionally NOT redefined — the current proforma / mundial-narrow
   stack is preserved.
   ======================================================================= */

:root {
    /* Surfaces */
    --v3-bg: #1f2328;
    --v3-surface: #2b3035;
    --v3-surface-2: #363b40;

    /* Ink (4-step scale, light → dark on dim background) */
    --v3-ink: #f0f1f2;
    --v3-ink-2: #d6d9dc;
    --v3-ink-3: #a0a4a8;
    --v3-ink-4: #6a6d71;

    /* Rules / borders */
    --v3-rule: #42474c;
    --v3-rule-soft: #3c4146;

    /* Accent (default UCBR blue; per-template overrides below) */
    --v3-accent: #77a8d9;
    --v3-accent-2: #b0cdea;
    --v3-accent-wash: rgba(119, 168, 217, 0.15);

    /* Semantic */
    --v3-ok: #5ec28a;
    --v3-warn: #e8c176;
    --v3-danger: #ff668d;
    --v3-danger-ink: #ff99b5;
    --v3-danger-wash: rgba(255, 102, 141, 0.12);

    /* Per-template accents (used to localize the accent variable in scoped
       contexts — e.g. .case-detail[data-template="referee"] { --v3-accent: var(--v3-tpl-referee); }) */
    --v3-tpl-appellate: #8f79cc;
    --v3-tpl-ucbr: #77a8d9;
    --v3-tpl-referee: #73e6c9;
    --v3-tpl-default: #9d9a95;

    /* Shadows — inset (concave depth) + raised float */
    --v3-shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 0 0 1px var(--v3-rule-soft);
    --v3-shadow-inset-sm: inset 0 1px 2px rgba(0, 0, 0, 0.25);
    --v3-shadow-float: 0 16px 40px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.35);

    /* Geometry */
    --v3-radius: 10px;
}

/* Dim theme: redirect the legacy tokens to the v3 dim palette so existing
   components (task cards, kanban cards, notes, anchor table) become legible
   without rewriting every rule. Hardcoded color washes (#fef2f2, #fff7ed)
   still appear lighter than ideal — that's a separate polish pass. */
:root[data-theme="dim"] {
    color-scheme: dark;

    --bg: var(--v3-bg);
    --surface: var(--v3-surface);
    --border: var(--v3-rule);
    --border-light: var(--v3-rule-soft);
    --text: var(--v3-ink);
    --text-muted: var(--v3-ink-3);
    --gray: var(--v3-ink-4);
    --shadow-sm: var(--v3-shadow-inset-sm);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: var(--v3-shadow-float);
}

/* Targeted dim overrides for elements that hardcode light backgrounds. */
:root[data-theme="dim"] .overdue-section {
    background: rgba(255, 102, 141, 0.08);
    border-left-color: var(--v3-danger);
}
:root[data-theme="dim"] .task-card.blocked {
    background: rgba(255, 255, 255, 0.02);
}
:root[data-theme="dim"] .priority-asap   { background: rgba(255, 102, 141, 0.15); color: var(--v3-danger-ink); }
:root[data-theme="dim"] .priority-high   { background: rgba(232, 193, 118, 0.15); color: var(--v3-warn); }
:root[data-theme="dim"] .priority-medium { background: rgba(119, 168, 217, 0.15); color: var(--v3-accent-2); }
:root[data-theme="dim"] .priority-low    { background: rgba(255, 255, 255, 0.04); color: var(--v3-ink-4); }
:root[data-theme="dim"] .notes-section {
    background: var(--v3-surface-2);
}
:root[data-theme="dim"] .note-card {
    background: var(--v3-surface);
    border-left-color: var(--v3-rule);
    box-shadow: none;
}
:root[data-theme="dim"] .anchor-table tr.anchor-imminent td {
    background: rgba(255, 102, 141, 0.12);
    color: var(--v3-danger-ink);
}
:root[data-theme="dim"] .anchor-table tr.anchor-soon td {
    background: rgba(232, 193, 118, 0.10);
    color: var(--v3-warn);
}
:root[data-theme="dim"] .task-card.has-hue {
    background: var(--v3-surface);
    box-shadow: none;
    border: 1px solid var(--v3-rule-soft);
    border-left: 4px solid hsl(var(--case-hue, 220), 50%, 65%);
}
:root[data-theme="dim"] .kanban-card {
    background: var(--v3-surface);
    box-shadow: none;
    border: 1px solid var(--v3-rule-soft);
    border-left: 4px solid hsl(var(--case-hue, 220), 55%, 50%);
}
:root[data-theme="dim"] .kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: var(--v3-rule);
}
:root[data-theme="dim"] .kanban-card-progress { background: var(--v3-bg); }
:root[data-theme="dim"] .progress-bar { background: var(--v3-bg); }
:root[data-theme="dim"] .complete-btn { border-color: var(--v3-rule); }
:root[data-theme="dim"] .complete-btn:hover {
    background: rgba(94, 194, 138, 0.15);
    border-color: var(--v3-ok);
    color: var(--v3-ok);
}
:root[data-theme="dim"] .task-note-input {
    background: var(--v3-bg);
    border-color: var(--v3-rule);
    color: var(--v3-ink);
}
:root[data-theme="dim"] .task-note-input:focus {
    background: var(--v3-bg);
    border-color: var(--v3-accent);
}
:root[data-theme="dim"] .template-badge {
    background: rgba(255, 255, 255, 0.04);
    color: var(--v3-ink-3);
}
:root[data-theme="dim"] .template-badge.colored {
    background: hsl(var(--case-hue, 220), 40%, 25%);
    color: hsl(var(--case-hue, 220), 60%, 80%);
    border-color: hsl(var(--case-hue, 220), 40%, 35%);
}
:root[data-theme="dim"] .anchor-date {
    background: hsl(var(--case-hue, 220), 40%, 22%);
    color: hsl(var(--case-hue, 220), 60%, 78%);
    border-color: hsl(var(--case-hue, 220), 40%, 32%);
}
:root[data-theme="dim"] .stage-status-badge.completed {
    background: rgba(94, 194, 138, 0.18);
    color: var(--v3-ok);
}
:root[data-theme="dim"] .stage-status-badge.active {
    background: var(--v3-accent-wash);
    color: var(--v3-accent-2);
}
:root[data-theme="dim"] .stage-status-badge.pending {
    background: rgba(255, 255, 255, 0.04);
    color: var(--v3-ink-4);
}
:root[data-theme="dim"] .blocked-badge { color: var(--v3-warn); border-color: var(--v3-warn); }
:root[data-theme="dim"] .compressed-badge { color: var(--v3-danger); border-color: var(--v3-danger); }
:root[data-theme="dim"] .deadline.overdue { color: var(--v3-danger-ink); }
:root[data-theme="dim"] .kanban-card-overdue { color: var(--v3-danger-ink); }
:root[data-theme="dim"] .anchor-table th { background: var(--v3-surface-2); }
:root[data-theme="dim"] .empty-state, :root[data-theme="dim"] .kanban-empty {
    color: var(--v3-ink-3);
    border-color: var(--v3-rule-soft);
}

/* When data-theme is active, body picks up the v3 surface as the page background.
   Existing components inside .v3-content keep their own backgrounds; Unit 3 polishes
   them onto the v3 token system. */
:root[data-theme] body {
    background: var(--v3-bg);
    color: var(--v3-ink);
}

/* =======================================================================
   v3 Shell — sidebar + topbar + content
   ======================================================================= */

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

.v3-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--v3-surface-2);
    border-right: 1px solid var(--v3-rule);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    position: sticky;
    top: 0;
    height: 100vh;
    font-family: "mundial-narrow-variable", sans-serif;
}

.v3-brand {
    font-family: "proforma", serif;
    font-size: 22px;
    font-weight: 700;
    padding: 4px 8px 18px;
    color: var(--v3-ink);
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.v3-nav { display: flex; flex-direction: column; gap: 1px; }

.v3-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--v3-ink-2);
    text-decoration: none;
    font-variation-settings: "wght" 500;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    background: transparent;
    border: none;
}
.v3-nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--v3-ink);
}
:root[data-theme="light"] .v3-nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
}
.v3-nav-item.on {
    background: var(--v3-ink-2);
    color: var(--v3-bg);
    font-variation-settings: "wght" 600;
}
.v3-nav-ic {
    width: 16px;
    text-align: center;
    color: var(--v3-ink-4);
    font-family: monospace;
    font-size: 11px;
    font-variation-settings: "wght" 600;
}
.v3-nav-item.on .v3-nav-ic { color: var(--v3-bg); }

.v3-nav-foot {
    margin-top: auto;
    font-size: 11px;
    color: var(--v3-ink-4);
    padding: 10px 8px;
    border-top: 1px solid var(--v3-rule-soft);
    line-height: 1.7;
}
.v3-kbd {
    font-family: "mundial-narrow-variable", monospace;
    font-variation-settings: "wght" 500;
    background: var(--v3-surface);
    border: 1px solid var(--v3-rule);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    color: var(--v3-ink-3);
}

.v3-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.v3-topbar {
    height: 52px;
    border-bottom: 1px solid var(--v3-rule);
    background: var(--v3-surface-2);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    flex-shrink: 0;
}
.v3-date {
    font-family: "mundial-narrow-variable", sans-serif;
    font-variation-settings: "wght" 500;
    font-size: 11px;
    color: var(--v3-ink-3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.v3-spacer { flex: 1; }

.v3-cmdk-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 14px;
    border: none;
    border-radius: 7px;
    background: var(--v3-bg);
    box-shadow: var(--v3-shadow-inset-sm);
    color: var(--v3-ink-3);
    cursor: pointer;
    font-size: 12px;
    font-family: "mundial-narrow-variable", sans-serif;
    min-width: 240px;
    transition: color 0.12s;
}
.v3-cmdk-btn:hover { color: var(--v3-ink); }
.v3-cmdk-btn > span:first-child { flex: 1; text-align: left; }
.v3-cmdk-btn .v3-kbd { background: var(--v3-surface-2); }

.v3-theme-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--v3-rule);
    border-radius: 7px;
    background: var(--v3-surface);
    color: var(--v3-ink-3);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 14px;
    transition: color 0.12s, border-color 0.12s;
}
.v3-theme-toggle:hover {
    color: var(--v3-ink);
    border-color: var(--v3-ink-3);
}

.v3-content {
    padding: 28px 36px 80px;
    flex: 1;
    overflow-y: auto;
}

/* The legacy .container wrapper used inside page templates retains its own
   max-width but no longer needs its own outer padding now that .v3-content
   provides it. Drop redundant outer padding when nested inside the shell. */
.v3-content .container {
    padding: 0;
    max-width: 1280px;
}

/* Hide legacy top-bar nav (kept in CSS for any pages still rendering it). */
.v3-shell .nav { display: none; }

/* =======================================================================
   v3 Case Head + Anchor Card hero
   ======================================================================= */

.v3-case-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--v3-rule-soft);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.v3-case-head-info { min-width: 0; flex: 1; }
.v3-case-head h1 {
    font-family: "proforma", serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--v3-ink);
    margin: 0;
}
.v3-case-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* Per-template accent localization for the case-head and anchor card.
   The data-case-type attribute scopes the accent so anchor card chrome
   matches the template's color identity. --v3-accent-2 is a brighter tint
   for use on dim surfaces; light mode below remaps the same templates to
   darker shades that read on white. */
.v3-case-head[data-case-type="referee"]    { --v3-accent: var(--v3-tpl-referee); --v3-accent-2: #a7f0db; }
.v3-case-head[data-case-type="ucbr"]       { --v3-accent: var(--v3-tpl-ucbr); --v3-accent-2: #b0cdea; }
.v3-case-head[data-case-type="appellate"]  { --v3-accent: var(--v3-tpl-appellate); --v3-accent-2: #c6b8ec; }
.v3-case-head[data-case-type="troubleshoot"] { --v3-accent: #d9a07a; --v3-accent-2: #ecc4a8; }

/* Light mode: anchor card sits on white, so swap to darker shades. */
:root[data-theme="light"] .v3-case-head[data-case-type="referee"]      { --v3-accent: #2aa88a; --v3-accent-2: #1f8a6f; }
:root[data-theme="light"] .v3-case-head[data-case-type="ucbr"]         { --v3-accent: #3d6f9f; --v3-accent-2: #2c5a85; }
:root[data-theme="light"] .v3-case-head[data-case-type="appellate"]    { --v3-accent: #6a5aa0; --v3-accent-2: #534584; }
:root[data-theme="light"] .v3-case-head[data-case-type="troubleshoot"] { --v3-accent: #b27845; --v3-accent-2: #8f5e2f; }

.v3-anchor-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    background: var(--v3-surface-2);
    border-radius: var(--v3-radius);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.35),
        inset 0 0 0 1px var(--v3-accent-wash);
    min-width: 240px;
}
:root[data-theme="light"] .v3-anchor-card {
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.05),
        inset 0 0 0 1px var(--v3-accent-wash);
}
.v3-anchor-num {
    font-family: "proforma", serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--v3-accent-2);
    line-height: 1;
    letter-spacing: -0.02em;
}
.v3-anchor-num-unit {
    font-family: "mundial-narrow-variable", sans-serif;
    font-size: 0.9rem;
    font-variation-settings: "wght" 500;
    margin-left: 4px;
    letter-spacing: 0;
    color: var(--v3-accent-2);
    opacity: 0.8;
}
.v3-anchor-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.v3-anchor-lab {
    font-family: "mundial-narrow-variable", sans-serif;
    font-variation-settings: "wght" 600;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--v3-accent-2);
    text-transform: uppercase;
}
.v3-anchor-date {
    font-size: 13px;
    font-variation-settings: "wght" 600;
    color: var(--v3-ink);
}

/* =======================================================================
   v3 Overdue banner (agenda hero)
   ======================================================================= */

.v3-overdue-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--v3-surface-2);
    border-radius: var(--v3-radius);
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.35),
        inset 0 0 0 1px rgba(255, 102, 141, 0.35);
    margin-bottom: 24px;
}
:root[data-theme="light"] .v3-overdue-banner {
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.05),
        inset 0 0 0 1px rgba(217, 59, 106, 0.25);
}
.v3-overdue-count {
    font-family: "proforma", serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--v3-danger-ink);
    line-height: 1;
}
.v3-overdue-text { flex: 1; min-width: 0; }
.v3-overdue-h {
    font-size: 14px;
    font-variation-settings: "wght" 600;
    color: var(--v3-ink);
}
.v3-overdue-s {
    font-size: 12px;
    color: var(--v3-ink-2);
    margin-top: 3px;
    line-height: 1.4;
}

/* =======================================================================
   Stage pipeline polish — applied via :root[data-theme] so the existing
   stage-progression block from above gets refined dot/connector treatment
   when the v3 theme is active.
   ======================================================================= */

:root[data-theme] .stage-progression {
    background: var(--v3-surface-2);
    border-radius: var(--v3-radius);
    box-shadow: var(--v3-shadow-inset);
    padding: 14px 16px;
    align-items: center;
}
:root[data-theme] .stage-pip:not(:last-child)::after {
    background: var(--v3-rule);
    height: 1.5px;
}
:root[data-theme] .stage-pip.completed:not(:last-child)::after {
    background: var(--v3-ink-3);
}
:root[data-theme] .stage-pip.active:not(:last-child)::after {
    background: linear-gradient(to right, var(--v3-accent), var(--v3-rule));
}
:root[data-theme] .stage-pip .pip-dot {
    background: var(--v3-surface);
    border-color: var(--v3-rule);
    box-shadow: var(--v3-shadow-inset-sm);
    width: 20px;
    height: 20px;
}
:root[data-theme] .stage-pip.completed .pip-dot {
    background: var(--v3-ink-2);
    border-color: var(--v3-ink-2);
    color: var(--v3-bg);
    box-shadow: none;
}
:root[data-theme] .stage-pip.active .pip-dot {
    background: var(--v3-accent);
    border-color: var(--v3-accent);
    box-shadow: 0 0 0 4px var(--v3-accent-wash);
    animation: none;
}
:root[data-theme] .stage-pip .pip-label {
    color: var(--v3-ink-3);
    margin-top: 8px;
}
:root[data-theme] .stage-pip.active .pip-label {
    color: var(--v3-accent-2);
    font-variation-settings: "wght" 600;
}

/* Page background keeps surfaces visible. The pages themselves still use
   their own white card backgrounds for cards/tables; that mismatch is
   intentional and lives until a future polish pass. */
:root[data-theme] h1 { color: var(--v3-ink); }

@media (max-width: 900px) {
    .v3-sidebar { display: none; }
    .v3-content { padding: 20px 16px 60px; }
    .v3-cmdk-btn { min-width: 0; }
    .v3-cmdk-btn > span:first-child { display: none; }
}

/* Light theme overrides */
:root[data-theme="light"] {
    color-scheme: light;

    --v3-bg: #f4f4f3;
    --v3-surface: #ffffff;
    --v3-surface-2: #fafaf9;

    --v3-ink: #1a1a1a;
    --v3-ink-2: #373737;
    --v3-ink-3: #676767;
    --v3-ink-4: #a5a5a5;

    --v3-rule: #e3e3e1;
    --v3-rule-soft: #ececea;

    --v3-accent: #4a7aa8;
    --v3-accent-2: #6b9bc9;
    --v3-accent-wash: rgba(74, 122, 168, 0.12);

    --v3-ok: #3a7a4a;
    --v3-warn: #b0742a;
    --v3-danger: #d93b6a;
    --v3-danger-ink: #c9295b;
    --v3-danger-wash: rgba(217, 59, 106, 0.12);

    --v3-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 0 0 1px var(--v3-rule-soft);
    --v3-shadow-inset-sm: inset 0 1px 1px rgba(0, 0, 0, 0.04);
    --v3-shadow-float: 0 16px 40px rgba(0, 0, 0, 0.14), 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* =========================================================================
   Layer B / Units 5-6: composer modal + task edit sheet
   Shared shell (.v3-composer) driven by reschedule.js and task_edit.js.
   ========================================================================= */

.v3-composer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 120ms ease;
}
.v3-composer.open { opacity: 1; }
.v3-composer[hidden] { display: none; }

.v3-composer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.v3-composer-card {
    position: relative;
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: var(--v3-surface, var(--surface));
    color: var(--v3-ink, var(--text));
    border: 1px solid var(--v3-rule, var(--border));
    border-radius: var(--v3-radius, 10px);
    box-shadow: var(--v3-shadow-float, var(--shadow-lg));
    padding: 20px 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.v3-composer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.v3-composer-title {
    margin: 0;
    font-family: 'proforma', Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--v3-ink, var(--text));
}
.v3-composer-close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--v3-ink-3, var(--text-muted));
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.v3-composer-close:hover { background: var(--v3-rule-soft, var(--border-light)); }

.v3-composer-body { display: flex; flex-direction: column; gap: 12px; }

.v3-composer-summary {
    font-size: 14px;
    color: var(--v3-ink-2, var(--text-muted));
    min-height: 20px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--v3-accent-wash);
    box-shadow: var(--v3-shadow-inset-sm, var(--shadow-sm));
}
.v3-composer-summary:empty { display: none; }
.v3-composer-summary-main { margin: 0; }
.v3-composer-summary-warn {
    margin: 6px 0 0;
    color: var(--v3-danger-ink, var(--v3-danger));
    font-weight: 500;
}

.v3-composer-error {
    font-size: 13px;
    color: var(--v3-danger-ink, var(--v3-danger));
    background: var(--v3-danger-wash);
    border-radius: 8px;
    padding: 8px 12px;
}

.v3-composer-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}
.v3-composer-primary,
.v3-composer-secondary {
    border: 1px solid var(--v3-rule, var(--border));
    background: var(--v3-surface-2, var(--bg));
    color: var(--v3-ink, var(--text));
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.v3-composer-primary {
    background: var(--v3-accent);
    color: #fff;
    border-color: var(--v3-accent);
}
.v3-composer-primary:hover { filter: brightness(1.06); }
.v3-composer-primary:disabled { opacity: 0.5; cursor: default; }
.v3-composer-secondary:hover { background: var(--v3-rule-soft, var(--border-light)); }

/* Edit form fields — shared by reschedule and task-edit body content */
.v3-edit-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
}
.v3-edit-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.v3-edit-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--v3-ink-3, var(--text-muted));
}
.v3-edit-input {
    width: 100%;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    color: var(--v3-ink, var(--text));
    background: var(--v3-surface-2, var(--bg));
    border: 1px solid var(--v3-rule, var(--border));
    border-radius: 8px;
    box-shadow: var(--v3-shadow-inset-sm, var(--shadow-sm));
}
.v3-edit-input:focus {
    outline: 2px solid var(--v3-accent);
    outline-offset: 1px;
}
.v3-edit-input:disabled { opacity: 0.5; }

.v3-edit-deadline-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.v3-edit-date { flex: 1 1 160px; }
.v3-edit-snooze { display: flex; gap: 6px; }
.v3-edit-snooze-btn {
    border: 1px solid var(--v3-rule, var(--border));
    background: var(--v3-surface-2, var(--bg));
    color: var(--v3-ink-2, var(--text));
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.v3-edit-snooze-btn:hover { background: var(--v3-accent-wash); border-color: var(--v3-accent); }
.v3-edit-snooze-btn:disabled { opacity: 0.5; cursor: default; }

.v3-edit-block {
    border: 0;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.v3-edit-block legend { padding: 0; }
.v3-edit-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.v3-edit-sub { margin-left: 24px; }

/* Edit-button affordance on task rows */
.v3-task-edit-btn {
    border: 1px solid var(--v3-rule, var(--border));
    background: var(--v3-surface-2, var(--bg));
    color: var(--v3-ink-2, var(--text-muted));
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.v3-task-edit-btn:hover {
    color: var(--v3-accent);
    border-color: var(--v3-accent);
    background: var(--v3-accent-wash);
}

/* Make the anchor card behave as a button */
button.v3-anchor-card {
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
button.v3-anchor-card:hover { filter: brightness(1.06); }
button.v3-anchor-card:focus-visible {
    outline: 2px solid var(--v3-accent);
    outline-offset: 2px;
}

/* =========================================================================
   ⌘K palette — shares the composer backdrop/layering tokens but has its
   own card layout (input + filter list, not a confirm composer).
   ========================================================================= */

.v3-palette {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
}
.v3-palette[hidden] { display: none; }

.v3-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.v3-palette-card {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 28vh);
    display: flex;
    flex-direction: column;
    background: var(--v3-surface, var(--surface));
    color: var(--v3-ink, var(--text));
    border: 1px solid var(--v3-rule, var(--border));
    border-radius: var(--v3-radius, 10px);
    box-shadow: var(--v3-shadow-float, var(--shadow-lg));
    overflow: hidden;
}

.v3-palette-label {
    position: absolute;
    width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.v3-palette-input {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--v3-rule, var(--border));
    padding: 16px 20px;
    font-family: inherit;
    font-size: 16px;
    background: transparent;
    color: var(--v3-ink, var(--text));
    outline: none;
}
.v3-palette-input::placeholder { color: var(--v3-ink-3, var(--text-muted)); }

.v3-palette-results {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.v3-palette-results[hidden] { display: none; }

.v3-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    cursor: pointer;
}
.v3-palette-item[aria-selected="true"] {
    background: var(--v3-accent-wash);
}

.v3-palette-chip {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 4px;
    color: #fff;
}
.v3-palette-chip--case { background: var(--v3-tpl-ucbr, #77a8d9); }
.v3-palette-chip--task { background: var(--v3-tpl-referee, #73e6c9); color: #0b1d18; }
.v3-palette-chip--nav  { background: var(--v3-ink-3, #666); }

.v3-palette-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.v3-palette-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--v3-ink, var(--text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.v3-palette-subtitle {
    font-size: 12px;
    color: var(--v3-ink-3, var(--text-muted));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v3-palette-empty {
    padding: 24px 20px;
    color: var(--v3-ink-3, var(--text-muted));
    font-size: 14px;
    text-align: center;
}

.v3-palette-hint {
    display: flex;
    gap: 14px;
    padding: 10px 20px;
    border-top: 1px solid var(--v3-rule, var(--border));
    font-size: 11px;
    color: var(--v3-ink-3, var(--text-muted));
}
.v3-palette-hint .v3-kbd { font-size: 10px; }

/* =========================================================================
   Case-detail action row — lightweight buttons that open the add-task /
   add-note composer sheets. Shares the understated tone of .v3-task-edit-btn.
   ========================================================================= */
.v3-case-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0 18px;
}
.v3-case-action {
    border: 1px solid var(--v3-rule, var(--border));
    background: var(--v3-surface-2, var(--bg));
    color: var(--v3-ink-2, var(--text-muted));
    padding: 6px 12px;
    font-size: 12px;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.02em;
}
.v3-case-action:hover {
    color: var(--v3-accent);
    border-color: var(--v3-accent);
    background: var(--v3-accent-wash);
}
.v3-case-action:focus-visible {
    outline: 2px solid var(--v3-accent);
    outline-offset: 2px;
}

/* Textarea variant of the shared edit input — preserves padding/border
   from .v3-edit-input and adds sensible line-height + resize affordance. */
.v3-edit-textarea {
    min-height: 120px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

/* =========================================================================
   Post-complete toast — shown after a successful agenda quick-complete on
   a case-attached task. Offers a one-tap path into the add-note sheet.
   ========================================================================= */
.v3-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 20px);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--v3-surface-2, var(--bg));
    color: var(--v3-ink, var(--text));
    border: 1px solid var(--v3-rule, var(--border));
    border-radius: var(--v3-radius, 10px);
    padding: 10px 14px;
    font-size: 14px;
    box-shadow: var(--v3-shadow-float, var(--shadow-lg));
    opacity: 0;
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 200;
    pointer-events: auto;
    max-width: calc(100vw - 40px);
}
.v3-toast.open {
    opacity: 1;
    transform: translate(-50%, 0);
}
.v3-toast-msg {
    color: var(--v3-ink-2, var(--text));
}
.v3-toast-action {
    border: 1px solid var(--v3-accent);
    background: var(--v3-accent-wash);
    color: var(--v3-accent-2, var(--v3-accent));
    padding: 4px 10px;
    font-size: 12px;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.02em;
}
.v3-toast-action:hover {
    filter: brightness(1.12);
}
.v3-toast-dismiss {
    border: none;
    background: transparent;
    color: var(--v3-ink-3, var(--text-muted));
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.v3-toast-dismiss:hover {
    color: var(--v3-ink, var(--text));
}
