/* Lou – Mind Map To-Do */
:root {
  --brand: #4F46E5;
  --brand-2: #7C3AED;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --canvas: #F6F7FB;
  --drawer-w: 440px;
  --bs-font-sans-serif: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --bs-body-color: #0F172A;
}
body { font-family: var(--bs-font-sans-serif); -webkit-font-smoothing: antialiased; }
.btn-brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; box-shadow: 0 4px 14px -4px rgba(79,70,229,.55); }
.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.07); }
.btn-brand.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(99,102,241,.22), 0 4px 14px -4px rgba(79,70,229,.55); } }
.min-w-0 { min-width: 0; }

/* ---------------------------------------------------------------- login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% 0%, #EEF2FF 0%, transparent 60%), radial-gradient(900px 600px at 100% 100%, #F5F3FF 0%, transparent 60%), #F8FAFC; padding: 24px; }
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.login-bg svg { width: 100%; height: 100%; }
.login-card { position: relative; z-index: 1; width: 100%; max-width: 400px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border: 1px solid #fff; border-radius: 24px; padding: 40px 36px; box-shadow: 0 30px 60px -20px rgba(15,23,42,.25), 0 0 0 1px rgba(15,23,42,.04); }
.login-card .form-control { border-radius: 12px; }

/* ---------------------------------------------------------------- app layout */
.app-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: var(--canvas); }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 18px; background: #0F172A; color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 6px 20px -10px rgba(15,23,42,.6); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand:hover { color: #fff; }
.search { position: relative; flex: 1; max-width: 460px; }
.search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #94A3B8; font-size: 14px; }
.search input { width: 100%; height: 38px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.07); color: #fff; padding: 0 14px 0 36px; font-size: 14px; outline: none; transition: .2s; }
.search input::placeholder { color: #94A3B8; }
.search input:focus { background: rgba(255,255,255,.12); border-color: #818CF8; box-shadow: 0 0 0 3px rgba(129,140,248,.25); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-tb { height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: #E2E8F0; font-size: 14px; font-weight: 600; }
.btn-tb:hover { background: rgba(255,255,255,.13); color: #fff; border-color: rgba(255,255,255,.18); }
.btn-tb-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: 0; color: #fff; }
.btn-tb-primary:hover { filter: brightness(1.1); color: #fff; }
.btn-tb-accent { color: #FDE68A; border-color: rgba(253,230,138,.3); }
.btn-tb-accent:hover { color: #FEF3C7; background: rgba(253,230,138,.12); }
.btn-tb-danger { color: #FCA5A5; border-color: rgba(252,165,165,.25); }
.btn-tb-danger:hover { color: #FECACA; background: rgba(239,68,68,.15); border-color: rgba(252,165,165,.4); }
.reset-badge { width: 44px; height: 44px; border-radius: 14px; background: #FEE2E2; color: #DC2626; display: grid; place-items: center; font-size: 21px; flex: none; }
.reset-chip { display: inline-block; padding: 1px 9px; margin: 0 2px 3px 0; border-radius: 10px; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; }
.tb-switch { color: #CBD5E1; padding: 0 8px; }
.tb-switch .form-check-input { background-color: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); cursor: pointer; }
.tb-switch .form-check-input:checked { background-color: #6366F1; border-color: #6366F1; }
.bin-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #EF4444; color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
@media (max-width: 860px) { .btn-tb span, .tb-switch label { display: none; } .brand span { display: none; } }

.stage { position: relative; flex: 1; overflow: hidden; }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
#map.is-panning { cursor: grabbing; }

/* ---------------------------------------------------------------- map nodes */
.mm-node { cursor: pointer; }
.mm-node.mm-anim, .mm-view.mm-anim { transition: transform .35s cubic-bezier(.3,.7,.3,1); }
.mm-edges { transition: opacity .25s; }
.mm-edges.mm-hide { opacity: 0; }
.mm-node .mm-shape { transition: stroke .15s, stroke-width .15s; }
.mm-task:hover .mm-shape { stroke: #A5B4FC; stroke-opacity: 1; }
.mm-node.is-selected .mm-shape { stroke: #4F46E5; stroke-width: 2.5; stroke-opacity: 1; }
.mm-branch.is-selected .mm-shape { stroke: #0F172A; stroke-width: 3; }
.mm-node.is-drop .mm-shape { stroke: #10B981; stroke-width: 3; stroke-dasharray: 6 4; stroke-opacity: 1; }
.mm-node.is-dragging { opacity: .85; pointer-events: none; }
.mm-node.is-dim { opacity: .16; }
.mm-svg .is-ghost { opacity: .2; transition: opacity .15s; }
.mm-branch { cursor: grab; }
.mm-node.is-done { opacity: .78; }
.mm-node.is-done.is-dim { opacity: .12; }
.mm-knob { opacity: 0; transition: opacity .15s, transform .15s; }
.mm-knob.mm-collapse { opacity: .95; }
.mm-node:hover .mm-knob, .mm-node.is-selected .mm-knob { opacity: 1; }
.mm-knob:hover circle:first-child { filter: brightness(1.15); }
.mm-check { cursor: pointer; }
.mm-check:hover circle:first-child { stroke-width: 3; }

/* ---------------------------------------------------------------- overlays */
.stats-strip { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }
.stat { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 12px; border-radius: 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: 0 4px 14px -6px rgba(15,23,42,.15); font-size: 13px; color: var(--muted); transition: .15s; }
.stat b { color: var(--ink); font-size: 16px; font-weight: 800; }
.stat i { font-size: 15px; color: var(--c); }
.stat:hover { transform: translateY(-1px); border-color: var(--c); }
.stat.active { background: var(--c); border-color: var(--c); color: rgba(255,255,255,.85); }
.stat.active b, .stat.active i { color: #fff; }
.stat-red { --c: #EF4444; } .stat-amber { --c: #F59E0B; } .stat-blue { --c: #3B82F6; } .stat-orange { --c: #EA580C; } .stat-teal { --c: #0D9488; }

.zoom-ctl { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; background: #fff; border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 6px 18px -8px rgba(15,23,42,.25); overflow: hidden; z-index: 5; }
.zoom-ctl .btn { width: 40px; height: 40px; border-radius: 0; border: 0; color: #334155; }
.zoom-ctl .btn + .btn { border-top: 1px solid var(--line); }
.zoom-ctl .btn:hover { background: #EEF2FF; color: var(--brand); }

.legend { position: absolute; left: 72px; bottom: 16px; display: flex; gap: 14px; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px; background: rgba(255,255,255,.9); border: 1px solid var(--line); font-size: 12px; color: #334155; z-index: 4; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c); margin-right: 6px; vertical-align: -1px; }

.empty-hint { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 22px 30px; box-shadow: 0 20px 40px -20px rgba(15,23,42,.3); z-index: 4; }
.empty-hint h2 { font-size: 17px; font-weight: 800; margin: 8px 0 4px; }
.empty-hint p { margin: 0; color: var(--muted); font-size: 14px; }
.eh-icon { width: 46px; height: 46px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #EEF2FF, #F5F3FF); color: var(--brand); font-size: 22px; }

/* ---------------------------------------------------------------- drawer */
.drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: var(--drawer-w); max-width: calc(100% - 24px); background: #fff; border-radius: 20px; box-shadow: 0 30px 60px -20px rgba(15,23,42,.35), 0 0 0 1px rgba(15,23,42,.05); transform: translateX(calc(100% + 30px)); transition: transform .3s cubic-bezier(.3,.7,.3,1); z-index: 10; display: flex; flex-direction: column; overflow: hidden; }
.drawer.open { transform: none; }
.drawer-inner { overflow-y: auto; flex: 1; }
.dr-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 16px 20px 14px; background: linear-gradient(180deg, color-mix(in srgb, var(--bc) 10%, #fff), #fff); border-top: 4px solid var(--bc); }
.dr-crumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); }
.dr-crumbs .bi-chevron-right { font-size: 10px; }
.crumb-branch { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--bc); text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; }
.crumb-branch i { width: 9px; height: 9px; border-radius: 50%; background: var(--bc); }
.crumb-link { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-link:hover { color: var(--brand); text-decoration: underline; }
.dr-form { padding: 4px 20px 6px; }
.title-input { width: 100%; border: 0; resize: none; overflow: hidden; outline: none; font-size: 20px; font-weight: 750; letter-spacing: -.015em; line-height: 1.3; padding: 6px 0 10px; color: var(--ink); background: transparent; border-bottom: 2px solid transparent; transition: border-color .15s; }
.title-input:focus { border-bottom-color: #C7D2FE; }
.title-input::placeholder { color: #CBD5E1; }
.dr-section { margin-bottom: 14px; }
.dr-label { display: block; font-size: 11.5px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.dr-label .opt { text-transform: none; letter-spacing: 0; font-weight: 500; color: #94A3B8; }
.dr-form .form-control, .dr-form .form-select { border-radius: 9px; border-color: #E2E8F0; }
.dr-form .form-control:focus, .dr-form .form-select:focus, .composer .form-control:focus { border-color: #A5B4FC; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.sub-box { padding: 12px; border-radius: 12px; }
.sub-email { background: #ECFEFF; border: 1px solid #CFFAFE; }
.sub-activity { background: #F5F3FF; border: 1px solid #EDE9FE; }
.sub-done { background: #F0FDF4; border: 1px solid #DCFCE7; }

.seg-group { display: flex; padding: 4px; background: #F1F5F9; border-radius: 12px; gap: 4px; }
.seg { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border-radius: 9px; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; transition: .15s; }
.seg:hover { color: var(--ink); }
.btn-check:checked + .seg { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15,23,42,.12); }

.pri-group { display: flex; gap: 6px; flex-wrap: wrap; }
.pri-pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 16px; border: 1.5px solid #E2E8F0; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; transition: .15s; }
.pri-pill i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--pc); }
.pri-pill:hover { border-color: var(--pc); }
.btn-check:checked + .pri-pill { background: var(--pc); border-color: var(--pc); color: #fff; }
.btn-check:checked + .pri-pill i { background: #fff; border-color: #fff; }
.pri-normal { --pc: #94A3B8; } .pri-enhanced { --pc: #3B82F6; } .pri-urgent { --pc: #F59E0B; } .pri-ultra { --pc: #EF4444; }

.quick-dates { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.quick-dates button { border: 0; background: #F1F5F9; color: #475569; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.quick-dates button:hover { background: #E0E7FF; color: var(--brand); }

.tag-pick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tagchip { border: 0; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 10px; }
.tag-blue { background: #DBEAFE; color: #1D4ED8; } .tag-green { background: #DCFCE7; color: #15803D; } .tag-purple { background: #EDE9FE; color: #6D28D9; }
.tag-orange { background: #FFEDD5; color: #C2410C; } .tag-red { background: #FEE2E2; color: #B91C1C; } .tag-teal { background: #CCFBF1; color: #0F766E; } .tag-grey { background: #F1F5F9; color: #475569; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { width: 32px; height: 32px; border-radius: 10px; background: var(--c); cursor: pointer; transition: .15s; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.swatches label:hover { transform: scale(1.08); }
.btn-check:checked + label { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.branch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.branch-stats div { background: #F8FAFC; border: 1px solid #F1F5F9; border-radius: 12px; padding: 10px; text-align: center; }
.branch-stats b { display: block; font-size: 22px; font-weight: 800; }
.branch-stats span { font-size: 12px; color: var(--muted); }

.dr-actions { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 12px 0 14px; margin-top: 4px; background: linear-gradient(0deg, #fff 75%, rgba(255,255,255,0)); z-index: 1; }
.dr-actions .btn { border-radius: 10px; font-weight: 600; }

/* notes */
.notes { border-top: 1px solid #F1F5F9; padding: 16px 20px 24px; background: #FBFCFE; }
.notes-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.notes-head h3 { font-size: 14px; font-weight: 800; margin: 0; }
.composer { background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; padding: 10px; margin-bottom: 14px; box-shadow: 0 2px 8px -4px rgba(15,23,42,.08); }
.composer-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.composer-tabs label { font-size: 12px; font-weight: 600; color: #64748B; padding: 4px 9px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.composer-tabs label:hover { background: #F1F5F9; }
.composer-tabs .btn-check:checked + label { background: #EEF2FF; color: var(--brand); }
.composer textarea { resize: none; border-radius: 9px; }
.composer-mail { margin-bottom: 8px; }

.todo-list { list-style: none; padding: 0; margin: 0 0 14px; background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; overflow: hidden; }
.todo-list li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; font-size: 14px; flex-wrap: wrap; }
.todo-list li + li { border-top: 1px solid #F1F5F9; }
.todo-box { flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px; border: 2px solid #CBD5E1; background: #fff; display: grid; place-items: center; padding: 0; color: #fff; font-size: 13px; transition: .15s; }
.todo-box:hover { border-color: #10B981; }
.todo-list li.is-done .todo-box { background: #10B981; border-color: #10B981; }
.todo-list li.is-done .todo-text { color: #94A3B8; text-decoration: line-through; }
.todo-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.todo-list .note-edit { flex-basis: 100%; }

.note-tools { margin-left: auto; opacity: 0; transition: opacity .15s; white-space: nowrap; }
li:hover > .note-tools, .tl-body:hover .note-tools { opacity: 1; }
.note-tools button { border: 0; background: none; color: #94A3B8; padding: 0 4px; font-size: 12px; }
.note-tools button:hover { color: var(--brand); }
.note-tools .js-ndel:hover { color: #EF4444; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: #E2E8F0; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.tl-dot { position: relative; z-index: 1; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: #EEF2FF; color: var(--brand); box-shadow: 0 0 0 3px #FBFCFE; }
.tl-email .tl-dot { background: #CFFAFE; color: #0E7490; }
.tl-received .tl-dot { background: #DCFCE7; color: #15803D; }
.tl-created .tl-dot { background: #F1F5F9; color: #94A3B8; }
.tl-body { flex: 1; min-width: 0; padding-top: 4px; }
.tl-meta { display: flex; gap: 4px; align-items: baseline; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.tl-meta strong { color: #334155; }
.tl-text { margin-top: 4px; font-size: 14px; white-space: pre-wrap; word-break: break-word; background: #fff; border: 1px solid #EEF2F7; border-radius: 4px 12px 12px 12px; padding: 8px 11px; }
.tl-empty { font-size: 13px; color: var(--muted); padding-left: 40px !important; }
.note-edit { margin-top: 6px; }

/* bin, toasts, modals */
.bin-list { list-style: none; padding: 0; margin: 0; }
.bin-list li { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-top: 1px solid #F1F5F9; }
.bin-list li > i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #F1F5F9; color: #64748B; flex: none; }
.done-badge { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #10B981, #059669); color: #fff; display: grid; place-items: center; font-size: 22px; flex: none; box-shadow: 0 8px 18px -6px rgba(16,185,129,.6); }
.modal-content { border-radius: 18px; }
.toast-wrap { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.lou-toast { display: flex; align-items: center; gap: 9px; background: #0F172A; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 14px 30px -10px rgba(15,23,42,.5); transform: translateY(12px); opacity: 0; transition: .25s; }
.lou-toast.show { transform: none; opacity: 1; }
.lou-toast.ok i { color: #34D399; }
.lou-toast.err { background: #7F1D1D; }
.lou-toast.err i { color: #FCA5A5; }
.dropdown-menu { border-radius: 12px; padding: 6px; }
.dropdown-item { border-radius: 8px; font-size: 14px; }

/* ---------------------------------------------------------------- tablets and phones */
.show-sm { display: none !important; }
.search-close { display: none; }
.drawer-grab { display: none; }
.mm-node.is-lifted { filter: drop-shadow(0 10px 14px rgba(15,23,42,.28)); }
.mm-node.is-lifted .mm-shape { stroke: #10B981; stroke-width: 2.5; stroke-opacity: 1; }
@supports (height: 100dvh) { .app-page { height: 100dvh; } }

@media (max-width: 900px) {
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: 72vh; height: 72dvh; border-radius: 22px 22px 0 0;
            transform: translateY(calc(100% + 20px)); padding-bottom: env(safe-area-inset-bottom); }
  .drawer-grab { display: flex; justify-content: center; padding: 8px 0 2px; flex: none; touch-action: none; cursor: grab; }
  .drawer-grab span { width: 42px; height: 5px; border-radius: 3px; background: #CBD5E1; }
  .dr-head { touch-action: none; border-top: 0; padding-top: 6px; }
  .legend { display: none; }
  .zoom-ctl { bottom: calc(16px + env(safe-area-inset-bottom)); }
  /* bigger touch targets */
  .note-tools { opacity: 1; }
  .note-tools button { padding: 4px 8px; font-size: 14px; }
  .todo-box { width: 24px; height: 24px; }
  .quick-dates button { padding: 5px 10px; font-size: 12.5px; }
}

@media (max-width: 700px) {
  .topbar { height: 56px; gap: 10px; padding: 0 10px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); position: relative; }
  .brand span { display: none; }
  .hide-sm { display: none !important; }
  .show-sm { display: inline-flex !important; }
  .tools { gap: 6px; }
  .btn-tb { height: 40px; min-width: 40px; justify-content: center; padding: 0 10px; }
  .btn-tb-primary span { display: inline; }
  .search { display: none; }
  .topbar.searching .search { display: block; position: absolute; left: 10px; right: 10px; bottom: 9px; max-width: none; z-index: 2; }
  .topbar.searching .search input { height: 38px; background: #1E293B; padding-right: 40px; font-size: 16px; }
  .topbar.searching .search-close { display: grid; place-items: center; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: none; color: #CBD5E1; }
  .menu-sm { min-width: 230px; }
  .menu-sm .dropdown-item { padding: 10px 12px; font-size: 15px; }

  .stats-strip { top: 10px; left: 0; right: 0; padding: 0 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .stats-strip::-webkit-scrollbar { display: none; }
  .stat { flex: none; height: 36px; padding: 0 11px 0 10px; font-size: 12.5px; gap: 6px; }
  .stat b { font-size: 15px; }
  .zoom-ctl { left: 10px; }
  .zoom-ctl .btn { width: 44px; height: 44px; }
  .empty-hint { left: 12px; right: 12px; transform: none; bottom: 90px; padding: 18px; }

  .drawer { height: 76vh; height: 76dvh; }
  .dr-head { padding: 4px 16px 10px; }
  .dr-form { padding: 4px 16px 6px; }
  .notes { padding: 14px 16px 28px; }
  .title-input { font-size: 19px; }
  /* 16px stops phones zooming in when a box is tapped */
  .dr-form .form-control, .dr-form .form-select, .composer .form-control, .note-edit .form-control, #doneNote { font-size: 16px; }
  .seg { height: 38px; font-size: 13px; }
  .pri-pill { height: 36px; padding: 0 11px; }
  .composer-tabs label { padding: 6px 9px; }
  .dr-actions { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dr-actions .btn { padding: 9px 14px; }
  .toast-wrap { bottom: auto; top: calc(66px + env(safe-area-inset-top)); width: calc(100% - 24px); }
  .lou-toast { max-width: 100%; }
  .modal-dialog { margin: 12px; }
}

/* ---------------------------------------------------------------- weekly print view */
.week-page { background: #E9ECF3; min-height: 100vh; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.week-tools { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 20px; background: #0F172A; color: #E2E8F0; box-shadow: 0 6px 20px -10px rgba(15,23,42,.6); }
.week-tools .btn-light { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.1); color: #E2E8F0; }
.week-tools .btn-light:hover, .week-tools .btn-light.active { background: rgba(255,255,255,.18); color: #fff; }
.week-tools .btn-light.active { box-shadow: inset 0 -2px 0 #818CF8; }
.week-tools .form-check-input { background-color: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); cursor: pointer; }
.week-tools .form-check-input:checked { background-color: #6366F1; border-color: #6366F1; }
.sheets { padding: 28px 20px 60px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.sheet { width: 297mm; background: #fff; border-radius: 6px; box-shadow: 0 30px 60px -25px rgba(15,23,42,.35), 0 0 0 1px rgba(15,23,42,.04); padding: 9mm 11mm 7mm; display: flex; flex-direction: column; }
.sheet-map { height: 210mm; }
.sheet-detail { min-height: 210mm; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 5mm; border-bottom: 2px solid #EEF2FF; }
.sh-brand { display: flex; align-items: center; gap: 12px; }
.sh-kicker { font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #6366F1; }
.sheet-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0; color: #0F172A; }
.sheet-head h2 { font-size: 17px; font-weight: 800; margin: 0; }
.sh-stats { display: flex; gap: 8px; }
.ss { min-width: 74px; padding: 6px 10px; border-radius: 10px; text-align: center; background: var(--sb); }
.ss b { display: block; font-size: 20px; font-weight: 800; line-height: 1.1; color: var(--sc); }
.ss span { font-size: 10.5px; font-weight: 600; color: #64748B; text-transform: uppercase; letter-spacing: .05em; }
.ss-ink { --sb: #EEF2FF; --sc: #4338CA; } .ss-red { --sb: #FEF2F2; --sc: #DC2626; } .ss-purple { --sb: #F5F3FF; --sc: #7C3AED; }
.ss-amber { --sb: #FFFBEB; --sc: #D97706; } .ss-green { --sb: #F0FDF4; --sc: #059669; }
.map-wrap { flex: 1; min-height: 0; padding: 4mm 0; background: radial-gradient(circle, #E2E8F0 1px, transparent 1.2px) 0 0 / 16px 16px; border-radius: 8px; margin-top: 4mm; }
.map-wrap svg { width: 100%; height: 100%; display: block; }
.map-wrap .mm-node { cursor: default; }
.map-wrap .mm-node.is-free { opacity: .55; }
.map-wrap .mm-node.is-done { opacity: .7; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 3mm; font-size: 10.5px; color: #94A3B8; }
.sf-legend { display: flex; gap: 14px; color: #475569; font-weight: 500; }
.sf-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c); margin-right: 5px; vertical-align: -1px; }
.sf-legend i.done { background: #10B981; border-color: #10B981; }

.dt-group { margin-top: 6mm; break-inside: avoid-page; }
.dt-group h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; margin: 0 0 2mm; color: var(--gc); text-transform: uppercase; letter-spacing: .04em; }
.dt-group h3 i { width: 10px; height: 10px; border-radius: 3px; background: var(--gc); }
.dt-group h3 span { font-size: 11px; color: #94A3B8; font-weight: 600; text-transform: none; letter-spacing: 0; }
.dt { width: 100%; border-collapse: collapse; font-size: 12px; }
.dt tr { border-top: 1px solid #EEF2F7; break-inside: avoid; }
.dt td { padding: 7px 6px; vertical-align: top; }
.c-box { width: 26px; }
.box { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--pc); color: #fff; font-size: 10px; font-weight: 800; }
.is-done .box { background: #10B981; border-color: #10B981; }
.dt-title { font-weight: 700; font-size: 13px; color: #0F172A; }
.is-done .dt-title { color: #94A3B8; text-decoration: line-through; }
.dt-sub { color: #64748B; margin-top: 1px; }
.dt-sub .late { color: #DC2626; font-weight: 600; }
.dt-details { margin-top: 3px; color: #334155; white-space: pre-wrap; }
.dt-todos { list-style: none; padding: 0; margin: 4px 0 0; columns: 2; column-gap: 20px; }
.dt-todos li { display: flex; gap: 6px; align-items: flex-start; break-inside: avoid; color: #334155; }
.dt-todos li span { flex: none; width: 12px; height: 12px; margin-top: 2px; border: 1.5px solid #94A3B8; border-radius: 3px; font-size: 9px; line-height: 9px; text-align: center; color: #fff; }
.dt-todos li.done { color: #94A3B8; text-decoration: line-through; }
.dt-todos li.done span { background: #10B981; border-color: #10B981; }
.dt-notes { margin-top: 4px; padding: 4px 8px; background: #F8FAFC; border-left: 3px solid #C7D2FE; border-radius: 0 6px 6px 0; color: #334155; }
.dt-notes b { color: #475569; font-weight: 600; }
.c-branch { width: 120px; }
.c-branch span { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: #334155; }
.c-branch span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bc); }
.c-pri { width: 80px; text-align: right; }
.pri { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 10.5px; font-weight: 700; color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, #fff); }

/* week page on smaller screens: the paper shrinks to fit (printing is unchanged) */
.phone-hint { display: none; }
@media screen and (max-width: 1180px) {
  .sheets { padding: 16px 10px 40px; gap: 16px; }
  .sheet { width: 100%; max-width: 297mm; padding: 18px 18px 12px; }
  .sheet-map { height: auto; }
  .map-wrap { flex: none; aspect-ratio: 297 / 160; min-height: 240px; }
}
@media screen and (max-width: 700px) {
  .week-tools { position: static; gap: 8px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .week-tools .btn-sm { padding: 6px 10px; }
  .week-tools .ms-auto { margin-left: 0 !important; width: 100%; padding: 9px; }
  .sheet { border-radius: 10px; padding: 14px 12px 10px; }
  .sheet-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .sheet-head h1 { font-size: 20px; }
  .sh-stats { flex-wrap: wrap; gap: 6px; }
  .ss { min-width: 0; flex: 1 1 56px; padding: 5px 6px; }
  .ss b { font-size: 17px; }
  .ss span { font-size: 9.5px; }
  .map-wrap { aspect-ratio: auto; height: auto; min-height: 0; padding: 8px 0; }
  .map-wrap svg { height: auto; max-height: 75vh; }
  .phone-hint { display: block; font-size: 12px; color: #64748B; text-align: center; margin-top: 6px; }
  .sheet-foot { flex-direction: column; gap: 6px; align-items: flex-start; }
  .sf-legend { flex-wrap: wrap; gap: 8px 12px; }
  .dt td { padding: 7px 3px; }
  .c-branch { width: auto; display: none; }
  .c-pri { width: 64px; }
  .dt-todos { columns: 1; }
}

@page { size: A4 landscape; margin: 0; }
@media print {
  .no-print { display: none !important; }
  .week-page { background: #fff; }
  .sheets { padding: 0; gap: 0; display: block; }
  .sheet { box-shadow: none; border-radius: 0; margin: 0; width: 297mm; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet-detail { min-height: 0; }
}
