/* Purple ToDos — design system.
   Mirrors the shared Purple house tokens (crossreview / SSO / blog): white
   surfaces, purple-tinted shadows, URW Gothic, square corners, thin headings. */

@font-face {
    font-family: "URW Gothic";
    src: url("/static/fonts/URWGothic-Book.otf") format("opentype");
    font-weight: 100 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "URW Gothic";
    src: url("/static/fonts/URWGothic-Demi.otf") format("opentype");
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --purple:            #422186;
    --purple-dark:       #33004c;
    --purple-light:      rgb(177, 156, 189);
    --ink-button:        #370054;
    --bg-light:          #f5f6fa;
    --bg-white:          #ffffff;
    --text-primary:      #333333;
    --text-muted:        #666666;
    --text-on-purple:    #ffffff;
    --border:            #e0e0e0;
    --red:               #c0392b;
    --green:             #1f9d8f;
    --amber:             #d1791f;

    --border-radius:     0;
    --sidebar-width:     280px;
    --panel-width:       360px;

    --font-brand:        "URW Gothic", Tahoma, sans-serif;
    --font-body:         Tahoma, Arial, sans-serif;
    --font-mono:         "Courier New", Courier, monospace;

    --shadow-panel:      0 6px 20px rgba(51, 0, 76, 0.08);
    --shadow-card:       0 3px 4px rgba(51, 0, 76, 0.08);
    --hover-tint:        rgba(107, 33, 168, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: linear-gradient(to top, var(--bg-light), var(--bg-white));
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-brand);
    font-weight: 100;
    color: var(--purple-dark);
    line-height: 1.25;
    margin: 0;
}

a { color: var(--purple); }

:focus-visible {
    outline: 3px solid var(--purple-light);
    outline-offset: 2px;
}

/* ---- App shell ---------------------------------------------------------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh; height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px 20px;
    background: var(--bg-white);
    box-shadow: var(--shadow-panel);
    z-index: 5;
    overflow-y: auto;
}

.sidebar__brand {
    font-family: var(--font-brand);
    font-size: 24px;
    font-weight: 100;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.brand__mark {
    width: 28px; height: 28px;
    background: var(--purple);
    border-radius: 50%;
    display: inline-block;
}
.brand__purple { color: var(--purple-dark); font-weight: 600; }
.brand__clear  { color: var(--purple);      font-weight: 600; }
.brand__product { color: var(--purple-dark); font-weight: 400; margin-left: 4px; }

.sidebar__section { display: flex; flex-direction: column; gap: 10px; }
.sidebar__heading {
    font-family: var(--font-brand);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 20px 28px 48px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.board-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-title {
    font-family: var(--font-brand);
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 100;
    color: var(--purple-dark);
    margin: 0;
    cursor: text;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.board-title-input {
    font-family: var(--font-brand);
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 100;
    color: var(--purple-dark);
    border: 1px solid var(--border);
    background: var(--bg-white);
    padding: 2px 8px;
}
.topbar__spacer { flex: 1 1 auto; }

/* ---- Presence (viewer circles) ----------------------------------------- */
.presence { display: flex; align-items: center; }
.presence .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg-white); }
.presence .avatar:first-child { margin-left: 0; }

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-brand);
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    background: var(--purple);
    user-select: none;
    flex: 0 0 auto;
}
.avatar--sm { width: 26px; height: 26px; font-size: 12px; }
.avatar--lg { width: 64px; height: 64px; font-size: 26px; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 0;
    border-radius: var(--border-radius);
    font-family: var(--font-brand);
    font-size: 14px;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: opacity .15s, background .15s;
    text-decoration: none;
}
.btn:hover:not(:disabled) { opacity: 0.9; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary   { background: var(--ink-button); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--purple); opacity: 1; }
.btn--secondary { background: var(--bg-light); color: var(--text-primary); }
.btn--danger    { background: var(--red); color: #fff; }
.btn--ai        { background: var(--purple); color: #fff; }
.btn--sm        { padding: 5px 10px; font-size: 12px; }
.btn--block     { width: 100%; }

.icon-button {
    width: 30px; height: 30px;
    border: 0; padding: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px; line-height: 1;
    cursor: pointer;
}
.icon-button:hover { color: var(--purple); }

/* ---- Forms -------------------------------------------------------------- */
input[type="text"], input[type="search"], input[type="date"],
input[type="email"], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-white);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--purple);
    outline: none;
}
textarea { resize: vertical; min-height: 90px; }
label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }

/* ---- Board -------------------------------------------------------------- */
.board {
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    gap: 18px;
    align-items: start;
}
.column {
    background: var(--bg-white);
    border-left: 5px solid var(--purple);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    min-height: 160px;
    max-height: calc(100vh - 190px);
}
.column__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.column__title {
    font-family: var(--font-brand);
    font-size: 16px;
    font-weight: 600;
    color: var(--purple-dark);
}
.column__count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-light);
    padding: 1px 8px;
    border-radius: 10px;
}
.column__list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 40px;
}
.column__list.drag-over { background: var(--hover-tint); }
.column__footer { padding: 10px 12px; border-top: 1px solid var(--border); }
.column__footer input { font-size: 14px; }

/* ---- Card --------------------------------------------------------------- */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-left: 3px solid var(--purple);
    box-shadow: var(--shadow-card);
    padding: 10px 12px;
    cursor: grab;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.5; }
.card.drop-target { border-top: 3px solid var(--purple); }
.card__title { font-size: 14px; color: var(--text-primary); word-break: break-word; }
.card__labels { display: flex; flex-wrap: wrap; gap: 4px; }
.card__meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.card__meta .avatar--sm { margin-left: auto; }
.card__priority { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.card__priority--high { color: var(--red); }
.card__priority--medium { color: var(--amber); }
.card__priority--low { color: var(--text-muted); }
.card__due { display: inline-flex; align-items: center; gap: 3px; }
.card__due--overdue { color: var(--red); font-weight: 600; }
.card__subcount { display: inline-flex; align-items: center; gap: 3px; }

/* ---- Label chips -------------------------------------------------------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-white);
    font-size: 12px;
    cursor: grab;
}
.chip__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot-color, var(--purple)); flex: 0 0 auto; }
.chip--mini { padding: 2px 6px; font-size: 11px; }
.chip__remove { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.chip__remove:hover { color: var(--red); }

/* ---- Detail panel (right side) ----------------------------------------- */
.detail-panel {
    position: fixed;
    top: 0; right: 0;
    width: min(var(--panel-width), 92vw);
    height: 100vh; height: 100dvh;
    background: var(--bg-white);
    box-shadow: var(--shadow-panel);
    transform: translateX(100%);
    transition: transform .2s ease;
    z-index: 20;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.detail-panel.open { transform: translateX(0); }
.detail-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-white);
}
.detail-panel__body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.detail-section__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.detail-labels { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; padding: 6px; border: 1px dashed var(--border); }
.detail-labels.drag-over { background: var(--hover-tint); border-color: var(--purple); }

.attachment-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.subtask-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.subtask-row input[type="checkbox"] { width: auto; }

/* ---- Modal (native dialog) --------------------------------------------- */
.modal {
    width: min(520px, calc(100vw - 32px));
    padding: 22px;
    border: 0;
    border-radius: var(--border-radius);
    background: var(--bg-white);
    color: var(--text-primary);
    box-shadow: var(--shadow-panel);
}
.modal::backdrop { background: rgba(26, 13, 46, 0.45); }
.modal__title { margin-bottom: 12px; font-size: 20px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---- Toolbar chips (filter / group) ------------------------------------ */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar__group { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

/* ---- Sidebar lists ------------------------------------------------------ */
.member-row, .label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 4px 2px;
}
.member-row .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.member-row .status-dot.online { background: var(--green); }
.label-row { justify-content: space-between; }
.label-row__left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.label-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Toasts ------------------------------------------------------------- */
.toast-stack {
    position: fixed;
    bottom: 18px; right: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 40;
    max-width: min(360px, 90vw);
}
.toast {
    background: var(--bg-white);
    border-left: 4px solid var(--purple);
    box-shadow: var(--shadow-panel);
    padding: 12px 14px;
    font-size: 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: toast-in .18s ease;
}
.toast__close { margin-left: auto; cursor: pointer; color: var(--text-muted); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Login -------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--bg-white);
    box-shadow: var(--shadow-panel);
    border-top: 5px solid var(--purple);
    padding: 36px 32px;
    width: min(400px, 92vw);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.login-card h1 { font-size: 30px; }
.login-card p { color: var(--text-muted); margin: 0; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--purple-light); border-top-color: var(--purple); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
    .sidebar { position: static; width: 100%; height: auto; }
    .main { margin-left: 0; }
    .board { grid-template-columns: 1fr; }
    .app { flex-direction: column; }
}

/* ---- Print (checklist) -------------------------------------------------- */
#printArea { display: none; }
.print-title { font-family: var(--font-brand); font-weight: 600; color: #000; margin-bottom: 4px; }
.print-code { font-family: var(--font-mono); font-size: 12px; color: #333; margin-bottom: 18px; }
.print-list { list-style: decimal; padding-left: 28px; }
.print-task { font-size: 15px; margin: 8px 0; line-height: 1.5; }
.print-box { font-size: 20px; margin-right: 8px; vertical-align: -1px; }
.print-hint { margin-top: 24px; font-size: 12px; color: #444; }

@media print {
    body { background: #fff; }
    .app, .toast-stack, .detail-panel, dialog.modal { display: none !important; }
    #printArea { display: block !important; padding: 8px 4px; color: #000; }
    .print-task { break-inside: avoid; }
}

/* ---- Offline import (PC modal + phone page) ----------------------------- */
.import-qr { text-align: center; margin: 12px 0; }
.import-qr img { border: 1px solid var(--border); }
.import-link { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); word-break: break-all; margin-top: 8px; }
.import-status { text-align: center; margin: 12px 0 4px; min-height: 20px; }

.mobile-import { max-width: 460px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.mi-card {
    background: var(--bg-white);
    box-shadow: var(--shadow-card);
    border-top: 4px solid var(--purple);
    padding: 22px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.mi-card h2 { font-size: 22px; }
.mi-card input[type="file"] { width: 100%; }
.mi-card .spinner { width: 26px; height: 26px; border-width: 3px; }

