/* ===== Tokens ===== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e8ebf2;
  --border: #e3e6ee;
  --border-strong: #cfd4df;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8a94a7;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fff5e6;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --prio: #e11d48;
  --prio-soft: #fff0f3;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-h: 60px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #131a26; --surface-2: #1a2232; --surface-3: #232d40;
    --border: #232c3d; --border-strong: #334057; --text: #e7ebf3; --text-2: #a8b2c5; --text-3: #6f7a90;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #1e2347; --accent-text: #0b0f17;
    --ok: #34d399; --ok-soft: #10261d; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1517;
    --prio: #fb7185; --prio-soft: #2c141b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17; --surface: #131a26; --surface-2: #1a2232; --surface-3: #232d40;
  --border: #232c3d; --border-strong: #334057; --text: #e7ebf3; --text-2: #a8b2c5; --text-3: #6f7a90;
  --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #1e2347; --accent-text: #0b0f17;
  --ok: #34d399; --ok-soft: #10261d; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1517;
  --prio: #fb7185; --prio-soft: #2c141b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 16px rgba(0, 0, 0, .25); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { display: inline-flex; flex-shrink: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.container.wide { max-width: 1280px; }
.container.narrow { max-width: 760px; }
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } .hide-sm { display: none; } }

/* ===== Buttons & inputs ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap; color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2);
  flex-shrink: 0; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input::placeholder { color: var(--text-3); }
.input.lg { min-height: 50px; font-size: 17px; }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94a7' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.field { display: grid; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.hint { font-size: 12.5px; color: var(--text-3); }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
@media (max-width: 640px) { .input { font-size: 16px; } }

/* ===== Chips / badges / avatars ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; max-width: 100%;
}
.chip.ghost { padding: 0 6px; }
.chip.time { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip.time.soon { background: var(--warn-soft); color: var(--warn); }
.chip.time.late { background: var(--danger-soft); color: var(--danger); }
.chip.person { padding-left: 3px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; transition: all .15s;
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }
.chip-btn.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-btn .count { font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); line-height: 18px; }
.chip-btn.active .count { background: color-mix(in srgb, var(--bg) 22%, transparent); color: var(--bg); }
.avatar {
  display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; letter-spacing: -.02em;
  box-shadow: 0 0 0 2px var(--surface);
}
.role-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.role-badge.owner { background: var(--accent-soft); color: var(--accent); }
.role-badge.editor { background: var(--ok-soft); color: var(--ok); }
.role-badge.viewer { background: var(--surface-2); color: var(--text-2); }
.badge { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--prio); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; gap: 8px; height: var(--topbar-h); max-width: 1280px; margin: 0 auto; padding: 0 12px; }
.topbar-title { min-width: 0; display: grid; }
.ev-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-sub { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.ev-sub .role-badge { margin-left: 4px; }
.dot-sep { color: var(--text-3); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; padding: 0 4px; }
.brand b { font-weight: 700; color: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; }
.presence { display: flex; align-items: center; padding-left: 6px; }
.presence-av { margin-left: -8px; display: inline-flex; }
.presence-more { margin-left: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0 8px; height: 28px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.conn.on .conn-dot { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent); animation: pulse 2.4s infinite; }
.conn.wait .conn-dot { background: var(--warn); }
.conn.off { background: var(--danger-soft); color: var(--danger); }
.conn.off .conn-dot { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.conn-short { display: none; }
@media (max-width: 720px) {
  .conn-label { display: none; }
  .conn-short { display: inline; }
  .conn.on { padding: 0 10px; background: transparent; }
  .presence-av:nth-child(n+3) { display: none; }
  .share-btn { width: 40px; padding: 0; }
}

/* ===== Home ===== */
.home { padding-top: 28px; padding-bottom: 60px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.025em; }
.hero p { margin-top: 4px; max-width: 520px; }
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.event-card {
  display: grid; gap: 10px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.event-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.event-card.gone { opacity: .55; }
.event-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.event-card h3 { font-size: 16.5px; font-weight: 700; }
.event-card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.event-card-meta .icon { margin-right: -6px; color: var(--text-3); }
.event-card-progress { display: flex; align-items: center; gap: 10px; }
.event-card-progress .bar { flex: 1; }
.pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.empty { text-align: center; padding: 56px 20px; display: grid; justify-items: center; gap: 10px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-top: 24px; }
.empty p { max-width: 420px; margin-bottom: 8px; }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.loading { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 12px; }

/* ===== Progress bars ===== */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar.complete .bar-fill, .section.complete .bar-fill { background: var(--ok); }
.bar.big { height: 12px; flex: 1; }

/* ===== New event ===== */
.new-form { display: grid; gap: 16px; padding: 22px 0 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); display: grid; gap: 12px; }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.step { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 800; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
@media (max-width: 640px) { .form-actions .btn.primary { flex: 1; } }

/* ===== Briefing input ===== */
.briefing { display: grid; gap: 12px; }
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 18px; border: 2px dashed var(--border-strong); border-radius: 12px; cursor: pointer;
  background: var(--surface-2); transition: all .15s; color: var(--text-2);
}
.dropzone strong { color: var(--text); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.or { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12.5px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.brief-text { min-height: 130px; font-size: 14px; }
.brief-status { display: none; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.brief-status.show { display: flex; }
.brief-status .err { color: var(--danger); }
.brief-preview { display: grid; gap: 10px; }
.brief-summary { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); flex-wrap: wrap; }
.brief-sec { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.brief-sec-title { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface-2); font-weight: 700; font-size: 14px; }
.brief-sec-title .link-btn { margin-left: auto; font-weight: 500; }
.brief-task { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border-top: 1px solid var(--border); font-size: 14px; }
.brief-task-title { flex: 1; min-width: 0; }
.flag-btn { border: 0; background: none; color: var(--text-3); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; }
.flag-btn.on { color: var(--prio); background: var(--prio-soft); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Event: progress + toolbar ===== */
.progress-wrap { background: var(--surface); border-bottom: 1px solid var(--border); }
.progress-inner { padding-top: 14px; padding-bottom: 12px; }
.progress-row { display: flex; align-items: center; gap: 14px; }
.pct-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; min-width: 78px; line-height: 1; }
.pct-text { font-size: 13.5px; color: var(--text-2); font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pct-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pct-flags:empty { display: none; }
.pflag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; border: 0; font-size: 12.5px; font-weight: 600; }
.pflag.prio { background: var(--prio-soft); color: var(--prio); }
.pflag.late { background: var(--danger-soft); color: var(--danger); }
.pflag.soon { background: var(--warn-soft); color: var(--warn); }
.pflag.mine { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) {
  .progress-row { flex-wrap: wrap; gap: 4px 12px; }
  .pct-num { font-size: 26px; min-width: 0; }
  .progress-row .bar.big { order: 3; flex-basis: 100%; height: 10px; margin-top: 6px; }
  .pct-text { align-self: flex-end; }
}
.toolbar { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.toolbar-inner { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 1px; }
.chips::-webkit-scrollbar { display: none; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search-input { padding-left: 34px; min-height: 36px; height: 36px; width: 260px; border-radius: 999px; font-size: 14px; }
@media (max-width: 900px) {
  .toolbar-inner { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar-right { order: -1; }
  .search { flex: 1; }
  .search-input { width: 100%; }
}
@media (max-width: 720px) { .toolbar-right > .btn { display: none; } }

/* ===== Event: layout ===== */
.ev-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; padding: 18px 0 40px; align-items: start; }
.ev-main { display: grid; gap: 14px; min-width: 0; }
.aside { position: sticky; top: calc(var(--topbar-h) + 72px); display: grid; gap: 14px; max-height: calc(100dvh - var(--topbar-h) - 92px); grid-template-rows: auto minmax(0, 1fr); }
.aside-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); min-height: 0; display: flex; flex-direction: column; }
.aside-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 10px; color: var(--text); }
.activity-list { overflow-y: auto; display: grid; gap: 2px; margin: 0 -8px; padding: 0 8px; align-content: start; min-height: 0; }
.team-list { display: grid; gap: 8px; max-height: 220px; overflow-y: auto; }
.team-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.team-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.presence-dot.on { background: var(--ok); }
.bottom-nav { display: none; }
@media (max-width: 1100px) {
  .ev-layout { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .aside { display: none; position: static; max-height: none; grid-template-rows: auto; }
  .ev-layout.show-activity .ev-main { display: none; }
  .ev-layout.show-activity .aside { display: grid; }
  .activity-list { max-height: none; overflow: visible; }
  .bottom-nav {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  }
  .readonly .bottom-nav { grid-template-columns: 1fr 1fr; }
}
.tab { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 6px 0; }
.tab.active { color: var(--accent); }
.tab-icon { position: relative; display: inline-flex; }
.tab-add { width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-text); place-items: center; margin-top: -22px; box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent); }

/* ===== Info card ===== */
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.info-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 14px; border: 0; background: none; font-weight: 600; font-size: 14px; text-align: left; }
.info-head .chev { margin-left: auto; }
.info-body { padding: 0 14px 14px 38px; white-space: pre-wrap; font-size: 14px; color: var(--text-2); }
.chev { display: inline-flex; transition: transform .2s; transform: rotate(-90deg); color: var(--text-3); }
.chev.open { transform: rotate(0); }

/* ===== Sections & tasks ===== */
.sections { display: grid; gap: 14px; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.sec-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 6px; }
.sec-toggle { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px; text-align: left; min-width: 0; border-radius: 8px; }
.sec-toggle h3 { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-count { font-size: 12.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.section.complete .sec-count { background: var(--ok-soft); color: var(--ok); }
.sec-bar { flex: 1; min-width: 40px; max-width: 160px; margin-left: auto; }
.sec-bar .bar { height: 6px; }
.section.collapsed .sec-body, .section.collapsed .sec-foot { display: none; }
.sec-body { border-top: 1px solid var(--border); }
.sec-empty { padding: 14px 18px; }
.sec-foot { border-top: 1px solid var(--border); padding: 4px 8px; }
.qa-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text-2); font-weight: 600; font-size: 14px; padding: 10px 10px; border-radius: 8px; }
.qa-btn:hover { color: var(--accent); background: var(--accent-soft); }
.qa-form { display: flex; gap: 8px; align-items: center; padding: 6px 2px; }
.qa-input { min-height: 38px; }
.add-section { display: flex; }

.task { display: flex; align-items: flex-start; gap: 4px; padding: 4px 12px 4px 6px; border-top: 1px solid var(--border); position: relative; transition: background .3s; }
.task:first-child { border-top: 0; }
.task.prio::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--prio); }
.task.late { background: color-mix(in srgb, var(--danger-soft) 60%, transparent); }
.task.flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.tick {
  flex-shrink: 0; width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; color: transparent; position: relative;
}
.tick::before { content: ''; position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); transition: all .15s; }
.tick .icon { position: relative; z-index: 1; transform: scale(.6); transition: transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.tick:hover:not(:disabled)::before { border-color: var(--ok); }
.tick[aria-pressed="true"]::before { background: var(--ok); border-color: var(--ok); }
.tick[aria-pressed="true"] { color: #fff; }
.tick[aria-pressed="true"] .icon { transform: scale(1); }
.tick:disabled { opacity: .75; }
.task-main { flex: 1; min-width: 0; display: grid; gap: 4px; padding: 13px 0 12px; border: 0; background: none; text-align: left; }
.task-title { font-size: 15px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.task.done .task-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-3) 60%, transparent); }
.task-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.done-by { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ok); font-weight: 600; }
.prio-flag { color: var(--prio); padding-top: 15px; }
.list-empty { text-align: center; padding: 40px 16px; display: grid; justify-items: center; gap: 14px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ===== Activity ===== */
.act { display: flex; gap: 10px; padding: 8px; border-radius: 10px; border: 0; background: none; text-align: left; font-size: 13.5px; line-height: 1.4; width: 100%; }
button.act:hover { background: var(--surface-2); }
.act-body { min-width: 0; overflow-wrap: anywhere; }
.act-body i { font-style: normal; color: var(--text); font-weight: 500; }
.act-done .avatar { box-shadow: 0 0 0 2px var(--ok); }
.act-note { display: block; margin-top: 4px; padding: 6px 10px; border-radius: 4px 10px 10px 10px; background: var(--surface-2); color: var(--text); }
.act-time { margin-top: 1px; font-size: 12px; }

/* ===== Overlay / modal / drawer ===== */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 20, .45); display: grid; place-items: center; padding: 16px; animation: fade .18s ease; backdrop-filter: blur(2px); }
.overlay.out { animation: fade .18s ease reverse forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.modal { width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: rise .22s cubic-bezier(.2, .8, .2, 1); border: 1px solid var(--border); }
.modal.sm { max-width: 420px; }
.modal.md { max-width: 620px; }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 4px 20px; }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 12px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .overlay:not(.drawer-overlay) { place-items: end stretch; padding: 0; }
  .overlay:not(.drawer-overlay) .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}
.name-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.name-chips .chip-btn { height: 40px; padding: 0 14px 0 8px; }

.drawer-overlay { place-items: stretch end; padding: 0; backdrop-filter: none; background: rgba(8, 12, 20, .28); }
.drawer { width: min(520px, 100vw); height: 100dvh; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .24s cubic-bezier(.2, .8, .2, 1); border-left: 1px solid var(--border); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + env(safe-area-inset-top)) 10px 10px 16px; border-bottom: 1px solid var(--border); position: relative; }
.drawer-grip { display: none; }
.drawer-section { display: flex; align-items: center; gap: 6px; color: var(--text-2); min-width: 0; }
.drawer-section select { border: 0; background-color: var(--surface-2); min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13.5px; font-weight: 600; max-width: 260px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 16px; align-content: start; }
.title-input { font-size: 19px; font-weight: 700; border-color: transparent; padding: 6px 8px; margin: -6px -8px 0; resize: none; background: transparent; line-height: 1.35; width: calc(100% + 16px); }
.title-input:hover:not([readonly]) { border-color: var(--border); }
.done-toggle { height: 52px; width: 100%; justify-content: center; font-size: 15px; border-width: 2px; }
.done-toggle.is-done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.done-toggle small { font-weight: 500; opacity: .85; }
.prio-toggle { width: 100%; height: 42px; }
.prio-toggle.on { background: var(--prio-soft); border-color: var(--prio); color: var(--prio); }
.drawer-fields { grid-template-columns: 1fr 1.3fr 1fr; }
@media (max-width: 480px) { .drawer-fields { grid-template-columns: 1fr 1fr; } .drawer-fields > :last-child { grid-column: 1 / -1; } }
.drawer-block { display: grid; gap: 10px; }
.drawer-block h4 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.notes { display: grid; gap: 10px; }
.note { display: flex; gap: 10px; }
.note-body { flex: 1; min-width: 0; }
.note-head { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; }
.note-head .link-btn { margin-left: auto; color: var(--text-3); }
.note-text { margin-top: 3px; padding: 8px 12px; background: var(--surface-2); border-radius: 4px 12px 12px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-form textarea { resize: none; min-height: 42px; }
.note-form .btn { height: 42px; }
.task-history { display: grid; gap: 0; margin: 0 -8px; }
@media (max-width: 640px) {
  .drawer-overlay { place-items: end stretch; }
  .drawer { width: 100%; height: auto; max-height: 94dvh; border-radius: 20px 20px 0 0; border-left: 0; animation: rise .24s cubic-bezier(.2, .8, .2, 1); }
  .drawer-head { padding-top: 16px; }
  .drawer-grip { display: block; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--border-strong); }
}

/* ===== Share ===== */
.share { display: grid; gap: 12px; }
.share-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: grid; gap: 10px; background: var(--surface); }
.share-card-head { display: flex; gap: 12px; align-items: flex-start; }
.share-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.share-ic.editor { background: var(--ok-soft); color: var(--ok); }
.share-ic.viewer { background: var(--surface-2); color: var(--text-2); }
.share-ic.owner { background: var(--accent-soft); color: var(--accent); }
.share-link { display: flex; gap: 8px; }
.share-link .input { font-size: 13px; min-height: 34px; height: 34px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2); }
.share-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-left: -8px; }
.qr { display: grid; justify-items: center; gap: 6px; padding: 8px; }
.qr img { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 6px; border: 1px solid var(--border); }
.owner-link summary { cursor: pointer; font-size: 13.5px; color: var(--text-2); font-weight: 600; padding: 6px 0; }
.owner-link .share-card { margin-top: 8px; }

/* ===== Menu ===== */
.menu { position: fixed; z-index: 60; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: rise .14s ease; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; font-size: 14px; text-align: left; color: var(--text); }
.menu-item .icon { color: var(--text-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ===== Toasts ===== */
.toasts { position: fixed; z-index: 70; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 1100px) { .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); } }
.toast { display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 16px; background: #111827; color: #f3f4f6; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; pointer-events: auto; animation: rise .2s ease; }
:root[data-theme="dark"] .toast { background: #273046; }
.toast.out { animation: fade .2s ease reverse forwards; }
.toast-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toast-msg i { font-style: normal; opacity: .85; }
.toast.ok { border-left: 3px solid #34d399; }
.toast.err { border-left: 3px solid #f87171; }
.toast.warn { border-left: 3px solid #fbbf24; }
.toast-btn { border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 8px; flex-shrink: 0; }
.toast-btn:hover { background: rgba(255, 255, 255, .2); }

/* ===== Print report ===== */
#print { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; }
  #print h1 { font-size: 20pt; margin-bottom: 4pt; }
  #print h2 { font-size: 13pt; margin: 16pt 0 6pt; border-bottom: 1.5pt solid #000; padding-bottom: 3pt; }
  #print table { width: 100%; border-collapse: collapse; }
  #print th { text-align: left; font-size: 9pt; color: #555; border-bottom: .5pt solid #999; padding: 3pt 4pt; }
  #print td { vertical-align: top; padding: 4pt; border-bottom: .5pt solid #ddd; font-size: 10pt; }
  #print .p-box { width: 16pt; font-size: 12pt; }
  #print .p-done td { color: #444; }
  #print .p-det, #print .p-note { font-size: 9pt; color: #555; margin-top: 2pt; }
  #print .p-notes { white-space: pre-wrap; font: inherit; font-size: 10pt; background: #f4f4f4; padding: 8pt; border-radius: 4pt; }
  #print .p-sec { break-inside: auto; }
  #print tr { break-inside: avoid; }
}

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

/* Botão de detalhes separado do ok (toque na tarefa só marca) */
.task-main { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.task-info { flex: none; align-self: center; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--text-3); }
.task-info:hover, .task-info:focus-visible { background: var(--surface-2, rgba(127,127,127,.12)); color: var(--text); }
.task .prio-flag { align-self: center; }
