/* base.css v2.1 — FIFO-style structure. Colours come from /layout/<theme>/theme.css (variables --sh-*). */

:root {
  --sh-sidebar: 256px; --sh-topbar-h: 60px; --sh-radius: 10px;
  --sh-font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --sh-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sh-bg: #0b1020; --sh-bg-grad: #0b1020;
  --sh-surface: #121a2e; --sh-surface-2: #182340; --sh-surface-3: #1f2b4d;
  --sh-border: rgba(255,255,255,.09);
  --sh-text: #e7ecf5; --sh-text-2: #c3cbdb; --sh-muted: #96a2b8;
  --sh-accent: #2ecc71; --sh-accent-ink: #06130b; --sh-info: #3498db; --sh-warn: #f39c12; --sh-danger: #e74c3c;
  --sh-shadow: 0 8px 24px rgba(0,0,0,.28); --sh-blur: none;
}

/* ---------- page frame ---------- */
body[data-shell] { margin: 0; background: var(--sh-bg-grad); background-attachment: fixed; color: var(--sh-text); font-family: var(--sh-font); padding-left: var(--sh-sidebar); min-height: 100vh; -webkit-font-smoothing: antialiased; }
body[data-shell] > *:not(.topbar):not(script):not(style):not(link) { max-width: 1240px; margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; box-sizing: border-box; }
body[data-shell] a { color: var(--sh-info); }
body[data-shell] h1, body[data-shell] h2, body[data-shell] h3 { color: var(--sh-text); letter-spacing: -0.01em; }
body[data-shell] code, body[data-shell] pre { font-family: var(--sh-mono); }
body[data-shell] ::selection { background: color-mix(in srgb, var(--sh-accent) 35%, transparent); }

/* ---------- sidebar ---------- */
body[data-shell] .topbar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sh-sidebar); background: var(--sh-surface); border-right: 1px solid var(--sh-border); border-bottom: 0; overflow-y: auto; z-index: 60; padding: 0; box-shadow: none; backdrop-filter: var(--sh-blur); max-width: none; }
body[data-shell] .topbar-inner { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding: 18px 14px 16px; max-width: none; width: auto; min-height: 100%; box-sizing: border-box; }
body[data-shell] .brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--sh-text); padding: 4px 8px 12px; border-bottom: 1px solid var(--sh-border); }
body[data-shell] .brand-title { font-weight: 900; font-size: 18px; letter-spacing: -0.01em; }
body[data-shell] .brand-sub { font-size: 11px; color: var(--sh-muted); }
body[data-shell] .topbar-right { display: flex; flex-direction: column; align-items: stretch; gap: 12px; flex: 1; }
body[data-shell] .nav { display: flex; flex-direction: column; gap: 2px; order: -1; }
body[data-shell] .nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sh-text-2); text-decoration: none; font-weight: 600; font-size: 14px; background: transparent; border: 0; }
body[data-shell] .nav a .sh-ico { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
body[data-shell] .nav a:hover { background: var(--sh-surface-2); color: var(--sh-text); }
body[data-shell] .nav a.active, body[data-shell] .nav a[aria-current="page"] { background: color-mix(in srgb, var(--sh-accent) 16%, transparent); color: var(--sh-accent); }
body[data-shell] .sh-group { margin: 10px 4px 2px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--sh-muted); font-weight: 700; }
body[data-shell] .menu-btn { display: none; }
body[data-shell] .sh-theme-mobile { display: none; }
body[data-shell] .sh-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sh-border); display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--sh-muted); }
body[data-shell] .sh-footer select { width: 100%; margin-top: 4px; }

/* ---------- components ---------- */
body[data-shell] .card { background: var(--sh-surface); border: 1px solid var(--sh-border); border-radius: var(--sh-radius); box-shadow: var(--sh-shadow); backdrop-filter: var(--sh-blur); color: var(--sh-text); }
body[data-shell] .card .card { box-shadow: none; background: var(--sh-surface-2); }
body[data-shell] .btn, body[data-shell] button:not(.menu-btn):not(.unstyled) { background: var(--sh-surface-2); color: var(--sh-text); border: 1px solid var(--sh-border); border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; transition: background .15s, transform .05s; }
body[data-shell] .btn:hover, body[data-shell] button:not(.menu-btn):hover { background: var(--sh-surface-3); }
body[data-shell] .btn:active { transform: translateY(1px); }
body[data-shell] .btn.good, body[data-shell] button.good { background: var(--sh-accent); color: var(--sh-accent-ink); border-color: transparent; }
body[data-shell] .btn.danger, body[data-shell] button.danger { background: var(--sh-danger); color: #fff; border-color: transparent; }
body[data-shell] .btn[disabled], body[data-shell] button[disabled] { opacity: .55; cursor: not-allowed; }
body[data-shell] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), body[data-shell] select, body[data-shell] textarea { background: var(--sh-bg); color: var(--sh-text); border: 1px solid var(--sh-border); border-radius: 8px; padding: 8px 10px; font: inherit; }
body[data-shell] input:focus, body[data-shell] select:focus, body[data-shell] textarea:focus { outline: 2px solid color-mix(in srgb, var(--sh-accent) 55%, transparent); outline-offset: 1px; }
body[data-shell] table { border-collapse: collapse; width: 100%; }
body[data-shell] th, body[data-shell] td { padding: 8px 10px; border-bottom: 1px solid var(--sh-border); text-align: left; }
body[data-shell] thead th { color: var(--sh-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
body[data-shell] tbody tr:hover { background: color-mix(in srgb, var(--sh-surface-2) 60%, transparent); }
body[data-shell] .muted { color: var(--sh-muted); }
body[data-shell] .small { font-size: 12px; }
body[data-shell] hr.sep { border: 0; border-top: 1px solid var(--sh-border); margin: 12px 0; }
body[data-shell] pre { border-radius: 8px; }

/* ---------- mobile: fixed top bar + theme select + overlay drawer ---------- */
@media (max-width: 900px) {
  body[data-shell] { padding-left: 0; padding-top: var(--sh-topbar-h); }
  body[data-shell] > *:not(.topbar):not(script):not(style):not(link) { padding-left: 14px; padding-right: 14px; }
  body[data-shell] .topbar { position: fixed; top: 0; left: 0; right: 0; bottom: auto; width: auto; height: var(--sh-topbar-h); border-right: 0; border-bottom: 1px solid var(--sh-border); overflow: visible; }
  body[data-shell] .topbar-inner { flex-direction: row; align-items: center; gap: 8px; height: var(--sh-topbar-h); min-height: 0; padding: 0 12px; }
  body[data-shell] .brand { border-bottom: 0; padding: 0; flex: 1; min-width: 0; }
  body[data-shell] .brand-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body[data-shell] .brand-sub { display: none; }
  body[data-shell] .sh-theme-mobile { display: inline-block; width: auto; max-width: 120px; padding: 6px 8px; font-size: 12px; margin-left: auto; }
  body[data-shell] .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: 0; background: var(--sh-surface-2); border: 1px solid var(--sh-border); border-radius: 8px; color: var(--sh-text); cursor: pointer; position: relative; }
  body[data-shell] .menu-btn .menu-icon, body[data-shell] .menu-btn .menu-icon::before, body[data-shell] .menu-btn .menu-icon::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; content: ""; position: absolute; left: 10px; }
  body[data-shell] .menu-btn .menu-icon { top: 19px; }
  body[data-shell] .menu-btn .menu-icon::before { top: -6px; left: 0; }
  body[data-shell] .menu-btn .menu-icon::after { top: 6px; left: 0; }
  body[data-shell].sh-open .menu-btn .menu-icon { background: transparent; }
  body[data-shell].sh-open .menu-btn .menu-icon::before { transform: translateY(6px) rotate(45deg); }
  body[data-shell].sh-open .menu-btn .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }
  body[data-shell] .topbar-right { display: none; position: fixed; top: var(--sh-topbar-h); left: 0; right: 0; bottom: 0; background: var(--sh-surface); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 24px; gap: 12px; z-index: 70; box-sizing: border-box; }
  body[data-shell].sh-open .topbar-right { display: flex; flex-direction: column; animation: shSlide .18s ease-out; }
  body[data-shell].sh-open { overflow: hidden; }
  body[data-shell] .nav a { padding: 12px 14px; font-size: 16px; }
  body[data-shell] .sh-footer { margin-top: 12px; }
  @keyframes shSlide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
  /* 3D page: stack canvas + info on phones */
  body[data-shell] #t3d { height: 55vh !important; }
  body[data-shell] #t3d-info { max-height: none !important; }
}
@media (max-width: 900px) { body[data-shell] [style*="grid-template-columns:1fr 300px"] { grid-template-columns: 1fr !important; } }
