@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --canvas: #120f18;
  --surface: #1b1722;
  --surface-raised: #25202f;
  --surface-soft: #30263c;
  --line: #3a3148;
  --line-strong: #534466;
  --text: #f4f1f7;
  --text-soft: #c4bdca;
  --muted: #958d9b;
  --accent: #c49ae8;
  --accent-bright: #dfc2f7;
  --accent-deep: #875bab;
  --accent-wash: rgba(190, 139, 231, .15);
  --success: #89c6a3;
  --error: #f0a4a4;
  --error-bg: rgba(167, 61, 70, .14);
  --focus: #d8b5f3;
  --shadow: 0 24px 70px rgba(0, 0, 0, .27);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Manrope', 'DM Sans', sans-serif;
  --sidebar-width: 254px;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; color: var(--text); background: var(--canvas); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.brand-mark { display: inline-grid; flex: 0 0 auto; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(218, 187, 239, .36); border-radius: 12px; color: #f1dfff; background: linear-gradient(145deg, #392b45, #211c27 72%); box-shadow: inset 0 1px rgba(255,255,255,.08); font-family: var(--font-display); font-size: 15px; font-weight: 800; letter-spacing: -.07em; }
.wordmark { display: flex; align-items: center; gap: 12px; }
.wordmark strong { display: block; font-family: var(--font-display); font-size: 18px; letter-spacing: -.045em; line-height: 1.1; font-weight: 800; }
.wordmark small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .015em; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.button { display: inline-flex; min-height: 48px; justify-content: center; align-items: center; gap: 9px; padding: 0 19px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 700; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .75; }
.button-primary { border-color: #b991d6; color: #17121c; background: linear-gradient(135deg, #d0afe8, #ad80cf); box-shadow: 0 7px 18px rgba(138, 93, 171, .18); }
.button-primary:hover:not(:disabled) { background: #dfc3f3; }
.button-full { width: 100%; }
.button-spinner, .spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.22); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }
.button-spinner { border-color: rgba(31, 23, 37, .28); border-top-color: #201629; }
.spinner { color: var(--accent-bright); }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.alert-error { border: 1px solid rgba(222, 125, 132, .28); color: #f1c5c7; background: var(--error-bg); }
.route-loader, .app-loading { display: grid; min-height: 100vh; place-items: center; }
.route-status, .app-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.route-status p, .app-loading p { margin: 6px 0; }
.route-status .brand-mark, .app-loading .brand-mark { margin-bottom: 5px; }
.access-error { display: flex; width: min(440px, calc(100vw - 40px)); flex-direction: column; align-items: flex-start; gap: 13px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.access-error h1 { margin: 0; font: 700 26px/1.2 var(--font-display); }
.access-error p { margin: 0 0 8px; color: var(--text-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* v0.3.2 theme controls and iOS form behavior */
input, textarea, select { font-size: 16px; }
.theme-toggle { display:inline-grid; width:38px; height:38px; flex:0 0 auto; place-items:center; border:1px solid var(--line); border-radius:10px; color:var(--text-soft); background:var(--surface); cursor:pointer; font-size:17px; }
.theme-toggle:hover { border-color:var(--line-strong); color:var(--text); background:var(--surface-raised); }

:root[data-theme="light"] {
  color-scheme: light;
  --canvas:#f5f1f8;
  --surface:#ffffff;
  --surface-raised:#f0e8f5;
  --surface-soft:#e8dcef;
  --line:#d8cce0;
  --line-strong:#bda7cb;
  --text:#241c2a;
  --text-soft:#514758;
  --muted:#766b7c;
  --accent:#8152a6;
  --accent-bright:#6d3d94;
  --accent-deep:#5f367d;
  --accent-wash:rgba(129,82,166,.11);
  --success:#397657;
  --error:#a5424e;
  --error-bg:rgba(167,61,70,.09);
  --focus:#8152a6;
  --shadow:0 24px 60px rgba(65,44,78,.13);
}
:root[data-theme="light"] body,
:root[data-theme="light"] .dashboard-page { background:var(--canvas); color:var(--text); }
:root[data-theme="light"] .brand-mark { color:#5e347c; background:linear-gradient(145deg,#efe2f7,#dfcee9 72%); border-color:#c8add9; }
:root[data-theme="light"] .button-primary { color:#fff; background:linear-gradient(135deg,#9664ba,#754699); border-color:#8152a6; }
:root[data-theme="light"] .button-primary:hover:not(:disabled) { background:#70418f; }
:root[data-theme="light"] .sidebar { background:linear-gradient(180deg,#f2eaf6,#e9dfee); border-color:var(--line); }
:root[data-theme="light"] .topbar { background:rgba(250,247,252,.94); border-color:var(--line); }
:root[data-theme="light"] .menu-toggle,
:root[data-theme="light"] .theme-toggle { color:#4d4054; background:#fff; border-color:var(--line); }
:root[data-theme="light"] .breadcrumb,
:root[data-theme="light"] .breadcrumb span { color:#746a7a; }
:root[data-theme="light"] .breadcrumb strong,
:root[data-theme="light"] .breadcrumb a { color:#3b3041; }
:root[data-theme="light"] .nav-link { color:#625768; }
:root[data-theme="light"] .nav-link:hover { color:#3b2c43; background:rgba(129,82,166,.08); }
:root[data-theme="light"] .nav-link.is-active { color:#5d347a; background:rgba(129,82,166,.12); border-color:rgba(129,82,166,.22); }
:root[data-theme="light"] .surface-card,
:root[data-theme="light"] .organization-card,
:root[data-theme="light"] .workspace-summary-card,
:root[data-theme="light"] .enabled-module-card,
:root[data-theme="light"] .menu-category-card { color:var(--text); background:linear-gradient(135deg,#fff,#f4edf7); border-color:var(--line); }
:root[data-theme="light"] .organization-card h3,
:root[data-theme="light"] .section-heading h2,
:root[data-theme="light"] .card-heading h2,
:root[data-theme="light"] .workspace-heading h1,
:root[data-theme="light"] .module-card-copy strong { color:var(--text); }
:root[data-theme="light"] .organization-card p,
:root[data-theme="light"] .workspace-heading p,
:root[data-theme="light"] .module-card-copy small { color:var(--muted); }
:root[data-theme="light"] .forge-dialog { color:var(--text); background:linear-gradient(155deg,#fff,#f4edf8 65%,#eee3f3); border-color:#b99acb; box-shadow:0 28px 80px rgba(54,34,65,.24); }
:root[data-theme="light"] .form-field input,
:root[data-theme="light"] .form-field textarea { color:var(--text); background:#fff; border-color:#cbb8d5; }
:root[data-theme="light"] .form-field label,
:root[data-theme="light"] .toggle-field legend,
:root[data-theme="light"] .switch-row strong { color:#33263a; }
:root[data-theme="light"] .toggle-field { background:rgba(129,82,166,.04); border-color:#d3c0dd; }
:root[data-theme="light"] .toggle-field > p,
:root[data-theme="light"] .switch-row small,
:root[data-theme="light"] .field-hint { color:#74697a; }
:root[data-theme="light"] .menu-item-card { background:linear-gradient(115deg,#fff,#f2eaf6); border-color:#d9cbe1; }
:root[data-theme="light"] .menu-item-titleline h4 { color:#2e2434; }
:root[data-theme="light"] .menu-item-description { color:#6d6272; }
:root[data-theme="light"] .category-description { color:#65596b; }
:root[data-theme="light"] .category-empty { background:#faf6fc; border-color:#cdb9d8; }
:root[data-theme="light"] .category-empty strong { color:#3a2d41; }
:root[data-theme="light"] .menu-concept-note { background:rgba(29,119,126,.06); }
:root[data-theme="light"] .auth-form-panel { background:var(--canvas); }
:root[data-theme="light"] .auth-card { background:#fff; border-color:var(--line); box-shadow:var(--shadow); }
:root[data-theme="light"] .auth-card h2,
:root[data-theme="light"] .auth-card label { color:var(--text); }
:root[data-theme="light"] .auth-card input { color:var(--text); background:#fff; border-color:#cbb8d5; }


/* v0.3.2 light-theme contrast refinements */
:root[data-theme="light"] .workspace-summary-card h2,
:root[data-theme="light"] .site-row-copy strong,
:root[data-theme="light"] .activity-empty p,
:root[data-theme="light"] .enabled-module-card strong { color:#241c2a; }
:root[data-theme="light"] .workspace-summary-card p,
:root[data-theme="light"] .site-row-copy small,
:root[data-theme="light"] .activity-empty small,
:root[data-theme="light"] .subtle-state { color:#625768; }
:root[data-theme="light"] .workspace-summary-card .eyebrow,
:root[data-theme="light"] .section-heading .eyebrow,
:root[data-theme="light"] .card-heading .eyebrow { color:#673586; }
:root[data-theme="light"] .summary-icon,
:root[data-theme="light"] .module-card-icon { color:#633681; background:#eadcf2; border-color:#bda3cc; }
:root[data-theme="light"] .site-state-pill,
:root[data-theme="light"] .access-label,
:root[data-theme="light"] .site-access { color:#2f6d4d; }
:root[data-theme="light"] .site-state-pill { background:#e8f3ec; border-color:#9fc3ae; }
:root[data-theme="light"] .site-glyph,
:root[data-theme="light"] .org-symbol,
:root[data-theme="light"] .count-badge { color:#5f347b; background:#eee4f3; border-color:#bca9c8; }
:root[data-theme="light"] .site-open-link { color:#5d347a; background:#eee2f4; border-color:#b89ac9; }
:root[data-theme="light"] .site-open-link:hover { color:#45245d; background:#e3d2ed; border-color:#9d78b3; }
:root[data-theme="light"] .site-row { border-color:#b9aebf; }
:root[data-theme="light"] .app-footer { color:#625768; border-color:#b9aebf; }
:root[data-theme="light"] .coming-soon-tag { color:#625768; border-color:#a99daf; background:#faf8fb; }
:root[data-theme="light"] .module-card-ready .module-card-copy small { color:#633681; }
