:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f8fafc; --line: #e5e7eb; --line-2: #d1d5db;
  --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8; --accent: #2563eb; --accent-ink: #fff;
  --danger: #dc2626; --ok: #16a34a; --warn: #d97706; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.06);
  --r: 10px; --r-sm: 7px;
  --s-todo: #64748b; --s-in_progress: #2563eb; --s-review: #d97706; --s-approved: #7c3aed; --s-done: #16a34a; --s-blocked: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --panel: #121829; --panel-2: #0f1524; --line: #232b40; --line-2: #2f3952;
    --ink: #e5e9f2; --ink-2: #a3adc2; --ink-3: #6b7690; --accent: #3b82f6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 40px; color: var(--ink-3); }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 12px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
a.btn { color: inherit; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--panel); outline: none; }
textarea.input { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.input { min-width: 0; max-width: 100%; }
label.field { min-width: 0; display: grid; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 500; }

/* sign in */
.auth { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.auth-card h1 { margin: 0; font-size: 20px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand img { width: 26px; height: 26px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .grow { flex: 1; }
.top select.input { width: auto; min-width: 170px; }
.top .search { width: 220px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; position: relative; }
.avatar.bot::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 3px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chip.due.late { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.chip.pri-high { color: var(--warn); }
.chip.pri-urgent { color: var(--danger); font-weight: 600; }

/* board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; padding: 14px 16px 30px; overflow-x: auto; align-items: start; min-height: calc(100vh - 60px); }
.col { background: color-mix(in srgb, var(--panel-2) 70%, var(--bg)); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; max-height: calc(100vh - 90px); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.col-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-head .count { color: var(--ink-3); font-weight: 500; }
.col-head .btn { margin-left: auto; }
.col-body { padding: 0 8px 10px; overflow-y: auto; display: grid; gap: 8px; min-height: 60px; align-content: start; }
.col.drop .col-body { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--r-sm); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 11px; cursor: pointer; display: grid; gap: 7px; box-shadow: 0 1px 1px rgba(15,23,42,.03); }
.card:hover { border-color: var(--line-2); }
.card.dragging { opacity: .4; }
.card .t { font-weight: 550; word-break: break-word; }
.card .meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.card .meta .avatar { margin-left: auto; }
.card .num { color: var(--ink-3); font-size: 12px; }
.card .thumbs { display: flex; gap: 4px; }
.card .thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.empty { color: var(--ink-3); font-size: 13px; padding: 6px 4px; }
.quick-add { display: grid; gap: 6px; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.38); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(780px, 100%); background: var(--panel); z-index: 41; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(15,23,42,.18); }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .num { color: var(--ink-3); font-weight: 600; }
.drawer-head .grow { flex: 1; }
.drawer-body { overflow-y: auto; overflow-x: hidden; padding: 16px 18px 40px; display: grid; gap: 22px; align-content: start; grid-template-columns: minmax(0, 1fr); }
.drawer-body > * { min-width: 0; }
.title-input { width: 100%; font-size: 20px; font-weight: 650; border: 1px solid transparent; border-radius: var(--r-sm); padding: 4px 6px; margin-left: -7px; background: transparent; outline: none; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); }
.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.section h3 .btn { text-transform: none; letter-spacing: 0; }
.section h3 .btn:first-of-type { margin-left: auto; }
.section h3 { flex-wrap: wrap; }
.md { line-height: 1.6; word-break: break-word; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md img { max-width: 100%; }
.md pre { background: var(--panel-2); padding: 10px; border-radius: var(--r-sm); overflow-x: auto; }
.md code { background: var(--panel-2); padding: 1px 4px; border-radius: 4px; font-size: 13px; }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.desc-view { border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 8px; margin: -6px -8px; cursor: text; min-height: 40px; }
.desc-view:hover { border-color: var(--line); }

/* files */
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 16px; text-align: center; color: var(--ink-2); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); color: var(--ink); }
.dropzone strong { color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 10px; }
.tile { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel-2); aspect-ratio: 1; cursor: zoom-in; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .x, .filerow .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 6px; border: 0; background: rgba(15,23,42,.65); color: #fff; cursor: pointer; display: none; place-items: center; }
.tile:hover .x { display: grid; }
.filelist { display: grid; gap: 6px; margin-top: 10px; }
.filerow { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }
.filerow .ext { width: 38px; height: 38px; border-radius: 7px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: #64748b; text-transform: uppercase; flex: none; }
.filerow .ext.pdf { background: #dc2626; } .filerow .ext.md, .filerow .ext.txt { background: #0f766e; } .filerow .ext.csv, .filerow .ext.xlsx { background: #15803d; } .filerow .ext.docx { background: #1d4ed8; } .filerow .ext.mp4, .filerow .ext.mov { background: #7c3aed; }
.filerow .info { flex: 1; min-width: 0; }
.filerow .info b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .x { position: static; display: grid; background: transparent; color: var(--ink-3); }
.filerow .x:hover { color: var(--danger); }
.uploading { display: grid; gap: 6px; margin-top: 10px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* comments */
.comments { display: grid; gap: 14px; }
.comment { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.comment .avatar { width: 28px; height: 28px; }
.comment .who { font-weight: 600; } .comment .who .faint { font-weight: 400; margin-left: 6px; }
.comment .bubble { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; margin-top: 4px; }
.comment .gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.composer { display: grid; gap: 8px; }
.composer .row { display: flex; gap: 8px; align-items: center; }
.composer .row .grow { flex: 1; }
.activity { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }

/* lightbox & modal */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(2,6,23,.92); display: grid; grid-template-rows: auto 1fr auto; color: #fff; }
.lightbox .bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.lightbox .bar .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox .bar a, .lightbox .bar button { color: #fff; background: rgba(255,255,255,.1); border: 0; border-radius: 7px; height: 32px; padding: 0 12px; display: inline-flex; align-items: center; cursor: pointer; text-decoration: none; }
.lightbox .stage { display: grid; place-items: center; min-height: 0; padding: 0 56px; position: relative; }
.lightbox .stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 20px; cursor: pointer; }
.lightbox .nav.prev { left: 8px; } .lightbox .nav.next { right: 8px; }
.lightbox .strip { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; justify-content: center; }
.lightbox .strip img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; opacity: .5; cursor: pointer; border: 2px solid transparent; }
.lightbox .strip img.on { opacity: 1; border-color: #fff; }
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px; overflow: auto; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.modal-body > *, .tokenbox code, .field { min-width: 0; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
pre.plain { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.tokenbox { display: flex; gap: 8px; }
.tokenbox code { flex: 1; padding: 9px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; word-break: break-all; }
.note { padding: 10px 12px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 13px; }

/* settings */
.page { max-width: 920px; margin: 0 auto; padding: 22px 16px 60px; display: grid; gap: 22px; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; }
.card-box h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.card-box h2 .btn { margin-left: auto; }
.rows { display: grid; }
.rowi { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.rowi:first-child { border-top: 0; }
.rowi .grow { flex: 1; min-width: 0; }
.rowi .grow b { font-weight: 600; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.code-block { position: relative; }
.code-block pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; overflow-x: auto; margin: 0; font: 12.5px/1.5 ui-monospace, Menlo, monospace; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 9px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  .top { padding: 8px 10px; }
  .top .search { width: 100%; order: 10; }
  .top select.input { min-width: 0; flex: 1 1 40%; order: 9; }
  .top .grow { display: none; }
  .top .brand { margin-right: auto; }
  .props { grid-template-columns: 1fr 1fr; }
  .drawer-head .btn.sm { padding: 0 6px; }
  .board { grid-auto-columns: 84vw; padding: 10px; }
  .drawer-body { padding: 14px 12px 40px; }
  .hide-sm { display: none; }
}
