/* TaskStream - built on the Stitch design tokens, with a widened accent
   palette, urgency colour coding, and motion. */

:root {
    /* Core roles (from the Stitch mockups) */
    --primary: #00685f;
    --primary-bright: #00a896;
    --primary-container: #008378;
    --on-primary: #ffffff;
    --secondary: #565e74;
    --secondary-container: #dae2fd;
    --on-secondary-container: #3f465c;
    --secondary-fixed-dim: #bec6e0;
    --background: #f6f8ff;
    --surface: #f8f9ff;
    --on-surface: #0b1c30;
    --on-background: #0b1c30;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #eff4ff;
    --surface-container: #e5eeff;
    --on-surface-variant: #3d4947;
    --outline: #6d7a77;
    --outline-variant: #c9d4e8;
    --error: #e5484d;
    --error-container: #ffdad6;
    --on-error-container: #93000a;

    /* Accents - the colour that brings the UI to life */
    --accent-sky: #3aa0ff;
    --accent-violet: #7c5cff;
    --accent-amber: #f5a524;
    --accent-coral: #ff6b57;
    --accent-mint: #00c9a7;

    /* Urgency ramp: how soon a reminder is due */
    --u-overdue: #e5484d;
    --u-soon: #f5a524;
    --u-today: #00a896;
    --u-later: #7c5cff;
    --u-none: #8b97ad;

    --grad-brand: linear-gradient(120deg, #00a896, #3aa0ff 55%, #7c5cff);
    --grad-primary: linear-gradient(135deg, #00a896, #00685f);

    /* Spacing scale */
    --gutter: 16px;
    --container-padding: 24px;
    --stack-sm: 8px;
    --stack-md: 16px;
    --stack-lg: 32px;

    /* Radii */
    --radius: 0.25rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;

    --sidebar-w: 240px;
    --topbar-h: 64px;
    --ease: cubic-bezier(.16, 1, .3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    background: var(--background);
    color: var(--on-background);
    -webkit-font-smoothing: antialiased;
}

/* Type scale ------------------------------------------------------------- */
.t-display    { font-size: 36px; line-height: 44px; letter-spacing: -0.02em; font-weight: 700; }
.t-headline-lg{ font-size: 24px; line-height: 32px; letter-spacing: -0.01em; font-weight: 600; }
.t-headline-sm{ font-size: 18px; line-height: 24px; font-weight: 600; }
.t-body-lg    { font-size: 16px; line-height: 24px; font-weight: 400; }
.t-body-md    { font-size: 14px; line-height: 20px; font-weight: 400; }
.t-label-md   { font-size: 12px; line-height: 16px; letter-spacing: 0.01em; font-weight: 500; }
.t-label-sm   { font-size: 11px; line-height: 16px; font-weight: 600; }

.muted   { color: var(--secondary); }
.faint   { color: var(--u-none); }
h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }

.gradient-text {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Keyframes -------------------------------------------------------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}
@keyframes ringPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 168, 150, .45); }
    50%      { transform: scale(1.06); box-shadow: 0 0 0 16px rgba(0, 168, 150, 0); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, -30px) scale(1.15); }
}
@keyframes shimmer {
    from { background-position: 0% 50%; }
    to   { background-position: 200% 50%; }
}
@keyframes softPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}
/* Halo over a card the live poller just brought in. Animates box-shadow, not
   background, so it can't fight the priority tint underneath. */
@keyframes arrive {
    0%   { box-shadow: 0 0 0 4px rgba(124, 92, 255, .6); }
    100% { box-shadow: 0 0 0 4px rgba(124, 92, 255, 0); }
}

.float { animation: float 3.5s ease-in-out infinite; }

/* Icons ------------------------------------------------------------------ */
.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: currentColor;
    display: block;
}
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; }
.icon-lg { width: 52px; height: 52px; }

/* Buttons ---------------------------------------------------------------- */
.btn {
    font: inherit;
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.01em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform .18s var(--ease), box-shadow .18s, background-color .15s,
                border-color .15s, color .15s, filter .15s;
}
.btn-primary {
    background: var(--grad-primary);
    color: var(--on-primary);
    box-shadow: 0 2px 8px rgba(0, 104, 95, .25);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(0, 104, 95, .32); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-outline {
    background: var(--surface-container-lowest);
    color: var(--secondary);
    border-color: var(--outline-variant);
}
.btn-outline:hover {
    background: var(--surface-container-low);
    border-color: var(--primary-bright);
    color: var(--primary);
    transform: translateY(-1px);
}
.btn-outline:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--primary-bright); outline-offset: 2px; }

.icon-btn {
    background: none;
    border: 0;
    padding: 8px;
    border-radius: var(--radius-full);
    color: var(--secondary);
    cursor: pointer;
    display: inline-flex;
    transition: background-color .15s, color .15s, transform .18s var(--ease);
}
.icon-btn:hover { background: var(--surface-container-low); color: var(--primary); transform: scale(1.12); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-on { color: var(--primary-bright); }
.icon-btn.danger:hover { background: var(--error-container); color: var(--error); }

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 40;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--container-padding);
    margin-bottom: var(--stack-lg);
    text-decoration: none;
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--grad-primary);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 168, 150, .35);
    transition: transform .3s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.08); }
.brand-name { font-weight: 700; }

.sidebar-cta { padding: 0 var(--container-padding); margin-bottom: var(--stack-lg); }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-list.grow { flex: 1; }
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--secondary);
    text-decoration: none;
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.01em;
    font-weight: 600;
    transition: background-color .15s, color .15s, padding-left .2s var(--ease);
}
.nav-link::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--grad-primary);
    transform: scaleY(0);
    transition: transform .25s var(--ease);
}
.nav-link:hover { background: var(--surface-container-low); color: var(--primary); padding-left: 20px; }
.nav-link.active {
    background: linear-gradient(90deg, rgba(0, 168, 150, .14), rgba(58, 160, 255, .06));
    color: var(--primary);
}
.nav-link.active::before { transform: scaleY(1); }
.nav-count {
    margin-left: auto;
    background: var(--surface-container);
    color: var(--on-surface-variant);
    border-radius: var(--radius-full);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
}
.nav-link.active .nav-count { background: var(--grad-primary); color: #fff; }
/* Unread assignments waiting - loud enough to notice from the sidebar. */
.nav-count.alert,
.nav-link.active .nav-count.alert {
    background: var(--u-overdue);
    color: #fff;
    animation: softPulse 1.8s ease-in-out infinite;
}

.sidebar-foot {
    margin-top: auto;
    border-top: 1px solid var(--outline-variant);
    padding-top: var(--stack-md);
}
.account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px var(--container-padding) 0;
}
.avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    /* --h is a per-user hue set inline, so every account looks distinct. */
    background: linear-gradient(135deg,
        hsl(var(--h, 170) 70% 55%), hsl(calc(var(--h, 170) + 40) 75% 45%));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 8px hsl(var(--h, 170) 60% 50% / .4);
}
.account-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--on-surface);
    font-weight: 600;
}

/* Top bar ---------------------------------------------------------------- */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-w);
    height: var(--topbar-h);
    background: rgba(248, 249, 255, .82);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    z-index: 30;
}
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu-btn { display: none; }

/* Main ------------------------------------------------------------------- */
.app-main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--topbar-h) + var(--stack-lg)) var(--container-padding) 64px;
}
.page { max-width: 768px; margin: 0 auto; }

.page-head {
    margin-bottom: var(--stack-lg);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--stack-md);
    border-bottom: 1px solid var(--outline-variant);
    padding-bottom: var(--stack-md);
    animation: slideUp .5s var(--ease) backwards;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, rgba(245, 165, 36, .16), rgba(255, 107, 87, .16));
    color: #b25c00;
    font-weight: 600;
    white-space: nowrap;
}
.count-pill.done {
    background: linear-gradient(135deg, rgba(0, 201, 167, .18), rgba(58, 160, 255, .14));
    color: var(--primary);
}

/* Task cards ------------------------------------------------------------- */
.task-list { display: flex; flex-direction: column; gap: var(--stack-sm); }

.task-card {
    position: relative;
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    padding: var(--stack-md);
    padding-left: 20px;
    display: flex;
    align-items: flex-start;
    gap: var(--stack-md);
    overflow: hidden;
    transition: border-color .2s, box-shadow .25s var(--ease),
                transform .25s var(--ease), opacity .25s;
    /* "backwards" (not "both") so the finished animation stops owning
       transform, leaving the hover lift free to apply. */
    animation: cardIn .45s var(--ease) backwards;
    animation-delay: calc(var(--i, 0) * 55ms);
}
/* Urgency stripe down the left edge. */
.task-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--stripe, var(--u-none));
    transition: width .2s var(--ease);
}
.task-card:hover {
    border-color: transparent;
    box-shadow: 0 10px 28px rgba(11, 28, 48, .12);
    transform: translateY(-3px);
}
.task-card:hover::before { width: 6px; }

.task-card.u-overdue { --stripe: var(--u-overdue); }
.task-card.u-soon    { --stripe: var(--u-soon); }
.task-card.u-today   { --stripe: var(--u-today); }
.task-card.u-later   { --stripe: var(--u-later); }
.task-card.u-none    { --stripe: var(--u-none); }
.task-card.done      { --stripe: var(--u-today); opacity: .72; }
.task-card.done:hover { opacity: 1; }

/* Plays briefly before the "mark done" form actually submits. */
.task-card.completing {
    opacity: .35;
    transform: translateX(10px) scale(.98);
}
.task-card.completing .check {
    background: var(--primary-bright);
    border-color: var(--primary-bright);
    color: #fff;
    animation: pop .3s ease;
}

.task-body { flex: 1; min-width: 0; }
.task-title { margin-bottom: 4px; word-wrap: break-word; }
.task-card.done .task-title {
    text-decoration: line-through;
    color: var(--secondary);
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
}
.task-desc {
    color: var(--secondary);
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-weight: 600;
    color: var(--u-none);
    background: rgba(139, 151, 173, .12);
}
.meta-item.u-overdue { color: var(--u-overdue); background: rgba(229, 72, 77, .12); }
.meta-item.u-soon    { color: #b25c00;         background: rgba(245, 165, 36, .16); }
.meta-item.u-today   { color: var(--primary);  background: rgba(0, 168, 150, .14); }
.meta-item.u-later   { color: var(--u-later);  background: rgba(124, 92, 255, .12); }
.meta-item.u-overdue { animation: fadeIn .3s ease; }

.meta-dot { width: 4px; height: 4px; border-radius: var(--radius-full); background: var(--outline-variant); }
.chip {
    background: var(--surface-container);
    color: var(--on-surface-variant);
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

/* Round checkbox that submits the "done" form */
.check {
    margin-top: 2px;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    border: 2px solid var(--outline-variant);
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: border-color .15s, background-color .15s, color .15s, transform .2s var(--ease);
    padding: 0;
}
.task-card:hover .check { border-color: var(--primary-bright); }
.check:hover {
    background: var(--grad-primary);
    border-color: transparent;
    color: #fff;
    transform: scale(1.15);
}
.check:active { transform: scale(.9); }

.check-done {
    margin-top: 2px;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--grad-primary);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 168, 150, .35);
}

.task-actions { display: flex; align-items: center; gap: 8px; align-self: center; }
.task-card .task-actions { opacity: 0; transform: translateX(6px); transition: opacity .2s, transform .2s var(--ease); }
.task-card:hover .task-actions,
.task-card:focus-within .task-actions { opacity: 1; transform: none; }

.inline-form { display: inline-flex; margin: 0; }

.group-head {
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    margin: var(--stack-lg) 0 var(--stack-sm);
}
.group-head:first-child { margin-top: var(--stack-md); }

/* Quick add -------------------------------------------------------------- */
.quick-add {
    margin-top: var(--stack-md);
    padding: 12px 16px;
    border: 1px dashed var(--outline-variant);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    color: var(--u-none);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    text-align: left;
    transition: border-color .2s, color .2s, background-color .2s, transform .2s var(--ease);
}
.quick-add:hover {
    border-color: var(--primary-bright);
    color: var(--primary);
    background: rgba(0, 168, 150, .05);
    transform: translateY(-2px);
}
.quick-add .icon { transition: transform .3s var(--ease); }
.quick-add:hover .icon { transform: rotate(90deg); }

/* Empty state ------------------------------------------------------------ */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 24px;
    text-align: center;
    animation: slideUp .5s var(--ease) backwards;
}
.empty .icon-lg { color: var(--secondary-fixed-dim); margin-bottom: var(--stack-md); }

/* Forms ------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: var(--stack-sm); }
.field-label { color: var(--on-surface); font-weight: 600; }

.input,
.textarea {
    width: 100%;
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    color: var(--on-surface);
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    padding: 11px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 76px; }
.input::placeholder,
.textarea::placeholder { color: var(--secondary-fixed-dim); }
.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary-bright);
    box-shadow: 0 0 0 3px rgba(0, 168, 150, .18);
}

.input-icon { position: relative; display: block; }
.input-icon > .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--u-none);
    pointer-events: none;
    transition: color .15s;
}
.input-icon .input { padding-left: 40px; }
.input-icon:focus-within > .icon { color: var(--primary-bright); }

/* Borderless title input used in the Add Task modal */
.input-title {
    width: 100%;
    font: inherit;
    font-size: 18px;
    line-height: 24px;
    font-weight: 600;
    color: var(--on-surface);
    background: none;
    border: 0;
    border-bottom: 2px solid var(--outline-variant);
    border-radius: 0;
    padding: 8px 0;
    transition: border-color .2s;
}
.input-title::placeholder { color: var(--secondary-fixed-dim); font-weight: 400; }
.input-title:focus { outline: none; border-bottom-color: var(--primary-bright); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: var(--radius-full);
    border: 1px solid var(--outline-variant);
    background: var(--surface);
    color: var(--secondary);
    font: inherit;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, transform .18s var(--ease);
}
.time-chip:hover { background: var(--surface-container-low); transform: translateY(-2px); }
.time-chip.active {
    border-color: transparent;
    background: var(--grad-primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 168, 150, .35);
}

/* Auth screens ----------------------------------------------------------- */
.auth-shell {
    position: relative;
    background: linear-gradient(160deg, #eef3ff, #e6f7f4 55%, #f3eeff);
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--stack-md);
    overflow: hidden;
}
/* Slow-drifting colour blobs behind the card. */
.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    animation: drift 16s ease-in-out infinite alternate;
    pointer-events: none;
}
.orb-a { width: 320px; height: 320px; background: var(--accent-mint);   top: -60px; left: -40px; }
.orb-b { width: 280px; height: 280px; background: var(--accent-sky);    bottom: -70px; right: -50px; animation-delay: -5s; }
.orb-c { width: 240px; height: 240px; background: var(--accent-violet); top: 40%; right: 15%; animation-delay: -10s; opacity: .35; }

.auth-card {
    position: relative;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(16px);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 50px rgba(11, 28, 48, .14);
    padding: var(--stack-lg);
    animation: slideUp .55s var(--ease) both;
}
.auth-head { text-align: center; margin-bottom: var(--stack-lg); }
.auth-mark {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-xl);
    background: var(--grad-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--stack-md);
    box-shadow: 0 8px 20px rgba(0, 168, 150, .4);
}
.auth-head h1 { margin-bottom: var(--stack-sm); font-size: 30px; line-height: 38px; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: var(--stack-md); }
.auth-actions { display: flex; flex-direction: column; gap: var(--stack-sm); margin-top: var(--stack-sm); }
.auth-alt { text-align: center; color: var(--secondary); margin-top: var(--stack-md); }
.link { color: var(--primary); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Modal ------------------------------------------------------------------ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--stack-md);
    background: rgba(11, 28, 48, .45);
    backdrop-filter: blur(5px);
    animation: fadeIn .25s ease-out both;
}
.modal-backdrop[hidden] { display: none; }

.modal-card {
    background: var(--surface-container-lowest);
    width: 100%;
    max-width: 448px;
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 32px);
    animation: slideUp .4s var(--ease) both;
}
/* The add/edit/assign modals wrap head+body+foot in a <form>. That form is the
   real flex child of .modal-card, so it has to carry the column layout too -
   otherwise no height constraint reaches .modal-body and it cannot scroll. */
.modal-card > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-head {
    flex: 0 0 auto;
    padding: var(--stack-md) var(--container-padding);
    border-bottom: 1px solid var(--outline-variant);
    background: linear-gradient(120deg, rgba(0, 168, 150, .1), rgba(124, 92, 255, .07));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--stack-md);
}
.modal-body {
    padding: var(--container-padding);
    display: flex;
    flex-direction: column;
    gap: var(--stack-md);
    overflow-y: auto;
    /* A flex child defaults to min-height:auto, which refuses to shrink below
       its content - so overflow-y never engaged. Dragging the textarea taller
       grew this box, pushed the footer past the card's clipped edge, and made
       Cancel / Save Task unreachable. min-height:0 lets it scroll instead. */
    flex: 1 1 auto;
    min-height: 0;
}
/* Keep a drag from swallowing the whole viewport in one go. */
.modal-body .textarea { max-height: 55vh; }
.modal-foot {
    flex: 0 0 auto;
    padding: var(--stack-md) var(--container-padding);
    border-top: 1px solid var(--outline-variant);
    background: var(--surface-container-low);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}
.modal-foot.spread { justify-content: space-between; }

/* Alarm ------------------------------------------------------------------ */
.alarm-mark {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
    background: var(--grad-primary);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--stack-md);
    animation: ringPulse 1.4s ease-in-out infinite;
}
.alarm-body { text-align: center; }
.alarm-body .task-desc { margin-top: var(--stack-sm); margin-bottom: 0; }
.alarm-time {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: var(--stack-md);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    background: rgba(0, 168, 150, .14);
    color: var(--primary);
    font-weight: 600;
}

/* Roles, badges, admin & manager views ----------------------------------- */
.role-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    line-height: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.role-admin        { background: rgba(255, 107, 87, .16);  color: #b3350f; }
.role-head_manager { background: rgba(58, 160, 255, .18);  color: #0b5ea8; }
.role-manager      { background: rgba(124, 92, 255, .16);  color: #4c30c9; }
.role-user         { background: rgba(0, 168, 150, .16);   color: var(--primary); }

/* "from a manager" marker on an assigned task */
.assigned-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    background: rgba(124, 92, 255, .13);
    color: #4c30c9;
    font-size: 11px;
    line-height: 16px;
    font-weight: 700;
    white-space: nowrap;
}
.task-card.is-assigned { --stripe: var(--accent-violet); }
.task-card.is-assigned::before { width: 6px; }

/* who a manager sent a task to */
.who-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    background: hsl(var(--h, 170) 70% 95%);
    color: hsl(var(--h, 170) 65% 30%);
    font-size: 11px;
    line-height: 16px;
    font-weight: 700;
}

.task-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}
.task-title-row .task-title { margin-bottom: 0; }

.icon-btn.locked { color: var(--secondary-fixed-dim); cursor: not-allowed; }
.icon-btn.locked:hover { background: none; color: var(--secondary-fixed-dim); transform: none; }

.status-dot {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    border: 3px solid var(--u-soon);
    background: transparent;
}

.pill-status {
    padding: 4px 11px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.pill-status.pending { background: rgba(245, 165, 36, .18); color: #b25c00; }
.pill-status.ok      { background: rgba(0, 168, 150, .18); color: var(--primary); }
/* Read receipts: not-read is a nudge, read is a calm "yes, they saw it". */
.pill-status.unread {
    background: var(--u-overdue);
    color: #fff;
    animation: softPulse 1.8s ease-in-out infinite;
}
.pill-status.read {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(58, 160, 255, .16);
    color: #0b5fa5;
}

/* Priority ---------------------------------------------------------------
   Normal green, Important yellow, Now red. One --prio colour per bucket
   feeds the pill, the dot and the card tint, so they can never disagree. */
.p-normal {
    --prio: var(--accent-mint);
    --prio-ink: #056b5b;
    --prio-soft: rgba(0, 201, 167, .15);
    --prio-line: rgba(0, 201, 167, .42);
}
.p-important {
    --prio: var(--u-soon);
    --prio-ink: #96500b;
    --prio-soft: rgba(245, 165, 36, .18);
    --prio-line: rgba(245, 165, 36, .48);
}
.p-now {
    --prio: var(--u-overdue);
    --prio-ink: #a8262a;
    --prio-soft: rgba(229, 72, 77, .15);
    --prio-line: rgba(229, 72, 77, .45);
}

.prio-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    line-height: 16px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--prio-ink, var(--secondary));
    background: var(--prio-soft, rgba(139, 151, 173, .14));
    border: 1px solid var(--prio-line, transparent);
}
.prio-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--prio, var(--u-none));
    flex-shrink: 0;
}
/* "Now" means now: keep the dot moving so it reads as live. */
.prio-pill.p-now .prio-dot { animation: softPulse 1.2s ease-in-out infinite; }

/* A tint across the whole card, strongest for "Now". The gradient is layered
   *over* the card's own surface colour - a bare gradient to `transparent`
   would drop the white and let the page background show through. Kept
   low-alpha so the left urgency stripe still carries the reminder timing. */
.task-card.p-important {
    background: linear-gradient(90deg, rgba(245, 165, 36, .12), transparent 62%),
                var(--surface-container-lowest);
}
.task-card.p-now {
    background: linear-gradient(90deg, rgba(229, 72, 77, .15), transparent 68%),
                var(--surface-container-lowest);
    border-color: rgba(229, 72, 77, .45);
}
/* Finished work should stop shouting. */
.task-card.done.p-important,
.task-card.done.p-now {
    background: var(--surface-container-lowest);
    border-color: var(--outline-variant);
}
.task-card.done .prio-pill { opacity: .65; }
.task-card.done .prio-dot { animation: none; }

/* Unread assignment ----------------------------------------------------- */
.task-card.is-unread { box-shadow: 0 0 0 2px rgba(124, 92, 255, .35); }
.status-dot.unread {
    border-color: var(--u-overdue);
    animation: softPulse 1.8s ease-in-out infinite;
}
.status-dot.seen { border-color: var(--accent-sky); }

.btn-read {
    background: var(--accent-sky);
    color: #fff;
    border-color: transparent;
}
.btn-read:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-xs { padding: 3px 10px; font-size: 11px; gap: 5px; border-radius: var(--radius-full); }

/* Priority picker inside the add / edit / assign modals ------------------
   The selected look comes from `input:checked + .prio-face` - a plain adjacent
   sibling, which every browser invalidates correctly. An earlier version used
   `.prio-opt:has(input:checked)` on the label instead; that styles the initial
   state fine but Chrome does not re-invalidate it when the checked radio moves
   within a group, so picking a new priority lit nothing and left the old one
   looking selected. Hence the extra .prio-face wrapper. */
.prio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.prio-opt {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}
.prio-opt input { position: absolute; opacity: 0; pointer-events: none; }

.prio-face {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--radius-full);
    border: 1px solid var(--outline-variant);
    background: var(--surface-container-lowest);
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary);
    transition: border-color .15s, background-color .15s, color .15s,
                transform .2s var(--ease);
}
.prio-opt:hover .prio-face { transform: translateY(-1px); }
.prio-opt input:checked + .prio-face {
    border-color: var(--prio);
    background: var(--prio-soft);
    color: var(--prio-ink);
}
.prio-opt input:checked + .prio-face .prio-dot { box-shadow: 0 0 0 3px var(--prio-soft); }
.prio-opt input:focus-visible + .prio-face {
    outline: 2px solid var(--primary-bright);
    outline-offset: 2px;
}

/* Live refresh ----------------------------------------------------------
   No fill-mode on `arrive`: once it ends the box-shadow has to fall back to
   whatever .is-unread / :hover want, not stay stuck on the halo's last frame. */
.task-card.just-arrived { animation: arrive 1.8s ease-out, cardIn .45s var(--ease) backwards; }
.foot-actions { display: flex; align-items: center; gap: 12px; }
.alarm-tags {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: var(--stack-sm);
}
.alarm-mark.incoming { background: linear-gradient(135deg, #7c5cff, #3aa0ff); }
/* The new-task popup has no exit but Read, so it says so. */
.must-read {
    margin-top: var(--stack-md);
    padding-top: var(--stack-sm);
    border-top: 1px solid var(--outline-variant);
}
/* With the close button gone the heading is the only child left. */
#incomingModal .modal-head { justify-content: center; }
.group-head.sub { margin-top: var(--stack-md); color: var(--secondary); text-transform: none; }
.stat.warn .stat-num { color: var(--u-overdue); }
.chip.ok { background: rgba(0, 168, 150, .16); color: var(--primary); }

.stat-row {
    display: flex;
    gap: var(--stack-md);
    margin-bottom: var(--stack-lg);
    flex-wrap: wrap;
}
.stat {
    flex: 1 1 120px;
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    padding: var(--stack-md);
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: cardIn .45s var(--ease) backwards;
}
.stat-num { font-size: 28px; line-height: 34px; font-weight: 700; color: var(--primary); }
.stat.ok .stat-num { color: var(--accent-mint); }

.admin-actions { display: flex; align-items: center; gap: 8px; align-self: center; flex-wrap: wrap; }
.select-sm { padding: 6px 8px; font-size: 12px; width: auto; min-width: 104px; }

.legend {
    margin-top: var(--stack-lg);
    padding: var(--stack-md);
    border-radius: var(--radius-lg);
    background: var(--surface-container-low);
    border: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notice {
    display: flex;
    gap: 12px;
    padding: var(--stack-md);
    border-radius: var(--radius-lg);
    background: var(--surface-container-low);
    color: var(--secondary);
}
.notice .icon { color: var(--u-none); flex-shrink: 0; }

/* Account panel */
.panel {
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: cardIn .45s var(--ease) backwards;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: var(--stack-md);
    padding: var(--container-padding);
    border-bottom: 1px solid var(--outline-variant);
    background: linear-gradient(120deg, rgba(0, 168, 150, .09), rgba(124, 92, 255, .06));
}
.panel-form {
    padding: var(--container-padding);
    display: flex;
    flex-direction: column;
    gap: var(--stack-md);
    max-width: 380px;
}
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }

/* Sidebar account block */
.account { text-decoration: none; border-radius: var(--radius-lg); transition: background-color .15s; }
.account:hover { background: var(--surface-container-low); }
.account-block { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.logout-form { padding: var(--stack-sm) var(--container-padding) 0; display: block; }

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23565e74'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 18px;
    padding-right: 30px;
}

/* Flash messages --------------------------------------------------------- */
.flashes {
    position: fixed;
    right: var(--stack-md);
    bottom: var(--stack-md);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: var(--stack-sm);
    max-width: 360px;
}
.flash {
    display: flex;
    align-items: center;
    gap: var(--stack-sm);
    padding: 12px var(--stack-md);
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    border-left: 4px solid var(--primary-bright);
    background: var(--surface-container-lowest);
    box-shadow: 0 8px 24px rgba(11, 28, 48, .16);
    animation: slideUp .35s var(--ease) both;
    font-weight: 500;
}
.flash.success { color: var(--primary); }
.flash.error {
    border-left-color: var(--error);
    background: #fff5f5;
    color: var(--error);
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s var(--ease);
        box-shadow: 0 0 40px rgba(0, 0, 0, .2);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .scrim { display: block; }

    .scrim {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(11, 28, 48, .45);
        backdrop-filter: blur(2px);
        z-index: 35;
        animation: fadeIn .25s ease both;
    }

    .topbar { left: 0; }
    .topbar-brand { display: flex; }
    .menu-btn { display: inline-flex; }
    .app-main { margin-left: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
    .page-head { flex-direction: column; align-items: flex-start; }
    .task-card .task-actions { opacity: 1; transform: none; }
    .t-display { font-size: 28px; line-height: 36px; }
    .flashes { left: var(--stack-md); right: var(--stack-md); max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---- Completion note ------------------------------------------------ */

/* The note the assignee left when they finished. Indented under the task and
   quoted, so it reads as their words rather than part of the task itself. */
.note-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent-sky);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(58, 160, 255, .08);
  color: var(--on-surface);
  word-wrap: break-word;
}

.note-line .icon { color: var(--accent-sky); flex-shrink: 0; margin-top: 2px; }

.note-card .note-task { color: var(--on-surface); }

/* ---- Assignee role, and a group heading with an action on the right - */

.who-role {
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, .06);
  font-size: 10px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.group-head.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
