/* Saathi — Nepzaa brand theme (shared with the Nepzaa Home): crimson #C8102E, deep blue #003893, navy, white. */
:root {
  --crimson:#c8102e;
  --crimson-d:#9e0b24;
  --crimson-l:#e0334f;
  --blue: #003893;
  --blue-d:#0b1f4d;
  --blue-l:#2b63d6;
  --gold: #f5b301;
  --bg:#ffffff;
  --bg2: #ffffff;
  --surface: #ffffff;
  --surface2: #eef1f8;
  --text:#0e1a3a;
  --muted:#566283;
  --line:#e2e7f3;
  --primary: var(--crimson);
  --accent: var(--blue);
  --ok: #16a34a;
  --warn: #b45309;
  --err: #dc2626;
  --radius: 18px;
  --shadow-1: 0 1px 2px rgba(0, 31, 84, .06), 0 4px 12px rgba(0, 31, 84, .08);
  --shadow-3d: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 -3px 0 rgba(0, 0, 0, .06) inset, 0 10px 24px -8px rgba(0, 31, 84, .28), 0 3px 6px rgba(0, 31, 84, .08);
  --hero: linear-gradient(125deg, #07163a 0%, #0b1f4d 45%, #0a2f86 78%, #9e0b24 150%);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: only light;
}
/* Saathi is light by default, on phones too. The phone's dark mode is followed only if the person picks "Follow my phone" in Settings. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0a0f1d; --bg2: #0f1629; --surface: #131c33; --surface2: #1a2540; --text: #e8ecf6; --muted: #9aa5bf; --line: #24304d;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-3d: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 -3px 0 rgba(0, 0, 0, .25) inset, 0 12px 26px -8px rgba(0, 0, 0, .7), 0 3px 6px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f1d; --bg2: #0f1629; --surface: #131c33; --surface2: #1a2540; --text: #e8ecf6; --muted: #9aa5bf; --line: #24304d;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-3d: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 -3px 0 rgba(0, 0, 0, .25) inset, 0 12px 26px -8px rgba(0, 0, 0, .7), 0 3px 6px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, Mukta, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: none;
}
a { color: var(--blue-l); }
:root[data-theme="dark"] a { color: #8fb1ff; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.2rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 650; }
h4 { font-size: .9rem; font-weight: 650; margin: 12px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: .4em 0; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.center { text-align: center; }
.ic { flex: none; vertical-align: middle; }
img, canvas, video { max-width: 100%; }

/* ---------- Layout ---------- */
#app { min-height: 100%; padding-bottom: calc(76px + var(--safe-b)); }
.page { max-width: 980px; margin: 0 auto; padding: 0 16px 24px; animation: pageIn .22s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.gap { gap: 12px; } .gap-s { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 720px) { .grid-md-3 { grid-template-columns: repeat(3, 1fr); } .grid-md-4 { grid-template-columns: repeat(4, 1fr); } }
.hide { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px; margin: 0 -16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; flex: none; box-shadow: var(--shadow-1);
}
.icon-btn:active { transform: translateY(1px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 2px 4px rgba(0,31,84,.08);
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background: linear-gradient(180deg, #ef2a51 0%, var(--crimson) 55%, var(--crimson-d) 100%); color: #fff; border-color: var(--crimson-d);
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 -2px 0 rgba(0,0,0,.18) inset, 0 8px 18px -6px rgba(220,20,60,.6);
}
.btn.blue {
  background: linear-gradient(180deg, #1d56c4 0%, var(--blue) 60%, var(--blue-d) 100%); color: #fff; border-color: var(--blue-d);
  box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 -2px 0 rgba(0,0,0,.2) inset, 0 8px 18px -6px rgba(0,56,147,.6);
}
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }
.fab {
  position: fixed; right: 18px; bottom: calc(90px + var(--safe-b)); z-index: 30; width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: linear-gradient(145deg, #ff3b62, var(--crimson) 50%, var(--blue) 140%); color: #fff; display: grid; place-items: center;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 14px 28px -8px rgba(220,20,60,.7); cursor: pointer;
}

/* ---------- Cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-1); }
.card.soft { background: var(--surface2); box-shadow: none; }
.card + .card { margin-top: 12px; }
.card-3d { background: var(--surface); border-radius: 22px; padding: 16px; box-shadow: var(--shadow-3d); border: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1.05rem; }
.section-title a { font-size: .85rem; font-weight: 600; text-decoration: none; }

/* ---------- Hero (Himalaya + flag colours) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; color: #fff; padding: 22px 20px 70px; margin-top: calc(14px + var(--safe-t));
  background: var(--hero); box-shadow: 0 24px 44px -18px rgba(0,56,147,.55), 0 1px 0 rgba(255,255,255,.25) inset;
}
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 80% at 90% -10%, rgba(255,255,255,.28), transparent 55%); pointer-events: none; }
.hero .mtn { position: absolute; left: 0; right: 0; bottom: -2px; width: 100%; height: 86px; }
.hero h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; text-shadow: 0 2px 10px rgba(0,0,0,.25); }
.hero p { opacity: .92; margin: 4px 0 0; }
.hero .date-chip { display: inline-flex; gap: 8px; align-items: center; margin-top: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3); backdrop-filter: blur(6px); font-size: .85rem; font-weight: 600; }
.hero .sun { position: absolute; right: 22px; top: 18px; width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #ffe3e8 40%, rgba(255,255,255,.2) 72%); box-shadow: 0 0 40px rgba(255,255,255,.5); }
.hero .flag { position: absolute; right: 26px; bottom: 60px; width: 34px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }

/* ---------- 3D app tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin-top: -42px; position: relative; z-index: 2; padding: 0 2px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 820px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { text-decoration: none; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-3d); border: 1px solid var(--line); text-align: center; transition: transform .15s; position: relative; }
.tile:active { transform: translateY(2px) scale(.98); }
@media (hover: hover) { .tile:hover { transform: translateY(-3px); } }
.tile b { font-size: .8rem; font-weight: 650; line-height: 1.15; }
.tile small { font-size: .68rem; color: var(--muted); margin-top: -6px; }
.orb {
  --c1: #ff5b7b; --c2: var(--crimson); --c3: #7a0a21;
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff; position: relative;
  background: linear-gradient(150deg, var(--c1) 0%, var(--c2) 52%, var(--c3) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.55) inset, 0 -4px 0 rgba(0,0,0,.18) inset, 0 10px 18px -6px color-mix(in srgb, var(--c2) 75%, transparent);
  transform: perspective(200px) rotateX(8deg);
}
.orb::after { content: ""; position: absolute; left: 6px; right: 6px; top: 4px; height: 45%; border-radius: 14px 14px 40% 40%; background: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,0)); pointer-events: none; }
.orb .ic { filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); width: 28px; height: 28px; stroke-width: 2; }
.orb.blue { --c1: #4b84ef; --c2: var(--blue); --c3: #001a4d; }
.orb.mix { --c1: #ff4d6d; --c2: var(--crimson-d); --c3: var(--blue); }
.orb.gold { --c1: #ffd45c; --c2: #f59e0b; --c3: #9a5b00; }
.orb.green { --c1: #ff8a9b; --c2: #b50e2a; --c3: #4a0613; }
.orb.teal { --c1: #8fc0ff; --c2: #1d6fd6; --c3: #0a2f6b; }
.orb.violet { --c1: #9db4e6; --c2: #1f3f94; --c3: #0b1f4d; }
.orb.slate { --c1: #94a3b8; --c2: #475569; --c3: #1e293b; }
.orb.sm { width: 42px; height: 42px; border-radius: 14px; }
.orb.sm .ic { width: 22px; height: 22px; }
.orb.lg { width: 72px; height: 72px; border-radius: 24px; }
.orb.lg .ic { width: 36px; height: 36px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); z-index: 40; width: min(560px, calc(100% - 20px));
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px; border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); box-shadow: 0 18px 36px -12px rgba(0,31,84,.35);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 16px; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600; }
.bottom-nav a.on { color: #fff; background: linear-gradient(160deg, var(--crimson), var(--blue)); box-shadow: 0 6px 14px -6px rgba(220,20,60,.7); }
body.editor-mode .bottom-nav { display: none; }
body.editor-mode #app { padding-bottom: 0; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; text-align: left; font: inherit; cursor: pointer; width: 100%; box-shadow: var(--shadow-1); }
.list-item small { display: block; }
.list-item.done b { text-decoration: line-through; color: var(--muted); }
.list-item .amt { font-weight: 700; white-space: nowrap; }
.amt.neg { color: var(--crimson); } .amt.pos { color: var(--ok); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 650; background: var(--surface2); color: var(--muted); }
.pill.red { background: color-mix(in srgb, var(--crimson) 14%, transparent); color: var(--crimson); }
.pill.blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue-l); }
.pill.green { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.amber { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pro { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 6px; font-size: .62rem; font-weight: 800; color: #5a3b00; background: linear-gradient(180deg, #ffe08a, #f5b301); vertical-align: middle; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2);
  color: var(--text); font: inherit; outline: none; transition: border .15s, box-shadow .15s;
}
textarea.input { resize: vertical; min-height: 64px; }
.input:focus { border-color: var(--blue-l); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-l) 22%, transparent); background: var(--surface); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--crimson); }
input[type=range] { width: 100%; accent-color: var(--crimson); }
.sl { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; margin: 6px 0; font-size: .82rem; color: var(--muted); }
.search { position: relative; } .search .ic { position: absolute; left: 12px; top: 11px; color: var(--muted); } .search input { padding-left: 40px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips button, .chip { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.chips.sm button { padding: 5px 10px; font-size: .78rem; }
.chips button.on, .chip.on { background: linear-gradient(160deg, var(--crimson), #b80f33); color: #fff; border-color: transparent; box-shadow: 0 4px 10px -4px rgba(220,20,60,.6); }
.seg { display: flex; background: var(--surface2); border-radius: 14px; padding: 4px; gap: 4px; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .85rem; padding: 8px 6px; border-radius: 10px; cursor: pointer; display: inline-flex; gap: 6px; justify-content: center; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.sw { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line); cursor: pointer; padding: 0; position: relative; }
.sw.on { outline: 3px solid var(--blue-l); outline-offset: 1px; }
.sw.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.sw.custom input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.grads { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin: 6px 0; }
.grads button { height: 40px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }

/* ---------- Modal / sheet ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(5,10,25,.5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.modal-back.show { opacity: 1; }
.modal { background: var(--bg2); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 26px 26px 0 0; box-shadow: 0 -20px 50px rgba(0,0,0,.3); transform: translateY(30px); transition: transform .2s; padding-bottom: var(--safe-b); }
.modal.wide { max-width: 860px; }
.modal-back.show .modal { transform: none; }
.modal:not(.sheet) { border-radius: 22px; margin: auto 16px; align-self: center; max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.modal-head::before { content: ""; position: absolute; left: 50%; transform: translateX(-50%); margin-top: -22px; width: 42px; height: 5px; border-radius: 4px; background: var(--line); }
.modal:not(.sheet) .modal-head::before { display: none; }
.modal-body { padding: 4px 16px 18px; overflow-y: auto; }
@media (min-width: 720px) { .modal-back { align-items: center; } .modal { border-radius: 24px; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 200; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 14px; background: #0f172a; color: #fff; font-weight: 600; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .2s; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: linear-gradient(135deg, #15803d, #16a34a); } .toast.err { background: linear-gradient(135deg, var(--crimson-d), var(--crimson)); }
.loader-back { position: fixed; inset: 0; z-index: 150; display: none; place-items: center; background: rgba(5,10,25,.45); }
.loader-back.show { display: grid; }
.loader { background: var(--bg2); padding: 22px 26px; border-radius: 20px; text-align: center; min-width: 220px; box-shadow: var(--shadow-3d); }
.spinner { width: 38px; height: 38px; margin: 0 auto 10px; border-radius: 50%; border: 4px solid var(--surface2); border-top-color: var(--crimson); border-right-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 6px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--crimson), var(--blue)); width: 0; transition: width .2s; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic { color: var(--crimson); opacity: .8; }
.empty h3 { color: var(--text); margin: 10px 0 4px; }

/* ---------- Editors (collage + designer) ---------- */
.editor { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 10; }
.editor .topbar { margin: 0; }
.ed-pages { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); scrollbar-width: none; }
.ed-pages::-webkit-scrollbar { display: none; }
.ed-pages .pg { flex: none; width: 54px; height: 54px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface2) center/cover no-repeat; cursor: pointer; position: relative; font-size: .62rem; font-weight: 700; color: var(--muted); display: grid; place-items: end center; padding-bottom: 2px; }
.ed-pages .pg.on { border-color: var(--crimson); box-shadow: 0 0 0 2px color-mix(in srgb, var(--crimson) 30%, transparent); }
.ed-pages .pg span { background: rgba(0,0,0,.55); color: #fff; padding: 0 5px; border-radius: 5px; }
.stage-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; background: repeating-conic-gradient(var(--surface2) 0% 25%, var(--bg) 0% 50%) 50% / 22px 22px; touch-action: none; overflow: hidden; }
.stage { box-shadow: 0 18px 40px -12px rgba(0,0,0,.45); touch-action: none; border-radius: 2px; background: #fff; }
.ed-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px 0; background: var(--surface); border-top: 1px solid var(--line); scrollbar-width: none; }
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tabs button, .dz-bar .tool { flex: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .7rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 12px; cursor: pointer; min-width: 58px; }
.ed-tabs button.on { color: var(--crimson); background: color-mix(in srgb, var(--crimson) 10%, transparent); }
.ed-panel, .dz-panel { background: var(--surface); padding: 10px 14px calc(12px + var(--safe-b)); max-height: 40vh; overflow-y: auto; }
.designer { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dz-bar { display: flex; overflow-x: auto; gap: 2px; padding: 6px 8px; background: var(--surface); border-top: 1px solid var(--line); scrollbar-width: none; align-items: center; }
.dz-bar .sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; flex: none; }
.dz-bar .tool:active, .ed-tabs button:active { background: var(--surface2); }

.tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.tray .ph { flex: none; width: 64px; height: 64px; border-radius: 12px; background: var(--surface2) center/cover; position: relative; border: 2px solid transparent; cursor: pointer; }
.tray .ph.on { border-color: var(--crimson); }
.tray .ph.used::after { content: "✓"; position: absolute; right: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 11px; display: grid; place-items: center; }
.tray .ph b { position: absolute; left: 3px; bottom: 3px; background: rgba(0,0,0,.6); color: #fff; font-size: .65rem; padding: 0 5px; border-radius: 5px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.tpl { border: 2px solid var(--line); border-radius: 14px; padding: 6px; background: var(--surface); cursor: pointer; text-align: center; font-size: .7rem; font-weight: 600; color: var(--text); position: relative; }
.tpl canvas { width: 100%; border-radius: 8px; display: block; margin-bottom: 4px; background: #fff; }
.tpl.on { border-color: var(--crimson); }
.tpl .pro { position: absolute; top: 4px; right: 4px; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.sticker-grid button { font-size: 26px; height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }

/* ---------- Project grid ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.proj { border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3d); text-decoration: none; color: var(--text); display: flex; flex-direction: column; position: relative; }
.proj .thumb { aspect-ratio: 1; background: var(--surface2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.proj .meta { padding: 8px 10px; }
.proj .meta b { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj .meta small { color: var(--muted); font-size: .72rem; }
.proj .more { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* ---------- Feature heroes on module pages ---------- */
.mod-hero { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 22px; color: #fff; margin-bottom: 14px; background: var(--hero); box-shadow: 0 18px 34px -16px rgba(0,56,147,.6); position: relative; overflow: hidden; }
.mod-hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(rgba(255,255,255,.25), transparent 65%); }
.mod-hero .orb { flex: none; --c1: rgba(255,255,255,.95); --c2: rgba(255,255,255,.7); --c3: rgba(255,255,255,.45); color: var(--crimson); }
.mod-hero p { margin: 2px 0 0; opacity: .9; font-size: .86rem; }
.mod-hero.blue { background: linear-gradient(135deg, var(--blue) 0%, #1d4fb8 50%, var(--crimson) 140%); }

/* ---------- Stats / charts ---------- */
.stat { padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3d); }
.stat small { color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 1.25rem; margin-top: 2px; }
.stat.red { background: linear-gradient(150deg, #ff4d6d, var(--crimson) 60%, var(--crimson-d)); color: #fff; border: 0; }
.stat.blue { background: linear-gradient(150deg, #3a72e0, var(--blue) 60%, var(--blue-d)); color: #fff; border: 0; }
.stat.red small, .stat.blue small { color: rgba(255,255,255,.85); }
.progress { height: 10px; border-radius: 6px; background: var(--surface2); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue-l), var(--blue)); }
.progress.warn i { background: linear-gradient(90deg, #fbbf24, var(--warn)); }
.progress.over i { background: linear-gradient(90deg, var(--crimson-l), var(--crimson)); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .d { aspect-ratio: 1; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 650; font-size: .9rem; cursor: pointer; position: relative; color: var(--text); }
.cal .d small { font-size: .6rem; color: var(--muted); font-weight: 500; }
.cal .d.out { opacity: .35; }
.cal .d.today { background: linear-gradient(150deg, var(--crimson), var(--blue)); color: #fff; border: 0; box-shadow: 0 6px 14px -6px rgba(220,20,60,.6); }
.cal .d.today small { color: rgba(255,255,255,.85); }
.cal .d.sel { outline: 2px solid var(--blue-l); }
.cal .d .dots { display: flex; gap: 2px; position: absolute; bottom: 4px; }
.cal .d .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--crimson); }
.cal .d .dots i.b { background: var(--blue-l); } .cal .d .dots i.g { background: var(--ok); } .cal .d .dots i.a { background: var(--warn); }
.cal .d.sat { color: var(--crimson); }
.countdown { display: flex; gap: 10px; }
.countdown div { flex: 1; text-align: center; padding: 10px 4px; border-radius: 14px; background: rgba(255,255,255,.16); }
.countdown b { display: block; font-size: 1.5rem; }

/* ---------- Habits ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.week button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); cursor: pointer; font-size: .7rem; font-weight: 700; color: var(--muted); }
.week button.on { background: linear-gradient(150deg, #22c55e, #15803d); color: #fff; border: 0; }
.week button.part { background: linear-gradient(150deg, #fde68a, #f59e0b); color: #5a3b00; border: 0; }

/* ---------- Notes ---------- */
.notes-grid { columns: 2 160px; column-gap: 10px; }
.note { break-inside: avoid; margin-bottom: 10px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer; white-space: pre-wrap; word-break: break-word; }
.note h3 { margin-bottom: 4px; }
.note p { font-size: .86rem; color: var(--muted); max-height: 9em; overflow: hidden; }

/* ---------- Paywall / misc ---------- */
.paywall .pw-hero { text-align: center; padding: 18px; border-radius: 20px; color: #fff; background: var(--hero); }
.paywall .pw-hero .ic { color: var(--gold); }
.pw-list { list-style: none; padding: 0; margin: 14px 0; }
.pw-list li { display: flex; gap: 8px; align-items: center; padding: 4px 0; } .pw-list .ic { color: var(--ok); }
.pw-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.pw-plan { position: relative; padding: 14px 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-align: center; box-shadow: var(--shadow-3d); }
.pw-plan .price { font-size: 1.1rem; font-weight: 800; color: var(--crimson); }
.pw-plan .badge { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font-size: .62rem; font-weight: 800; background: var(--blue); color: #fff; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.pw-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.banner { margin: 12px 0 0; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--blue) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line)); font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.preview-box { display: grid; place-items: center; background: repeating-conic-gradient(var(--surface2) 0% 25%, var(--bg) 0% 50%) 50% / 20px 20px; border-radius: 16px; padding: 10px; min-height: 160px; overflow: hidden; position: relative; }
.preview-box canvas, .preview-box img, .preview-box video { max-height: 52vh; box-shadow: 0 10px 26px -10px rgba(0,0,0,.45); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl td.r, .tbl th.r { text-align: right; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 16px auto; }
.pin-pad button { height: 60px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 1.3rem; font-weight: 700; color: var(--text); box-shadow: var(--shadow-3d); cursor: pointer; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 14px 0; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue-l); }
.pin-dots i.on { background: linear-gradient(150deg, var(--crimson), var(--blue)); border-color: transparent; }
.qr-video { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 3/4; max-height: 60vh; margin: 0 auto; }
.qr-video video { width: 100%; height: 100%; object-fit: cover; }
.qr-video .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 22px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.qr-video .frame::after { content: ""; position: absolute; left: 8%; right: 8%; height: 3px; top: 10%; background: linear-gradient(90deg, transparent, var(--crimson), transparent); animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 50% { top: 88%; } }
.corner-editor { position: relative; touch-action: none; display: inline-block; }
.corner-editor .h { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: rgba(220,20,60,.25); border: 3px solid var(--crimson); touch-action: none; cursor: grab; }
.corner-editor svg { position: absolute; inset: 0; pointer-events: none; }
.drag-handle { cursor: grab; touch-action: none; color: var(--muted); padding: 4px; }
.reorder-list .list-item.dragging { opacity: .6; outline: 2px dashed var(--crimson); }
.tabs-top { position: sticky; top: calc(62px + var(--safe-t)); z-index: 15; margin: 0 -16px 12px; padding: 0 16px 8px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; } }
.legend div { display: flex; align-items: center; gap: 8px; font-size: .85rem; padding: 3px 0; }
.legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend span { flex: 1; } .legend b { font-weight: 700; }
.grid2 > .btn, .grid3 > .btn, .row > .btn.grow { white-space: normal; min-width: 0; text-align: center; line-height: 1.2; padding-top: 6px; padding-bottom: 6px; }

/* PDF Reader + ZIP manager */
.pdfr-drop,.zdrop{display:grid;justify-items:center;gap:10px;padding:28px 16px;text-align:center;border:2px dashed var(--line);cursor:pointer}
.pdfr-drop.over,.zdrop.over{border-color:var(--primary,#2563eb);background:var(--surface2)}
.pdfr-app{display:flex;flex-direction:column;gap:8px;background:var(--bg)}
.pdfr-app.fs{padding:8px;height:100vh}
.pdfr-bar{display:flex;flex-wrap:wrap;gap:6px;align-items:center;position:sticky;top:0;z-index:5;background:var(--bg);padding:4px 0}
.pdfr-grp,.pdfr-pg{display:inline-flex;gap:4px;align-items:center}
.pdfr-pg input{width:56px;text-align:center;padding:6px}
.pdfr-find,.pdfr-hlbar{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.pdfr-find .input{flex:1;min-width:140px}
.pdfr-sw{width:24px;height:24px;border-radius:50%;border:2px solid var(--line)}.pdfr-sw.on{border-color:var(--text)}
.pdfr-body{display:flex;gap:8px;min-height:0;flex:1}
.pdfr-side{width:150px;flex:none;max-height:75vh;overflow:auto;border:1px solid var(--line);border-radius:12px;padding:6px;background:var(--surface)}
.pdfr-th{display:grid;justify-items:center;gap:2px;width:100%;padding:4px;border-radius:8px;background:none;border:2px solid transparent}.pdfr-th.on{border-color:var(--primary,#2563eb)}
.pdfr-thc{display:block;min-height:60px}.pdfr-thc canvas{max-width:100%;height:auto}
.pdfr-scroll{position:relative;flex:1;min-width:0;height:75vh;overflow:auto;background:var(--surface2);border-radius:12px;padding:12px 0}
.pdfr-app.fs .pdfr-scroll{height:calc(100vh - 120px)}
.pdfr-scroll.drawing{cursor:crosshair;touch-action:none}
.pdfr-page{position:relative;margin:0 auto 12px;background:#fff;box-shadow:0 4px 18px -8px rgba(0,0,0,.5)}
.pdfr-page canvas{display:block}
.pdfr-num{position:absolute;top:4px;left:6px;font-size:.7rem;color:#999}
.pdfr-tl{position:absolute;inset:0;overflow:hidden;line-height:1}
.pdfr-tl span,.pdfr-tl br{position:absolute;white-space:pre;color:transparent;transform-origin:0 0;cursor:text}
.pdfr-tl ::selection{background:rgba(37,99,235,.35)}
.pdfr-ov{position:absolute;inset:0;pointer-events:none}
.pdfr-mk{position:absolute;opacity:.45;mix-blend-mode:multiply}.pdfr-mk.drag{background:#ffeb3b}
.pdfr-hit{position:absolute;background:rgba(255,200,0,.45);border-radius:2px}.pdfr-hit.cur{background:rgba(255,120,0,.6);outline:2px solid #f97316}
.zlist{max-height:55vh;overflow:auto}.list-item.blk{opacity:.75;background:var(--surface2)}
.progress{height:8px;border-radius:6px;background:var(--surface2);overflow:hidden}.progress i{display:block;height:100%;background:var(--primary,#2563eb);transition:width .15s}
@media (max-width:640px){.hide-s{display:none}.pdfr-side{position:absolute;z-index:6;max-height:60vh;width:140px}}
#printRoot{display:none}
@media print{body.printing>*:not(#printRoot){display:none!important}body.printing #printRoot{display:block}.pdfr-printpg{display:block;width:100%;page-break-after:always}}

/* ---- Nine service hubs ---- */
.hubp .hub-hero { display: flex; gap: 14px; align-items: center; }
.hubgrid a { align-items: flex-start; }
.hubp .tscroll { overflow-x: auto; max-width: 100%; }
.hubp .tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.hubp .tbl th { text-align: left; font-size: .78rem; color: var(--muted); }
.hubp .field { display: grid; gap: 4px; min-width: 0; }
.hubp .field > span { font-size: .8rem; font-weight: 600; }
.hubp .grid3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hubp .chip.on { font-weight: 700; }
.hubp .src { display: block; margin-top: 6px; color: var(--muted); font-size: .75rem; }
.hubp .help summary { cursor: pointer; }
.hubp .cl { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.hubp .cl li { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.hubp .cl li.done span.grow { text-decoration: line-through; color: var(--muted); }
.hubp .cl input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.hubp .qty { width: 72px; flex: none; }
.hubp .progress { height: 8px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.hubp .progress i { display: block; height: 100%; background: var(--primary, #2563eb); }
.hubp .stat { text-align: left; cursor: pointer; border: 1px solid var(--line); }
.hubp .stat.on { outline: 2px solid var(--primary, #2563eb); }
.hubp .banner.ok { background: color-mix(in srgb, var(--ok, #067647) 14%, var(--surface)); }
.hubp .banner.err { background: color-mix(in srgb, var(--err, #b42318) 12%, var(--surface)); }
.hubp .rowx { align-items: end; }
.hubp button, .hubp .btn, .hubp .chip { min-height: 40px; }
.hubp .btn.sm { min-height: 36px; }
.cvwrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .cvwrap { grid-template-columns: 1fr; } }
.cv { font-family: Georgia, 'Noto Serif Devanagari', serif; color: #111; background: #fff; padding: 18px; border-radius: 6px; font-size: 11pt; line-height: 1.4; }
.cv h2 { margin: 0; font-size: 20pt; }
.cv h3 { margin: 14px 0 4px; font-size: 11pt; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid #999; padding-bottom: 2px; }
.cv .cvtitle { font-size: 12pt; color: #444; }
.cv .cvcontact { font-size: 9.5pt; color: #444; margin: 4px 0 6px; }
.cv .cvitem { margin: 4px 0; }
.cv .cvyears { float: right; color: #444; }
.cv .cvtag { display: inline-block; border: 1px solid #999; border-radius: 10px; padding: 0 8px; margin: 2px; font-size: 9.5pt; }
.cv-modern h2, .cv-modern h3 { color: #1d4ed8; }
.cv-modern h3 { border-color: #1d4ed8; }
.cv-compact { font-size: 10pt; line-height: 1.25; }
.cv-compact h2 { font-size: 16pt; }
.tline { list-style: none; margin: 8px 0 0; display: grid; gap: 6px; border-left: 2px solid var(--line); padding: 0 0 0 12px; }
.cal-h, .cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h b { text-align: center; font-size: .75rem; color: var(--muted); }
.cal-c { min-height: 62px; border: 1px solid var(--line); border-radius: 10px; padding: 3px 4px; background: var(--surface); font-size: .8rem; overflow: hidden; }
.cal-c.off { border: 0; background: none; }
.cal-c.has { border-color: var(--primary, #2563eb); }
.cal-c small { float: right; }
.cal-e { display: block; font-size: .68rem; background: var(--surface2); border-radius: 6px; padding: 0 3px; margin-top: 2px; overflow-wrap: anywhere; }
.tn { cursor: pointer; }
.tn .tnr { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.tn .tnr.m { stroke: #3b82f6; }
.tn .tnr.f { stroke: var(--crimson-l); }
.tn.sel .tnr { stroke-width: 3; stroke: var(--primary, #2563eb); }
.tn .tnc { fill: var(--surface2); }
.tn .tni { font-size: 18px; fill: var(--text); }
.tn .tnt { font-size: 13px; font-weight: 700; fill: var(--text); }
.tn .tns { font-size: 11px; fill: var(--muted); }
#canvas svg { color: var(--muted); display: block; }
.tn:focus { outline: none; }
.tn:focus-visible .tnr { stroke: var(--primary, #2563eb); stroke-width: 3; }
.pdoc { color: #111; background: #fff; padding: 12mm; font-family: Georgia, 'Noto Serif Devanagari', serif; }
.pdoc h1 { font-size: 20pt; margin: 0 0 8px; }
.pdoc table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.pdoc th, .pdoc td { border: 1px solid #888; padding: 4px 6px; text-align: left; }
.pdoc .pfoot { margin-top: 16px; font-size: 8.5pt; color: #555; }
.pdoc .plist { list-style: none; padding: 0; }
.pdoc .plist li { margin: 6px 0; font-size: 12pt; }
.pdoc .fcard { border: 2px solid #111; border-radius: 10px; padding: 12px; max-width: 120mm; }
.pdoc .fcard p { margin: 6px 0; }
@media print { body.printing #printRoot.pdoc { display: block; } }

/* ---- Chess and card games ---- */
.cbwrap { display: flex; justify-content: center; }
.cboard { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); width: min(100%, 560px); aspect-ratio: 1; border: 3px solid #5b3a1e; border-radius: 6px; overflow: hidden; }
.cboard .sq { position: relative; border: 0; padding: 0; display: grid; place-items: center; font-size: clamp(1.4rem, 7.5vw, 3rem); line-height: 1; cursor: pointer; min-height: 0; overflow: hidden; }
.cboard .sq.l { background: #f0d9b5; } .cboard .sq.d { background: #b58863; }
.cboard .sq.sel { box-shadow: inset 0 0 0 4px #2563eb; } .cboard .sq.last { background-image: linear-gradient(rgba(250, 204, 21, .45), rgba(250, 204, 21, .45)); }
.cboard .sq.chk { background-image: radial-gradient(circle, rgba(220, 38, 38, .85), rgba(220, 38, 38, 0) 70%); }
.cboard .sq.tg::after { content: ""; width: 26%; height: 26%; border-radius: 50%; background: rgba(37, 99, 235, .55); position: absolute; }
.cboard .sq.cap::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 4px solid rgba(37, 99, 235, .7); }
.cboard .pw { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 0 1px 3px #000; } .cboard .pb { color: #111; }
.moves { columns: 2; padding-left: 1.4rem; font-family: ui-monospace, monospace; font-size: .85rem; }
.pcard { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 54px; height: 78px; border-radius: 8px; border: 1px solid #94a3b8; background: #fff; color: #111; font-family: Georgia, serif; line-height: 1.1; padding: 0; margin: 2px; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.pcard b { font-size: 1.3rem; } .pcard i { font-style: normal; font-size: 1.4rem; } .pcard.red { color: #b91c1c; }
.pcard.sm { width: 34px; height: 48px; } .pcard.sm b { font-size: .95rem; } .pcard.sm i { font-size: 1rem; }
.pcard.back { background: repeating-linear-gradient(45deg, #1e3a8a, #1e3a8a 6px, #3b5bb5 6px, #3b5bb5 12px); border-color: #fff; }
.pcard.joker { background: #fef3c7; } .pcard.wild { outline: 3px solid #f59e0b; outline-offset: -3px; }
button.pcard { cursor: pointer; } button.pcard:disabled { opacity: .45; cursor: not-allowed; } button.pcard.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px #2563eb; } button.pcard.take { box-shadow: 0 0 0 3px #16a34a; }
button.pcard:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.hand { display: flex; flex-wrap: wrap; justify-content: center; padding: 14px 4px 4px; }
.cbtable { display: grid; grid-template-areas: ". top ." "left mid right" ". me ."; grid-template-columns: 1fr 1.4fr 1fr; gap: 6px; text-align: center; }
.cbtable .seat { display: grid; justify-items: center; gap: 2px; }
.cbtable .seat.s2 { grid-area: top; } .cbtable .seat.s1 { grid-area: left; } .cbtable .seat.s3 { grid-area: right; } .cbtable .seat.s0 { grid-area: me; }
.cbtable .slot { min-height: 80px; display: grid; place-items: center; }
.dhtable { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; } .dhtable .opp { text-align: center; }
@media (max-width: 420px) { .pcard { width: 44px; height: 64px; } .pcard b { font-size: 1.05rem; } .pcard.sm { width: 30px; height: 42px; } }

.chess [hidden], .marriage [hidden], .dhumbal [hidden], .callbreak [hidden] { display: none !important; }

/* ---- Template gallery ---- */
.gal-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 10px; }
.gal-bar input, .gal-bar select { min-height: 44px; }
@media (max-width: 520px) { .gal-bar { grid-template-columns: 1fr 1fr; } .gal-bar input { grid-column: 1 / -1; } }
.tpl-ph { display: block; width: 100%; border-radius: 8px; background: var(--surface-2, #e5e7eb); margin-bottom: 4px; }
.tpl > span:nth-of-type(2) { display: block; line-height: 1.2; }
.tpl-preview { display: grid; gap: 12px; }
.tpl-prev-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 720px) { .tpl-prev-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.tpl-prev-canvas { display: grid; place-items: start center; }
.tpl-prev-canvas canvas { max-width: 100%; max-height: 62vh; width: auto; height: auto; border-radius: 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, .25); }
.tpl-prev-form { display: grid; gap: 6px; align-content: start; }
.tpl-prev-form input, .tpl-prev-form textarea, .tpl-prev-form select { width: 100%; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatches button.on { outline: 3px solid var(--primary, #2563eb); outline-offset: 2px; }
#gal [hidden], .tpl-preview [hidden] { display: none !important; }

/* ---- Culture library ---- */
.lib-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.lib-bar .lib-search { flex: 1 1 220px; } .lib-bar input, .lib-bar select { width: 100%; min-height: 44px; }
.lib-list { display: grid; gap: 10px; }
.chip-s { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2, #eef2f7); font-size: .75rem; font-weight: 600; }
.person { display: flex; gap: 12px; align-items: flex-start; }
.person .pthumb { flex: 0 0 72px; width: 72px; height: 90px; border-radius: 10px; background: var(--surface-2, #e5e7eb); overflow: hidden; }
.person .pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person .pbody { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.lib-foot a { text-decoration: underline; }
