/* =====================================================================
   App shell (sidebar + full-width content), page headers, tool layouts,
   and cross-browser hardening. Loaded last so it can refine earlier sheets.
   ===================================================================== */

/* ---------- cross-browser hardening ---------- */
html { text-size-adjust: 100%; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
select { -webkit-appearance: none; -moz-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d99ba' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
select::-ms-expand { display: none; }
select option { background: var(--surface); color: var(--fg); }
input[type=file] { padding: 6px; cursor: pointer; }
input[type=file]::file-selector-button { font: 600 var(--fs-sm) var(--font-ui); min-height: 32px; margin-right: 12px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); color: var(--fg); cursor: pointer; }
input[type=file]::-webkit-file-upload-button { font: 600 var(--fs-sm) var(--font-ui); min-height: 32px; margin-right: 12px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); color: var(--fg); cursor: pointer; }
input[type=date], input[type=month] { min-height: var(--tap); }
input[type=color] { padding: 4px; min-height: var(--tap); cursor: pointer; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.eyebrow, .cmdk, .sidebar, .mtop { -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  nav.top, .mtop, .sidebar, .card.glass, .auth-card { background: var(--surface); }
}
@media (hover: none) { .card.lift:hover, .kcard:hover, button:hover, .btn:hover { transform: none; } }

/* ---------- app shell ---------- */
body.is-app { --sb-w: 232px; }
html[data-sb="mini"] body.is-app { --sb-w: 68px; }
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 80; width: var(--sb-w); display: flex; flex-direction: column; gap: 6px;
  padding: 14px 12px; background: rgba(11, 16, 32, .72); border-right: 1px solid var(--line); overflow-x: hidden; overflow-y: auto; }
:root[data-theme="light"] .sidebar { background: rgba(255, 255, 255, .78); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .sidebar { background: rgba(255, 255, 255, .78); } }
.sb-head { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px 0 6px; }
.sb-head .brand { display: flex; align-items: center; overflow: hidden; flex: 1; min-width: 0; text-decoration: none; }
.sb-head .logo { height: 26px; }
.sb-collapse { flex: none; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding-top: 4px; }
.sb-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin: 14px 10px 4px; white-space: nowrap; }
.sb-nav a, .sb-btn { position: relative; display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 10px; border-radius: 10px; color: var(--muted);
  text-decoration: none; font: 500 var(--fs-sm) var(--font-ui); white-space: nowrap; background: transparent; border: 0; box-shadow: none; width: 100%; justify-content: flex-start; }
.sb-nav a:hover, .sb-btn:hover { background: var(--tint-info); color: var(--fg); transform: none; box-shadow: none; filter: none; }
.sb-nav a[aria-current="page"] { background: var(--tint-ok); color: var(--accent-strong); font-weight: 600; }
.sb-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sb-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.sb-btn .moon { display: none; } :root[data-theme="light"] .sb-btn .moon { display: block; } :root[data-theme="light"] .sb-btn .sun { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .sb-btn .moon { display: block; } :root:not([data-theme]) .sb-btn .sun { display: none; } }
.app-body { margin-left: var(--sb-w); min-height: 100vh; min-height: 100dvh; min-width: 0; }
.mtop { display: none; }
.sb-scrim { display: none; }

/* mini (icon) sidebar on desktop */
html[data-sb="mini"] .is-app .sb-text, html[data-sb="mini"] .is-app .sb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-sb="mini"] .is-app .sb-nav a, html[data-sb="mini"] .is-app .sb-btn { justify-content: center; padding: 0; }
html[data-sb="mini"] .is-app .sb-head { flex-direction: column; gap: 10px; padding: 0; }
html[data-sb="mini"] .is-app .sb-head .brand { width: 27px; flex: none; }  /* just the leaf of the 26px-tall logo */
html[data-sb="mini"] .is-app .sb-nav { padding-top: 14px; gap: 4px; }
html[data-sb="mini"] .is-app .sb-collapse svg { transform: scaleX(-1); }

/* tablets and phones: the sidebar becomes a drawer */
@media (max-width: 960px) {
  body.is-app, html[data-sb="mini"] body.is-app { --sb-w: 0px; }  /* also when collapsed (the editor's default) */
  .sidebar { width: min(300px, 86vw); transform: translateX(-105%); transition: transform var(--dur-3) var(--ease-out); box-shadow: var(--shadow-3); background: var(--surface); }
  html.nav-open .sidebar { transform: none; }
  html.nav-open .sb-scrim { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(5, 8, 18, .5); }
  .sb-collapse { display: none; }
  html[data-sb="mini"] .is-app .sb-text, html[data-sb="mini"] .is-app .sb-label { position: static; width: auto; height: auto; clip: auto; }
  html[data-sb="mini"] .is-app .sb-nav a, html[data-sb="mini"] .is-app .sb-btn { justify-content: flex-start; padding: 0 12px; }
  html[data-sb="mini"] .is-app .sb-head { flex-direction: row; }
  html[data-sb="mini"] .is-app .sb-head .brand { width: auto; flex: 1; }
  .mtop { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px; padding-top: calc(8px + env(safe-area-inset-top));
    background: var(--surface-glass); border-bottom: 1px solid var(--line); }
  .mtop .brand { flex: 1; display: flex; text-decoration: none; }
}

/* ---------- full-width page containers ---------- */
.app-content > main.page, .app-content > main.page.wide { max-width: 1760px; margin: 0 auto; padding: clamp(16px, 2vw, 30px) clamp(14px, 2.4vw, 40px) 56px; }
.public-content > main.page { max-width: 1320px; padding: 0 clamp(16px, 3vw, 48px); }
.public-content > main.page.readable { max-width: 860px; }
main.page > .aurora { position: fixed; }

/* page header */
.pagehead { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: clamp(14px, 1.8vw, 24px); }
.pagehead-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--grad); color: var(--on-grad); box-shadow: 0 10px 28px rgba(16, 185, 129, .3); }
.pagehead-icon .ico { width: 22px; height: 22px; stroke-width: 2; }
.pagehead-text { flex: 1; min-width: 260px; }
.pagehead h1 { font-size: var(--fs-xl); margin: 0 0 6px; }
.pagehead .lede { color: var(--muted); max-width: 90ch; margin: 0; }
.pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }

/* tool pages: controls on the left, results on the right */
.tool-grid { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: clamp(16px, 2vw, 28px); align-items: start; }
.tool-grid.wide-side { grid-template-columns: minmax(380px, 1.1fr) minmax(320px, .9fr); }
.tool-side, .tool-main { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.tool-side > .card, .tool-main > .card, .tool-side > form.card { margin: 0; }
.tool-main > div > section.card, .tool-main > div > .card { margin-bottom: var(--s-4); }
.tool-side h2, .tool-main h2 { font-size: var(--fs-lg); }
.tool-empty { display: grid; place-items: center; text-align: center; min-height: min(62vh, 560px); padding: 40px 24px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface-glass); color: var(--muted); }
.tool-empty .illus { width: min(220px, 60%); height: auto; margin: 0 auto 14px; }
.tool-empty h2 { color: var(--fg); margin-bottom: 6px; }
.tool-empty p { max-width: 46ch; margin: 0 auto; }
@media (max-width: 1100px) { .tool-grid, .tool-grid.wide-side { grid-template-columns: minmax(0, 1fr); } .tool-empty { min-height: 260px; } }

/* dashboard uses the whole width */
.app-content .dash-grid { grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 360px); }
.app-content .cvgrid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@media (max-width: 1100px) { .app-content .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* settings: two columns of cards */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: var(--s-4); align-items: start; }
.settings-grid > .card { margin: 0; }
/* headings inside app cards are section titles, a step below the page title (low specificity: cards that set their own size win) */
:where(.app-content .card) h2 { font-size: var(--fs-lg); }

/* events */
.events.events-page { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }

/* kanban fills the width */
.app-content .kanban { grid-template-columns: repeat(5, minmax(240px, 1fr)); }

/* ---------- editor in the shell ---------- */
.is-app .editor { grid-template-columns: minmax(380px, 42%) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.is-app .editor .panel { padding: 0 clamp(14px, 1.6vw, 24px) 24px; }
.sectabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; overflow-x: auto; margin: 0 calc(-1 * clamp(14px, 1.6vw, 24px)) 14px; padding: 10px clamp(14px, 1.6vw, 24px);
  background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.sectabs::-webkit-scrollbar { display: none; }
.sectabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font: 500 var(--fs-sm) var(--font-ui); white-space: nowrap; border: 1px solid transparent; }
.sectabs a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sectabs a:hover { color: var(--fg); background: var(--tint-info); }
.sectabs a.on { color: var(--accent); background: var(--tint-ok); border-color: rgba(16, 185, 129, .35); }
.editor .preview { background-color: var(--bg-2); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; padding: clamp(12px, 1.4vw, 22px); }
.editor .preview iframe { border-radius: 14px; }
@media (max-width: 960px) { .is-app .editor { grid-template-columns: 1fr; height: auto; } .is-app .editor iframe { height: 75vh; } .sectabs { top: 58px; } }

/* ---------- pricing notes, sign-up code, link buttons (any page) ---------- */
.linkbtn { display: inline; min-height: 0; padding: 0 2px; border: 0; border-radius: 4px; background: none; box-shadow: none; color: var(--accent);
  font: 600 inherit/inherit var(--font-ui); text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { background: none; box-shadow: none; transform: none; filter: none; color: var(--accent-strong); }
.linkbtn:disabled { color: var(--muted); text-decoration: none; opacity: 1; }
.price-note { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line-strong); border-left: 4px solid var(--emerald); border-radius: var(--r-sm);
  background: var(--tint-ok); color: var(--fg); font-size: var(--fs-sm); line-height: 1.5; }
.price-note strong { display: block; margin-bottom: 2px; }
.auth .otp { font: 700 1.6rem/1 var(--font-display); letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.small-print { font-size: var(--fs-xs); margin-top: 12px; }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-4); max-width: 920px; margin: 0 auto; }
.plan { position: relative; padding: 22px 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.plan.paid { border-color: var(--emerald); box-shadow: var(--glow); }
.plan h3 { margin: 0 0 4px; }
.plan .amount { font: 800 var(--fs-xl)/1.1 var(--font-display); margin: 6px 0 2px; }
.plan .per { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 14px; }
.plan ul { margin: 0; padding-left: 1.2em; } .plan li { margin: 6px 0; }
.price-why { max-width: 720px; margin: var(--s-5) auto 0; text-align: center; }
.pay-rows { display: grid; gap: 12px; max-width: 980px; }
.pay-row.card { margin: 0; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 18px; }
.pay-row p { margin: 0 0 4px; } .pay-amount b { font: 700 var(--fs-lg) var(--font-display); margin-right: 8px; }
.pay-utr b { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.pay-actions { display: flex; gap: 8px; }

/* ---------- print: only the content ---------- */
@media print { .sidebar, .sb-scrim, .mtop, nav.top, .skip, .toasts { display: none !important; } .app-body { margin: 0 !important; } body::after, body::before, .aurora { display: none !important; } }
.sb-head .logo, .mtop .logo { max-width: none; }
@media (max-width: 640px) { .newtile { min-height: 110px; } }
.is-app .editor .panel { scroll-padding-top: 72px; } .is-app .editor .panel .entry, .is-app .editor details.sec { scroll-margin-top: 72px; }
