/* ---------------------------------------------------------------------------
   Terminator — Task Defense System
   A dark, chrome-and-red HUD aesthetic with calm, readable task cards.
--------------------------------------------------------------------------- */

:root {
    --bg: #0a0c0e;
    --bg-raised: #111519;
    --panel: #151a1f;
    --panel-2: #1a2026;
    --panel-3: #20272e;
    --line: #2b343c;
    --line-bright: #3c4852;
    --text: #eceae4;
    --text-dim: #b3bcc4;
    --muted: #85909a;
    --red: #e63329;
    --red-bright: #ff5a4f;
    --red-deep: #8f1712;
    --amber: #eaa63c;
    --green: #58d68d;
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    --shadow-panel: 0 18px 40px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
    --radius: 12px;
}

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

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(1200px 700px at 12% -10%, rgba(230, 51, 41, 0.13), transparent 60%),
        radial-gradient(900px 600px at 110% 10%, rgba(90, 120, 140, 0.09), transparent 55%),
        linear-gradient(180deg, #0c0f12 0%, var(--bg) 45%, #08090b 100%);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

.scanlines {
    position: fixed;
    inset: 0;
    z-index: 900;
    pointer-events: none;
    background: repeating-linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.028) 0px,
        rgba(255, 255, 255, 0.028) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.5;
    animation: scan-drift 12s linear infinite;
}

@keyframes scan-drift {
    from { background-position-y: 0; }
    to { background-position-y: 120px; }
}

a {
    color: var(--red-bright);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

h1, h2, h3, p, dl, dd {
    margin: 0;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--red-bright);
}

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--line-bright);
    background: var(--panel-3);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease,
        box-shadow 0.15s ease;
}

.btn:hover {
    background: #28313a;
    border-color: #4b5a66;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.context-menu button:focus-visible,
.awaiting-toggle:focus-visible,
.bucket-grip:focus-visible {
    outline: 2px solid var(--red-bright);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(180deg, #f04a3f 0%, #cf2a20 60%, #b41f16 100%);
    border-color: #ff7065;
    color: #fff8f7;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 8px 18px rgba(230, 51, 41, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #ff5c50 0%, #e2342a 60%, #c5271d 100%);
    border-color: #ff8b82;
}

.btn-danger {
    background: linear-gradient(180deg, #6d1713, #4a0f0c);
    border-color: #a02a22;
    color: #ffd7d3;
}

.btn-danger:hover {
    background: linear-gradient(180deg, #87201a, #5d130f);
    border-color: var(--red-bright);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.035);
    border-color: var(--line);
    color: var(--text-dim);
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    padding: 8px 10px;
}

.btn-quiet:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--line);
    color: var(--text);
}

.btn-block {
    width: 100%;
    padding: 11px 16px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--line);
}

/* ---------------------------------------------------------------------------
   Top bar
--------------------------------------------------------------------------- */

.board-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 12px 22px;
    background: linear-gradient(180deg, rgba(18, 22, 26, 0.97), rgba(12, 15, 18, 0.94));
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    flex: 0 0 auto;
}

.topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(230, 51, 41, 0.7) 18%, rgba(230, 51, 41, 0.18) 55%, transparent);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-eye {
    display: inline-flex;
    width: 44px;
    height: 30px;
    filter: drop-shadow(0 0 8px rgba(230, 51, 41, 0.55));
}

.brand-eye svg {
    width: 100%;
    height: 100%;
}

.eye-socket {
    fill: #210b0b;
    stroke: var(--red);
    stroke-width: 1.5;
}

.eye-iris {
    fill: var(--red);
    animation: iris-pulse 4.5s ease-in-out infinite;
}

.eye-pupil {
    fill: #120506;
}

.eye-glint {
    fill: #ffd9d4;
}

@keyframes iris-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.72; }
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-text strong {
    font-size: 17px;
    letter-spacing: 0.16em;
    font-weight: 800;
}

.brand-text small {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 3px;
}

.hud {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 6px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.28);
    margin-left: 4px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
    min-width: 44px;
}

.hud-label {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.hud-value {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-top: 3px;
}

.hud-item--alert .hud-value {
    color: var(--amber);
}

.hud-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.14em;
    color: var(--green);
    border-left: 1px solid var(--line);
    padding-left: 16px;
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(88, 214, 141, 0.8);
    animation: status-pulse 2.4s ease-in-out infinite;
    flex: 0 0 auto;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
}

.upload-form {
    margin: 0;
}

.upload-label {
    cursor: pointer;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    max-width: 170px;
}

.user-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(180deg, #343d45, #20272d);
    border: 1px solid var(--line-bright);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    flex: 0 0 auto;
}

.user-name {
    font-size: 12px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-form {
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Board layout
--------------------------------------------------------------------------- */

.board-shell {
    position: relative;
    z-index: 10;
    flex: 1 1 auto;
    min-height: 0;
}

.noscript {
    margin: 14px 22px 0;
    padding: 10px 14px;
    border: 1px solid rgba(234, 166, 60, 0.4);
    border-radius: 8px;
    background: rgba(234, 166, 60, 0.08);
    color: #f0c37e;
    font-size: 12px;
}

.board {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    height: 100%;
    padding: 20px 22px 28px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-color: #39434c transparent;
    scrollbar-width: thin;
}

.board::-webkit-scrollbar {
    height: 10px;
}

.board::-webkit-scrollbar-thumb {
    background: #39434c;
    border-radius: 8px;
}

.board-empty {
    align-self: center;
    margin: auto;
    max-width: 460px;
    padding: 34px 38px 38px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(26, 32, 38, 0.92), rgba(15, 18, 22, 0.92));
    box-shadow: var(--shadow-panel);
}

.board-empty[hidden] {
    display: none;
}

.board-empty-eye {
    width: 76px;
    margin: 0 auto 16px;
    filter: drop-shadow(0 0 16px rgba(230, 51, 41, 0.4));
}

.board-empty-eye svg {
    width: 100%;
    height: auto;
}

.board-empty h1 {
    font-size: 24px;
    letter-spacing: -0.01em;
    margin: 6px 0 8px;
}

.board-empty p:not(.eyebrow) {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.bucket-ghost {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 160px;
    height: 118px;
    border: 1px dashed var(--line-bright);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.015);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.bucket-ghost:hover {
    border-color: var(--red);
    color: var(--red-bright);
    background: rgba(230, 51, 41, 0.06);
}

.bucket-ghost[hidden] {
    display: none;
}

/* ---------------------------------------------------------------------------
   Bucket columns
--------------------------------------------------------------------------- */

.bucket {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 0 0 320px;
    width: 320px;
    max-height: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(29, 35, 41, 0.96) 0%, rgba(18, 22, 26, 0.98) 100%);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
}

.bucket::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--red), rgba(230, 51, 41, 0.12) 55%, transparent);
    z-index: 2;
}

.bucket.dragging {
    opacity: 0.5;
    transform: scale(0.99);
    border-color: var(--red);
}

.bucket-header {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 13px 11px 10px 8px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent);
    flex: 0 0 auto;
}

.bucket-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 26px;
    padding: 0;
    margin-top: 1px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: #5c6873;
    cursor: grab;
    flex: 0 0 auto;
}

.bucket-grip:active {
    cursor: grabbing;
}

.bucket-grip:hover {
    color: var(--red-bright);
    background: rgba(230, 51, 41, 0.08);
}

.bucket-grip svg {
    width: 12px;
    height: 20px;
    fill: currentColor;
}

.bucket-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.015em;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
    padding-top: 2px;
}

.bucket-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    margin-top: 2px;
    border-radius: 999px;
    background: rgba(230, 51, 41, 0.12);
    border: 1px solid rgba(230, 51, 41, 0.3);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--red-bright);
    flex: 0 0 auto;
}

.bucket-menu-btn {
    margin-top: -1px;
    flex: 0 0 auto;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    min-height: 62px;
    flex: 0 1 auto;
    overflow-y: auto;
    scrollbar-color: #39434c transparent;
    scrollbar-width: thin;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.task-list::-webkit-scrollbar {
    width: 8px;
}

.task-list::-webkit-scrollbar-thumb {
    background: #39434c;
    border-radius: 8px;
}

.task-list.drop-target {
    background: rgba(230, 51, 41, 0.055);
    box-shadow: inset 0 0 0 1px rgba(230, 51, 41, 0.35);
    border-radius: 8px;
}

.task-list:has(.task-card) .empty-hint {
    display: none;
}

.empty-hint {
    padding: 14px 10px;
    text-align: center;
    font-size: 11px;
    line-height: 1.5;
    color: #66727c;
    border: 1px dashed rgba(255, 255, 255, 0.07);
    border-radius: 8px;
}

.empty-hint[hidden] {
    display: none;
}

.add-task-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 10px 8px;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.add-task-btn:hover {
    color: var(--red-bright);
    background: rgba(230, 51, 41, 0.07);
    border-color: rgba(230, 51, 41, 0.24);
}

/* Awaiting input area */

.awaiting {
    flex: 0 0 auto;
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22);
}

.awaiting-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.awaiting-toggle:hover {
    background: rgba(234, 166, 60, 0.07);
    color: var(--amber);
}

.awaiting-toggle.drop-target {
    background: rgba(234, 166, 60, 0.12);
    box-shadow: inset 0 0 0 1px rgba(234, 166, 60, 0.4);
}

.awaiting-chevron {
    display: inline-block;
    font-size: 12px;
    color: var(--amber);
    transition: transform 0.2s ease;
    transform-origin: 50% 50%;
}

.is-awaiting-open .awaiting-chevron {
    transform: rotate(90deg);
}

.awaiting-label {
    flex: 1 1 auto;
}

.awaiting-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(234, 166, 60, 0.13);
    border: 1px solid rgba(234, 166, 60, 0.3);
    color: var(--amber);
    font-size: 9px;
}

.awaiting-body {
    padding: 0 0 8px;
    max-height: 34vh;
    overflow-y: auto;
}

.awaiting-body[hidden] {
    display: none;
}

.awaiting-list {
    padding-top: 2px;
    min-height: 54px;
    overflow: visible;
}

/* ---------------------------------------------------------------------------
   Task cards
--------------------------------------------------------------------------- */

.task-card {
    position: relative;
    padding: 10px 10px 10px 12px;
    border: 1px solid var(--line);
    border-left: 2px solid #47535d;
    border-radius: 8px;
    background: linear-gradient(180deg, #212830 0%, #1a2026 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: grab;
    transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.task-card:hover {
    border-color: #4a5762;
    border-left-color: var(--red);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
}

.task-card:active {
    cursor: grabbing;
}

.task-card.dragging {
    opacity: 0.4;
    transform: rotate(1deg) scale(1.01);
    border-color: var(--red);
}

.task-card--awaiting {
    border-left-color: var(--amber);
    background: linear-gradient(180deg, #23211c 0%, #1a1a18 100%);
}

.task-card--awaiting:hover {
    border-left-color: var(--amber);
}

.task-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    min-height: 20px;
}

.task-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.5;
    color: var(--text-dim);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chip-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.chip--case {
    border-color: #3a4650;
    color: #cfd7dd;
}

.chip--due {
    border-color: rgba(234, 166, 60, 0.35);
    color: #f0c37e;
}

.chip--due .chip-label {
    color: rgba(234, 166, 60, 0.75);
}

.chip--overdue {
    border-color: rgba(230, 51, 41, 0.5);
    background: rgba(230, 51, 41, 0.1);
    color: #ff9c94;
}

.chip--overdue .chip-label {
    color: var(--red-bright);
}

.task-menu-btn {
    width: 22px;
    height: 20px;
    margin: -2px -3px 0 0;
    font-size: 16px;
    flex: 0 0 auto;
}

.task-description {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-meta {
    display: grid;
    gap: 4px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.task-meta div {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 7px;
    align-items: baseline;
}

.task-meta dt {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: #6f7b85;
}

.task-meta dd {
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--text-dim);
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ---------------------------------------------------------------------------
   Context menus
--------------------------------------------------------------------------- */

.context-menu {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-width: 168px;
    padding: 5px;
    border: 1px solid var(--line-bright);
    border-radius: 9px;
    background: linear-gradient(180deg, #222a31, #161b20);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.context-menu[hidden] {
    display: none;
}

.context-menu button {
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
}

.context-menu button:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
}

.context-menu button.danger {
    color: #ff8a82;
}

.context-menu button.danger:hover {
    background: rgba(230, 51, 41, 0.14);
    color: #ffb3ad;
}

/* ---------------------------------------------------------------------------
   Dialogs
--------------------------------------------------------------------------- */

.modal {
    width: min(680px, calc(100vw - 28px));
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 1px solid var(--line-bright);
    border-radius: 14px;
    background: linear-gradient(180deg, #1c2228 0%, #12161a 100%);
    color: var(--text);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(230, 51, 41, 0.18);
    overflow: auto;
}

.modal::backdrop {
    background: rgba(4, 6, 8, 0.74);
    backdrop-filter: blur(4px);
}

.modal--small {
    width: min(440px, calc(100vw - 28px));
}

.modal-form {
    padding: 20px 22px 22px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    font-size: 19px;
    letter-spacing: -0.01em;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.modal-header .icon-btn {
    font-size: 22px;
    margin-top: -3px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-wide {
    grid-column: 1 / -1;
}

.field > span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.field > span em {
    font-style: normal;
    color: var(--red-bright);
    font-size: 8.5px;
    letter-spacing: 0.1em;
}

.field input,
.field textarea,
.auth-form input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line-bright);
    border-radius: 7px;
    background: #0e1216;
    color: var(--text);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
    resize: vertical;
    min-height: 92px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.field input::placeholder,
.field textarea::placeholder,
.auth-form input::placeholder {
    color: #5d6872;
}

.field input:focus,
.field textarea:focus,
.auth-form input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(230, 51, 41, 0.15);
}

.field input[type="date"] {
    color-scheme: dark;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.field-help {
    font-size: 10.5px;
    line-height: 1.45;
    color: #6f7b85;
}

.field-help ul {
    margin: 3px 0 0;
    padding-left: 16px;
}

.field-error {
    font-style: normal;
    font-size: 11px;
    color: #ff8a82;
}

.form-error {
    margin-top: 12px;
    padding: 8px 10px;
    border: 1px solid rgba(230, 51, 41, 0.4);
    border-radius: 7px;
    background: rgba(230, 51, 41, 0.1);
    color: #ffb3ad;
    font-size: 12px;
}

.form-error[hidden] {
    display: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.confirm-message {
    color: var(--text-dim);
    font-size: 13.5px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   Toasts
--------------------------------------------------------------------------- */

.toast-region {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--line-bright);
    border-left: 3px solid var(--text-dim);
    border-radius: 9px;
    background: linear-gradient(180deg, #232b32, #171c21);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.45;
    pointer-events: auto;
    animation: toast-in 0.22s ease-out;
}

.toast--success { border-left-color: var(--green); }
.toast--error { border-left-color: var(--red); }
.toast--warning { border-left-color: var(--amber); }
.toast--info { border-left-color: #6aa7d8; }

.toast-text {
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.toast-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 17px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    flex: 0 0 auto;
}

.toast-close:hover {
    color: var(--text);
}

.toast.leaving {
    animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(6px); }
}

/* ---------------------------------------------------------------------------
   Auth screens
--------------------------------------------------------------------------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 28px 16px;
    overflow-y: auto;
}

.auth-shell {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    justify-content: center;
}

.auth-card {
    position: relative;
    width: min(440px, 100%);
    padding: 30px 32px 24px;
    border: 1px solid var(--line-bright);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(29, 35, 41, 0.97), rgba(13, 16, 20, 0.98));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 60px rgba(230, 51, 41, 0.08);
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--red), transparent);
}

.auth-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(230, 51, 41, 0.03) 50%, transparent 100%);
    pointer-events: none;
    animation: auth-sweep 7s ease-in-out infinite;
}

@keyframes auth-sweep {
    0%, 100% { transform: translateY(-40%); opacity: 0.35; }
    50% { transform: translateY(40%); opacity: 0.8; }
}

.auth-eye {
    width: 66px;
    margin: 0 auto 12px;
    filter: drop-shadow(0 0 14px rgba(230, 51, 41, 0.55));
}

.auth-eye svg {
    width: 100%;
    height: auto;
}

.boot-line {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: 0.16em;
    color: var(--muted);
    margin-bottom: 8px;
}

.auth-title {
    text-align: center;
    font-size: 27px;
    font-weight: 800;
    letter-spacing: 0.2em;
    margin-bottom: 5px;
}

.auth-tagline {
    text-align: center;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 22px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.auth-form .btn {
    margin-top: 4px;
}

.auth-alt {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.auth-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 20px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.cursor {
    color: var(--red-bright);
    animation: blink 1.1s steps(2, start) infinite;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.alert {
    padding: 9px 11px;
    border: 1px solid var(--line-bright);
    border-left: 3px solid var(--text-dim);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.24);
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.45;
    margin-bottom: 14px;
}

.alert p + p {
    margin-top: 4px;
}

.alert--error {
    border-left-color: var(--red);
    background: rgba(230, 51, 41, 0.09);
    color: #ffb3ad;
}

.alert--success { border-left-color: var(--green); }
.alert--warning { border-left-color: var(--amber); }

.auth-messages {
    margin-bottom: 4px;
}

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */

@media (max-width: 1080px) {
    .topbar {
        gap: 14px;
        padding: 10px 16px;
        flex-wrap: wrap;
    }

    .hud {
        order: 3;
        width: 100%;
        justify-content: space-between;
        padding: 6px 12px;
    }

    .hud-status {
        padding-left: 12px;
    }

    .topbar-actions {
        margin-left: auto;
    }
}

@media (max-width: 760px) {
    .board-page {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .board-shell {
        overflow: visible;
    }

    .board {
        height: auto;
        min-height: calc(100vh - 120px);
        padding: 14px;
        align-items: flex-start;
    }

    .bucket {
        flex: 0 0 86vw;
        width: 86vw;
        max-height: none;
    }

    .task-list {
        max-height: none;
    }

    .awaiting-body {
        max-height: none;
    }

    .brand-text small,
    .user-name,
    .hud-status {
        display: none;
    }

    .field-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .toast-region {
        right: 12px;
        bottom: 12px;
    }

    .auth-card {
        padding: 24px 20px 20px;
    }
}

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