/*
 * Meknum Tasks — mobile-first styles.
 * Base rules describe the phone layout. Wider layouts are layered on with min-width queries:
 *   520px  two-column forms          768px  top-bar navigation, tables, side drawer
 *   1024px roomier spacing
 */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #e1e4ee;
  --text: #1a2133;
  --muted: #667089;
  --accent: #4f46e5;
  --accent-text: #4338ca;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 18px 40px rgb(16 24 40 / 16%);
  --radius: 14px;
  --gutter: 16px;
  --nav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1117;
  --surface: #171b24;
  --surface-2: #202634;
  --border: #2b3242;
  --text: #e7eaf1;
  --muted: #939cb1;
  --accent: #6d67f0;
  --accent-text: #a5a9ff;
  --accent-soft: #232750;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-lg: 0 18px 40px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Armenian", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Lock the page behind an open task panel or dialog. */
html:has(#drawer .drawer), html:has(#modal .modal) { overflow: hidden; }

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.25; text-wrap: balance; }
h1 { font-size: 20px; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, summary, label, select, input { touch-action: manipulation; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; width: 100%; }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.danger-text { color: var(--danger); }
svg.i { width: 16px; height: 16px; flex: none; }
.spacer { flex: 1; }

/* ---------- controls (44px touch targets on phones) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; font-weight: 600; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.btn.block { width: 100%; min-height: 48px; }
.btn:active { transform: scale(.98); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted); text-decoration: none;
  width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; font-size: 16px; flex: none;
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.tiny { width: 32px; height: 32px; margin-left: auto; }

/* 16px text in fields stops iOS from zooming the page on focus. */
input[type=text], input[type=url], input[type=email], input[type=date], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; font-size: 16px;
}
select { padding-right: 28px; }
textarea { resize: vertical; min-height: 88px; }
select.compact { width: auto; min-height: 36px; padding: 4px 28px 4px 10px; font-size: 14px; }
:is(input, select, textarea, .btn, .icon-btn, .tab, .chip, .jump, summary, .card, .task-line, tr, .take-btn, .th-btn):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=color] { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; flex: none; }
input[type=range] { width: 100%; height: 32px; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 20px; height: 20px; flex: none; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
label.field > :is(input, select, textarea, span) { color: var(--text); font-weight: 400; }
label.field small { font-weight: 400; }
.two { display: grid; gap: 12px; }
.actions { display: flex; flex-direction: column-reverse; gap: 8px; margin-top: 6px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inline-form input:is([type=text], [type=url]) { flex: 1 1 160px; }
.inline-form .grow-2 { flex: 2 1 180px; }
.inline-form .btn { flex: 0 0 auto; }
[data-form="add-link"] input { flex-basis: 100% !important; }
[data-form="add-link"] .btn { flex: 1 1 auto; }
.pointer-only { display: none; }

/* ---------- auth screens ---------- */
.auth-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px var(--gutter) calc(20px + var(--safe-b)); }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px 18px; display: grid; gap: 14px; }
.auth-card form { display: grid; gap: 14px; margin-top: 4px; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 8px calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: -3px; }
.topbar .brand-text { display: none; }
.view-title { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* Phone: tabs are a bottom navigation bar. */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tab {
  flex: 1 1 0; min-width: 0; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tab svg.i { width: 22px; height: 22px; }
.tab.active { color: var(--accent-text); }
.tab.active svg.i { stroke-width: 2.4; }

/* Phone: "New task" is a floating action button above the navigation bar. */
.new-task-btn {
  position: fixed; z-index: 20; right: calc(var(--gutter) + var(--safe-r)); bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  width: 56px; height: 56px; min-height: 0; padding: 0; border-radius: 50%;
  box-shadow: 0 8px 20px rgb(79 70 229 / 40%);
}
.new-task-btn span { display: none; }
.new-task-btn svg.i { width: 24px; height: 24px; }

.me-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px; cursor: pointer; list-style: none; }
.me-btn .avatar { width: 32px; height: 32px; font-size: 12px; }
.me-name { display: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-btn::-webkit-details-marker, .menu summary::-webkit-details-marker { display: none; }

.main {
  padding: var(--gutter) calc(var(--gutter) + var(--safe-r)) calc(var(--nav-h) + var(--safe-b) + 88px) calc(var(--gutter) + var(--safe-l));
  max-width: 1640px; margin: 0 auto;
}

/* dropdown menus */
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; cursor: pointer; }
.menu-list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 240px; max-width: calc(100vw - 24px); text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: grid;
}
.menu.right .menu-list { left: auto; right: 0; }
.menu-list button { display: flex; align-items: center; gap: 10px; min-height: 44px; border: 0; background: transparent; text-align: left; padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.menu-list button.danger { color: var(--danger); }
.menu-info { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: grid; min-width: 0; }
.menu-info span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- avatars & badges ---------- */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center; flex: none; text-transform: uppercase;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.empty { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border); }
.take-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: 2px 12px 2px 8px; font-size: 13px; font-weight: 600; cursor: pointer; flex: none; }
.prio { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; flex: none; }
.prio-low { background: #e2e8f0; color: #475569; }
.prio-medium { background: #dbeafe; color: #1d4ed8; }
.prio-high { background: #ffedd5; color: #c2410c; }
.prio-urgent { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .prio-low { background: #273041; color: #a5b1c6; }
[data-theme="dark"] .prio-medium { background: #1e2c4f; color: #93b4ff; }
[data-theme="dark"] .prio-high { background: #3b2817; color: #fdba74; }
[data-theme="dark"] .prio-urgent { background: #3f1d1d; color: #fca5a5; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.off { color: var(--muted); }
.role { font-weight: 600; font-size: 14px; }
.role-owner { color: var(--accent-text); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.due { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; flex: none; }
.due svg.i { width: 14px; height: 14px; }
.due.overdue { color: var(--danger); font-weight: 600; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }
.bar.done > span { background: #16a34a; }
.count { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.counts { display: inline-flex; gap: 10px; color: var(--muted); font-size: 12px; }
.counts span { display: inline-flex; align-items: center; gap: 3px; }
.counts svg.i { width: 14px; height: 14px; }

/* horizontally scrolling strips (stats, filters, column jump bar) bleed to the screen edges */
.summary, .filter-row, .col-jump {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter);
}
:is(.summary, .filter-row, .col-jump)::-webkit-scrollbar { display: none; }

/* ---------- summary & filters ---------- */
.summary { margin-bottom: 14px; gap: 10px; scroll-snap-type: x proximity; }
.stat { flex: 0 0 142px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; align-content: start; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value.danger { color: var(--danger); }
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filter-row { align-items: center; }
.filter-row > * { flex: none; }
.filter-row select { width: auto; min-height: 40px; font-size: 14px; padding-block: 6px; border-radius: 999px; }
.chip { min-height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 16px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- board ---------- */
.col-jump { margin-bottom: 10px; }
.jump { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; }
.jump .n { color: var(--muted); font-weight: 500; }
.jump.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* Phone: one column per screen, swipe sideways between statuses. */
.board {
  display: flex; gap: 12px; align-items: flex-start;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1); padding: 0 var(--gutter) 12px; scroll-padding-inline: var(--gutter);
}
.board::-webkit-scrollbar { display: none; }
.column {
  flex: 0 0 min(86vw, 340px); scroll-snap-align: start; min-width: 0;
  background: var(--surface-2); border-radius: var(--radius); padding: 10px;
  border: 2px solid transparent; transition: border-color .15s, background .15s;
}
.column.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-weight: 700; }
.col-head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .count { background: var(--surface); }
.cards { display: grid; gap: 8px; min-height: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  box-shadow: var(--shadow); cursor: pointer; display: grid; gap: 8px; min-width: 0;
  transition: transform .12s, border-color .12s;
}
.card.mine { border-left: 3px solid var(--accent); }
.card.dragging { opacity: .45; }
.card:active { transform: scale(.985); }
.card h4 { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.card-top, .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; min-width: 0; }
.chips { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.quick-add { margin-top: 8px; }
.quick-add input { background: transparent; border-color: transparent; }
.quick-add input::placeholder { color: var(--muted); }
.quick-add input:focus { background: var(--surface); border-color: var(--border); }

/* ---------- list: cards on phones, table from 768px ---------- */
.list-sort { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; white-space: nowrap; }
.list-sort select { font-size: 15px; font-weight: 400; color: var(--text); }
.list-cards { display: grid; gap: 8px; }
.task-table { display: none; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table-wrap.flat { border: 0; border-radius: 0; background: transparent; overflow: visible; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); padding: 6px 14px; }
.th-btn { border: 0; background: transparent; color: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.th-btn.active { color: var(--text); }
td.title-cell { white-space: normal; min-width: 240px; font-weight: 500; }
tbody tr[data-action] { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive { opacity: .55; }
.assignee-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.progress-cell .bar { flex: 1; }

/* People table: stacked cards on phones. */
table.people, table.people tbody, table.people tr, table.people td { display: block; }
table.people thead { display: none; }
table.people tr { position: relative; padding: 14px 0; border-bottom: 1px solid var(--border); }
table.people tr:last-child { border-bottom: 0; }
table.people td { border: 0; padding: 3px 0; white-space: normal; text-align: left; overflow-wrap: anywhere; }
table.people td[data-label] { display: flex; align-items: center; gap: 10px; min-height: 30px; }
table.people td[data-label]::before { content: attr(data-label); flex: 0 0 84px; color: var(--muted); font-size: 12px; font-weight: 600; }
table.people td.p-name { padding-right: 48px; padding-bottom: 8px; }
table.people td.p-menu { position: absolute; top: 10px; right: 0; padding: 0; }
table.people td.p-menu:empty { display: none; }

/* ---------- panels, my work, team ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.panel h3 { font-size: 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.panel-head { display: grid; gap: 12px; margin-bottom: 8px; }
.panel-head h3 { margin-bottom: 2px; }
.panel-head .btn-row .btn { flex: 1 1 auto; }
.hello { margin-bottom: 14px; display: grid; gap: 4px; }
.two-col, .stack, .team-grid, .settings { display: grid; gap: 12px; min-width: 0; }
.two-col > *, .stack > *, .team-grid > *, .settings > * { min-width: 0; }
.team-grid { align-items: start; }
.member-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; min-width: 0; }
.member-head .who { min-width: 0; }
.member-head .who b { display: block; overflow-wrap: anywhere; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; text-align: center; }
.mini-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 2px; }
.mini-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 11px; color: var(--muted); }
.member-tasks { margin-top: 10px; }

/* Phone: title on its own line (up to two lines), details underneath. */
.task-line {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 4px; align-items: start;
  padding: 10px 8px; margin: 0 -8px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.task-line:last-of-type { border-bottom: 0; }
.task-line .dot { margin-top: 7px; }
.task-line .t { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-line .line-meta { grid-column: 2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.task-line .line-meta :is(.take-btn, .avatar, .pct) { margin-left: auto; }
.task-line .pct { font-variant-numeric: tabular-nums; }
.section-gap { margin-top: 12px; }
.feed { display: grid; gap: 14px; }
.feed-item { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; min-width: 0; }
.feed-item > div { min-width: 0; overflow-wrap: anywhere; }
.feed-item .when { color: var(--muted); font-size: 12px; }
.empty-state { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px 16px; text-align: center; display: grid; gap: 10px; justify-items: center; margin-bottom: 14px; }
.empty-state p { max-width: 52ch; }

/* ---------- settings ---------- */
.row { display: flex; align-items: center; gap: 8px; padding: 8px 0; min-width: 0; }
.row input[type=text] { flex: 1 1 0; }
.row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status-row { flex-wrap: wrap; border-bottom: 1px solid var(--border); padding: 10px 0; }
.status-row input[type=text] { flex: 1 1 calc(100% - 60px); }
.status-row .check { margin-right: auto; padding-left: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-size: 13px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.roles-help { margin-top: 12px; }

/* ---------- task panel: full screen on phones ---------- */
.backdrop { position: fixed; inset: 0; background: rgb(10 14 25 / 50%); z-index: 40; animation: fade .15s ease-out; }
.drawer {
  position: fixed; inset: 0; z-index: 41; background: var(--surface);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  animation: slide-up .2s ease-out;
}
.drawer.no-anim { animation: none; }
#drawer:has(.no-anim) .backdrop { animation: none; }
.drawer-head {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: 6px calc(8px + var(--safe-r)) 6px calc(4px + var(--safe-l)); border-bottom: 1px solid var(--border);
}
.drawer-head .id { color: var(--muted); font-weight: 600; }
.drawer-head .close-btn { display: none; }
.drawer-body { padding: 14px calc(var(--gutter) + var(--safe-r)) calc(32px + var(--safe-b)) calc(var(--gutter) + var(--safe-l)); display: grid; gap: 20px; }
.drawer-body > * { min-width: 0; }
.title-input { font-size: 20px !important; font-weight: 700; border-color: transparent !important; padding: 6px 8px !important; margin-left: -8px; width: calc(100% + 8px) !important; }
.title-input:focus { border-color: var(--border) !important; }
.meta-grid { display: grid; gap: 12px; }
.assign-row { display: flex; gap: 8px; }
.assign-row select { flex: 1; }
.assign-row .btn { min-height: 44px; }
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-row output { min-width: 46px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.item-list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 12px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .grow a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; padding: 2px 0; }
.item .grow small { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist { display: grid; gap: 2px; }
.check-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; padding: 0 0 0 8px; }
.check-item label { flex: 1; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 10px 0; min-width: 0; overflow-wrap: anywhere; }
.check-item.done span { text-decoration: line-through; color: var(--muted); }
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s; display: block; margin-top: 8px;
}
.dropzone.drag-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.comment { display: flex; gap: 10px; min-width: 0; }
.comment .bubble { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.comment .bubble header { display: flex; gap: 8px; align-items: center; font-size: 12px; min-height: 28px; }
.comment .bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; margin-top: 10px; }
.activity-box summary { cursor: pointer; list-style: none; min-height: 40px; display: flex; align-items: center; }
.activity-box summary::-webkit-details-marker { display: none; }
.activity-box summary h3 { margin: 0; }
.activity-box summary h3::after { content: "▸"; }
.activity-box[open] summary h3::after { content: "▾"; }
.activity-list { display: grid; gap: 10px; font-size: 14px; padding: 0; margin: 6px 0 0; }
.activity-list li { list-style: none; display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.drawer-foot { display: grid; gap: 12px; border-top: 1px solid var(--border); padding-top: 14px; }

/* ---------- dialogs: bottom sheet on phones ---------- */
#modal .backdrop { z-index: 50; }
.modal {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding: 20px calc(var(--gutter) + var(--safe-r)) calc(20px + var(--safe-b)) calc(var(--gutter) + var(--safe-l));
  animation: slide-up .2s ease-out; display: grid; gap: 10px;
}
.modal::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--border); justify-self: center; margin-top: -8px; }
.modal h2 { font-size: 18px; }
.modal form { display: grid; gap: 14px; margin-top: 6px; }
.modal > * { min-width: 0; }
/* Keep the new-task sheet short enough to fit a phone screen without scrolling. */
@media (min-width: 340px) { [data-form="new-task"] .two { grid-template-columns: 1fr 1fr; } }
[data-form="new-task"] textarea { min-height: 72px; }
.share-fields { display: grid; gap: 12px; margin-top: 6px; }
.note { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); left: 50%; translate: -50% 0; z-index: 60; display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast-msg { background: #1b2232; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; text-align: center; }
.toast-msg.error { background: #b91c1c; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes pop { from { opacity: 0; scale: .97; } }

/* Hover effects only where a real pointer exists (no sticky hover on touch). */
@media (hover: hover) {
  .touch-only { display: none; }
  .pointer-only { display: inline; }
  .tab:hover { color: var(--text); }
  .btn:hover { background: var(--surface-2); }
  .btn.primary:hover { background: var(--accent); filter: brightness(1.1); }
  .btn.danger-solid:hover { background: #dc2626; filter: brightness(1.1); }
  .btn.ghost:hover { color: var(--text); }
  .icon-btn:hover:not(:disabled), .menu-list button:hover, .chip:not(.active):hover, .jump:not(.active):hover,
  .me-btn:hover, .task-line:hover, tbody tr[data-action]:hover, .check-item:hover { background: var(--surface-2); }
  .icon-btn:hover:not(:disabled), .th-btn:hover { color: var(--text); }
  .card:hover { border-color: var(--accent); transform: translateY(-1px); }
  .take-btn:hover, .dropzone:hover { border-style: solid; border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
  .title-input:hover { border-color: var(--border) !important; }
  .quick-add input:hover { background: var(--surface); }
  .check-item .icon-btn { opacity: 0; }
  .check-item:hover .icon-btn, .check-item .icon-btn:focus-visible { opacity: 1; }
}

/* ============ 520px+: two-column forms ============ */
@media (min-width: 520px) {
  .two, .meta-grid { grid-template-columns: 1fr 1fr; }
  .actions { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
  .auth-card { padding: 28px; }
  [data-form="add-link"] input { flex-basis: 160px !important; }
  [data-form="add-link"] .btn { flex: 0 0 auto; }
  .drawer-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  .comment-form .btn { justify-self: end; }
  .status-row { flex-wrap: nowrap; border-bottom: 0; padding: 6px 0; }
  .status-row input[type=text] { flex: 1 1 0; }
  .status-row .check { margin-right: 0; }
  .panel-head .btn-row .btn { flex: 0 0 auto; }
}

/* ============ 768px+: tablet / desktop ============ */
@media (min-width: 768px) {
  :root { --gutter: 20px; --radius: 12px; }
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  svg.i { width: 15px; height: 15px; }

  .btn { min-height: 36px; padding: 7px 13px; border-radius: 8px; font-weight: 500; }
  .btn.sm { min-height: 30px; padding: 4px 10px; }
  .btn.block { min-height: 42px; }
  .icon-btn { width: 30px; height: 30px; border-radius: 7px; font-size: 15px; }
  .icon-btn.tiny { width: 22px; height: 22px; }
  input[type=text], input[type=url], input[type=email], input[type=date], input[type=password], input[type=search], select, textarea {
    min-height: 36px; padding: 7px 10px; font-size: 14px; border-radius: 8px;
  }
  select { padding-right: 24px; }
  textarea { min-height: 72px; }
  select.compact { min-height: 30px; }
  input[type=color] { width: 34px; height: 34px; border-radius: 8px; }
  input[type=range] { height: auto; }
  input[type=checkbox] { width: 16px; height: 16px; }
  label.field { font-size: 12px; }
  .copy-row input { font-size: 13px; }

  /* navigation moves into the top bar */
  .topbar { gap: 16px; padding: 10px 20px; }
  .view-title { display: none; }
  .tabs { position: static; height: auto; padding: 0; border: 0; background: transparent; justify-content: flex-start; gap: 2px; overflow-x: auto; }
  .tab { flex: none; flex-direction: row; padding: 7px 13px; border-radius: 8px; font-size: 14px; }
  .tab svg.i { display: none; }
  .tab.active { background: var(--accent-soft); }
  .new-task-btn { position: static; width: auto; height: auto; min-height: 36px; padding: 7px 13px; border-radius: 8px; box-shadow: none; }
  .new-task-btn span { display: inline; }
  .new-task-btn svg.i { width: 15px; height: 15px; }
  .me-btn { padding: 3px 12px 3px 3px; }
  .me-btn .avatar { width: 26px; height: 26px; font-size: 11px; }
  .main { padding: 20px; }
  .menu-list button { min-height: 0; padding: 8px 10px; border-radius: 8px; }
  .avatar { width: 26px; height: 26px; }
  .avatar.lg { width: 42px; height: 42px; }
  .take-btn { min-height: 0; padding: 2px 9px 2px 6px; font-size: 12px; font-weight: 500; }

  /* stats become a grid, filters wrap */
  .summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; padding: 0; overflow: visible; }
  .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
  .filters input[type=search] { max-width: 260px; }
  .filter-row { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .filter-row select { min-height: 36px; border-radius: 8px; }
  .chip { min-height: 34px; padding: 6px 13px; font-size: 13px; font-weight: 500; }

  /* board: all columns side by side */
  .col-jump { display: none; }
  .board { margin: 0; padding: 0 0 12px; gap: 14px; scroll-snap-type: none; scrollbar-width: auto; }
  .board::-webkit-scrollbar { display: block; }
  .column { flex: 0 0 292px; }
  .card { padding: 10px 12px; border-radius: 10px; }
  .card h4 { font-size: 14px; }
  .card:active { transform: none; }

  /* list: table */
  .list-sort, .list-cards { display: none; }
  .task-table { display: block; }
  .progress-cell { min-width: 120px; }

  /* people: real table */
  table.people { display: table; }
  table.people thead { display: table-header-group; }
  table.people tbody { display: table-row-group; }
  table.people tr { display: table-row; position: static; padding: 0; border: 0; }
  table.people td, table.people td[data-label] { display: table-cell; padding: 12px 14px; border-bottom: 1px solid var(--border); min-height: 0; }
  table.people td:first-child, table.people th:first-child { padding-left: 0; }
  table.people td[data-label]::before { content: none; }
  table.people td.p-menu { position: static; text-align: right; padding-right: 0; }
  table.people td.p-menu:empty { display: table-cell; }
  table.people tr:last-child td { border-bottom: 0; }
  .table-wrap.flat th { background: transparent; }
  .role { font-size: 13px; }

  .panel { padding: 16px; }
  .panel h3 { font-size: 15px; }
  .panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
  .panel-head p { max-width: 60ch; }
  .hello { margin-bottom: 18px; }
  .two-col, .stack, .settings { gap: 16px; }
  .settings { max-width: 1100px; }
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
  .section-gap { margin-top: 16px; }
  .mini-stats b { font-size: 17px; }
  .feed-item { font-size: 13px; }
  .check { min-height: 0; font-size: 12px; gap: 5px; }
  .row { padding: 6px 0; }

  /* task rows: single line */
  .task-line { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-bottom: 0; border-radius: 8px; }
  .task-line .dot { margin-top: 0; }
  .task-line .t { flex: 1; min-width: 0; display: block; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
  .task-line .line-meta { flex: none; flex-wrap: nowrap; gap: 8px; }
  .task-line .line-meta :is(.take-btn, .avatar, .pct) { margin-left: 0; }
  .task-line .pct { min-width: 34px; text-align: right; }

  /* task panel: side drawer */
  .drawer { inset: 0 0 0 auto; width: min(640px, 100vw); box-shadow: var(--shadow-lg); animation-name: slide; }
  .drawer-head { min-height: 0; padding: 12px 20px; gap: 10px; }
  .drawer-head .back-btn { display: none; }
  .drawer-head .close-btn { display: inline-grid; }
  .drawer-body { padding: 18px 20px 40px; gap: 22px; }
  .item { padding: 8px 10px; border-radius: 8px; }
  .check-item label { padding: 5px 0; gap: 10px; }
  .activity-list { font-size: 13px; }

  /* dialogs: centered */
  .modal {
    left: 50%; right: auto; bottom: auto; top: 50%; translate: -50% -50%;
    width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
    border-radius: 16px; padding: 24px; animation-name: pop;
  }
  .modal::before { content: none; }
  #toast { bottom: 20px; }
}

/* ============ 900px+: two-column dashboard, room for names in the top bar ============ */
@media (min-width: 900px) {
  .topbar .brand-text { display: block; white-space: nowrap; }
  .me-name { display: block; }
  .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
