/* ============================================================
   Solar Sim ? Premium Design System
   8px grid ? Restrained palette ? 150ms transitions
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
  --s-bg:       #f7f8fa;
  --s-surface:  #ffffff;
  --s-border:   #e2e6ea;
  --s-text:     #1e293b;
  --s-muted:    #64748b;
  --s-accent:   #2563eb;
  --s-accent-h: #1d4ed8;
  --s-green:    #16a34a;
  --s-amber:    #d97706;
  --s-red:      #dc2626;
  --s-orange:   #ea580c;
  --s-radius:   8px;
  --s-shadow:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --s-shadow-lg:0 4px 12px rgba(0,0,0,.08);
  --s-font:     'Inter', system-ui, -apple-system, sans-serif;
  --s-mono:     'JetBrains Mono', ui-monospace, monospace;
  --s-ease:     cubic-bezier(.4,0,.2,1);
}

/* --- Base ------------------------------------------------- */
html { font-size: 14px; position: relative; min-height: 100%; overflow-x: hidden; }
@media (min-width: 768px) { html { font-size: 15px; } }

body {
  font-family: var(--s-font);
  color: var(--s-text);
  background: var(--s-bg);
  margin: 0; padding: 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

/* --- 8px grid spacing helpers ----------------------------- */
.gap-8  { gap: 8px !important; }
.gap-16 { gap: 16px !important; }
.gap-24 { gap: 24px !important; }
.p-8  { padding: 8px !important; }
.p-16 { padding: 16px !important; }
.p-24 { padding: 24px !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mb-32 { margin-bottom: 32px !important; }

/* --- Skip link (WCAG 2.4.1) ------------------------------ */
.s-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #2563eb;
  color: #fff;
  padding: 8px 16px;
  z-index: 10000;
  font-size: 14px;
  text-decoration: none;
  transition: top 0.2s;
}
.s-skip-link:focus {
  top: 0;
}

/* --- Focus-visible (keyboard accessibility) -------------- */
.s-back-btn:focus-visible,
.s-wiz-btn:focus-visible,
button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* --- Premium Navbar --------------------------------------- */

/* --- Back-to-main bar (sub-pages) --- */
.s-back-bar {
  background: #f8fafc;
  border-bottom: 1px solid var(--s-border);
  padding: 8px 24px;
}
.s-back-btn {
  background: none; border: none; cursor: pointer;
  color: #2563eb; font-size: .85rem; font-weight: 500;
  padding: 4px 8px; border-radius: 4px;
  transition: background 120ms ease;
}
.s-back-btn:hover { background: #e0e7ff; }

.s-navbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 100;
}
.s-navbar-brand {
  font-weight: 700; font-size: 1.1rem;
  color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.s-brand-logo {
  width: 28px; height: 28px; flex-shrink: 0;
}
.s-brand-text {
  font-family: 'Inter', 'Helvetica Neue', sans-serif;
  font-weight: 700; letter-spacing: -0.02em;
}
.s-brand-text .s-brand-hinata { color: #fbbf24; }
.s-brand-text .s-brand-cast   { color: #fff; }
.s-navbar-help {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 150ms var(--s-ease);
}
.s-navbar-help:hover { background: rgba(255,255,255,.18); color: #fff; }
.s-navbar-wizard-btn {
  background: rgba(251,191,36,.18);
  border-color: rgba(251,191,36,.5);
  color: #fbbf24;
}
.s-navbar-wizard-btn:hover { background: rgba(251,191,36,.3); color: #fde68a; }
.s-navbar-help span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.2); font-weight: 700; font-size: .7rem;
}
/* --- Hamburger menu (mobile) ----- */
.s-navbar-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  padding: 8px; flex-direction: column; gap: 4px; z-index: 102;
  min-width: 44px; min-height: 44px;
}
.s-navbar-hamburger span {
  display: block; width: 22px; height: 2px; background: #e2e8f0;
  border-radius: 2px; transition: transform 200ms, opacity 200ms;
}
.s-navbar-hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.s-navbar-hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.s-navbar-hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.s-navbar-links { display: flex; align-items: center; gap: 8px; }

@media (max-width: 768px) {
  .s-navbar-hamburger { display: flex; }
  .s-navbar-links {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 101;
  }
  .s-navbar-links.open { display: flex; }
  .s-navbar-links .s-navbar-help { width: 100%; justify-content: flex-start; }
}

/* --- Card system ------------------------------------------ */
.s-card {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius);
  box-shadow: var(--s-shadow);
  transition: box-shadow 150ms var(--s-ease);
  overflow: visible;
}
.s-card:hover { box-shadow: var(--s-shadow-lg); }

.s-card-header {
  padding: 12px 16px;
  font-weight: 600; font-size: .85rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--s-border);
  background: #f8fafc;
  color: var(--s-muted);
  display: flex; align-items: center; gap: 8px;
}
.s-card-body { padding: 16px; }

/* --- Collapsible card (details/summary) ------------------- */
details.s-card { }
details.s-card > summary.s-card-header {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.s-card > summary.s-card-header::-webkit-details-marker { display: none; }
details.s-card > summary.s-card-header::after {
  content: '?';
  margin-left: auto;
  font-size: .82rem;
  transition: transform 150ms var(--s-ease);
  color: var(--s-muted);
}
details.s-card[open] > summary.s-card-header::after {
  transform: rotate(90deg);
}

/* --- Section headers -------------------------------------- */
.s-section-icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: .75rem;
  flex-shrink: 0;
}
.s-section-icon.env   { background: #dbeafe; color: #2563eb; }
.s-section-icon.home  { background: #dcfce7; color: #16a34a; }
.s-section-icon.panel { background: #fef3c7; color: #d97706; }
.s-section-icon.prop  { background: #f1f5f9; color: #475569; }

/* --- Form rows: label left / input right ------------------ */
.s-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 0;
}
.s-form-row + .s-form-row { border-top: 1px solid #f1f5f9; }
.s-form-label {
  flex: 0 0 auto;
  font-size: .8rem;
  color: var(--s-muted);
  white-space: nowrap;
  min-width: 64px;
}
.s-form-input {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.s-form-input input,
.s-form-input select {
  width: 100%;
  border: 1px solid var(--s-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: .82rem;
  background: #fff;
  color: var(--s-text);
  transition: border-color 150ms var(--s-ease), box-shadow 150ms var(--s-ease);
}
.s-form-input input:focus,
.s-form-input select:focus {
  border-color: var(--s-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.s-form-input input:focus:not(:focus-visible),
.s-form-input select:focus:not(:focus-visible) {
  outline: none;
}
.s-unit {
  font-size: .75rem;
  color: var(--s-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 28px;
  text-align: left;
}

/* --- KPI Cards -------------------------------------------- */
.s-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.s-kpi {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius);
  padding: 20px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 150ms var(--s-ease), box-shadow 150ms var(--s-ease);
}
.s-kpi:hover { transform: translateY(-2px); box-shadow: var(--s-shadow-lg); }
.s-kpi-value {
  font-size: 2rem; font-weight: 700; line-height: 1.1;
  font-family: var(--s-mono);
}
.s-kpi-unit { font-size: .85rem; font-weight: 400; color: var(--s-muted); margin-left: 4px; }
.s-kpi-label {
  font-size: .78rem; color: var(--s-muted);
  margin-top: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.s-kpi.green  .s-kpi-value { color: var(--s-green); }
.s-kpi.blue   .s-kpi-value { color: var(--s-accent); }
.s-kpi.amber  .s-kpi-value { color: var(--s-amber); }
.s-kpi.orange .s-kpi-value { color: var(--s-orange); }
.s-kpi-stripe {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.s-kpi.green  .s-kpi-stripe { background: var(--s-green); }
.s-kpi.blue   .s-kpi-stripe { background: var(--s-accent); }
.s-kpi.amber  .s-kpi-stripe { background: var(--s-amber); }
.s-kpi.orange .s-kpi-stripe { background: var(--s-orange); }

/* --- Tooltip ---------------------------------------------- */
.s-tip {
  position: relative; cursor: help;
  border-bottom: 1px dotted var(--s-muted);
}
.s-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) scale(.95);
  background: #1e293b; color: #fff;
  font-size: .82rem; line-height: 1.4;
  padding: 6px 10px; border-radius: 6px;
  white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity 150ms var(--s-ease), transform 150ms var(--s-ease);
  z-index: 50;
}
.s-tip:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* --- Fixed Action Button ---------------------------------- */
.s-fab-wrap {
  position: fixed; bottom: 24px; right: 24px; z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  max-width: min(420px, calc(100vw - 48px));
}
.s-fab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 28px;
  font-size: .95rem; font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: none; border-radius: 50px;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  cursor: pointer;
  transition: transform 150ms var(--s-ease), box-shadow 150ms var(--s-ease);
}
.s-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,.45);
}
.s-fab:active { transform: translateY(0); }
.s-fab.s-fab-pulse {
  animation: s-fabPulse 600ms ease-in-out 5;
}
@keyframes s-fabPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 14px rgba(37,99,235,.35); }
  50%      { transform: scale(1.08); box-shadow: 0 6px 24px rgba(37,99,235,.55); }
}
.s-fab-hint {
  font-size: .82rem; color: var(--s-muted);
  background: var(--s-surface); padding: 3px 10px;
  border-radius: 20px; box-shadow: var(--s-shadow);
  white-space: nowrap;
}
.s-fab-notice {
  font-size: .82rem; color: #92400e; background: #fef3c7;
  padding: 5px 12px; border-radius: 8px; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  max-width: 480px; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* --- Consent Modal ---------------------------------------- */
.s-consent-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: s-consentFadeIn 200ms ease-out;
}
@keyframes s-consentFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.s-consent-dialog {
  background: #fff; border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  max-width: 480px; width: calc(100% - 32px);
  animation: s-consentSlideUp 250ms ease-out;
}
@keyframes s-consentSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.s-consent-header {
  font-size: 1rem; font-weight: 700; color: #1e293b;
  padding: 20px 24px 0;
}
.s-consent-body {
  padding: 16px 24px;
}
.s-consent-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 24px 20px; border-top: 1px solid var(--s-border);
}
.s-consent-cancel {
  padding: 8px 20px; font-size: .85rem; font-weight: 500;
  background: var(--s-surface); border: 1px solid var(--s-border);
  border-radius: 8px; cursor: pointer; color: #64748b;
  transition: background 150ms;
}
.s-consent-cancel:hover { background: #f1f5f9; }
.s-consent-submit {
  padding: 8px 24px; font-size: .85rem; font-weight: 600;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
  transition: opacity 150ms, transform 150ms;
}
.s-consent-submit:disabled {
  opacity: .4; cursor: not-allowed; transform: none;
}
.s-consent-submit:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

/* --- Result section fade-in ------------------------------- */
/* --- Onboarding Coach Mark -------------------------------- */
.s-coach-mark {
  position: fixed; bottom: 80px; right: 24px; z-index: 89;
  max-width: 440px; width: calc(100% - 48px);
  animation: s-coachFadeIn 400ms var(--s-ease) both;
}
.s-coach-mark-content {
  display: flex; align-items: flex-start; gap: 12px;
  background: #1e3a5f; color: #fff; border-radius: 12px;
  padding: 16px 20px; box-shadow: 0 8px 32px rgba(0,0,0,.25);
  font-size: .85rem; line-height: 1.6;
}
.s-coach-mark-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.s-coach-mark-text { flex: 1; }
.s-coach-mark-text strong { color: #93c5fd; }
.s-coach-mark-close {
  background: none; border: none; color: rgba(255,255,255,.6);
  cursor: pointer; font-size: 1rem; padding: 0 0 0 8px; flex-shrink: 0;
}
.s-coach-mark-close:hover { color: #fff; }
@keyframes s-coachFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.s-coach-mark.s-coach-out {
  animation: s-coachFadeOut 300ms var(--s-ease) both;
}
@keyframes s-coachFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

/* --- Interactive Tutorial --------------------------------- */
.s-tut-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(15,23,42,.45);
  pointer-events: none;
  transition: opacity 200ms var(--s-ease);
}
.s-tut-highlight {
  position: absolute; z-index: 8001;
  border: 3px solid var(--s-accent);
  border-radius: var(--s-radius);
  box-shadow: 0 0 0 4000px rgba(15,23,42,.4), 0 0 24px rgba(37,99,235,.35);
  pointer-events: none;
  transition: all 300ms var(--s-ease);
  animation: s-tutPulse 2s ease-in-out infinite;
}
@keyframes s-tutPulse {
  0%, 100% { box-shadow: 0 0 0 4000px rgba(15,23,42,.4), 0 0 24px rgba(37,99,235,.35); }
  50%      { box-shadow: 0 0 0 4000px rgba(15,23,42,.4), 0 0 36px rgba(37,99,235,.55); }
}
.s-tut-tooltip {
  position: absolute; z-index: 8002;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f1f5f9;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  max-width: 360px; width: max-content;
  animation: s-tutFadeIn 250ms var(--s-ease);
}
@keyframes s-tutFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.s-tut-title {
  font-size: 1rem; font-weight: 700;
  color: #93c5fd;
  margin-bottom: 8px;
}
.s-tut-desc {
  font-size: .82rem; line-height: 1.7;
  color: #cbd5e1;
  white-space: pre-line;
}
.s-tut-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.s-tut-progress {
  font-size: .82rem; color: #64748b;
  font-family: var(--s-mono);
}
.s-tut-btns { display: flex; gap: 8px; }
.s-tut-skip {
  background: transparent; border: 1px solid rgba(255,255,255,.15);
  color: #94a3b8; padding: 6px 14px; border-radius: 8px;
  font-size: .78rem; font-weight: 500; cursor: pointer;
  transition: all 150ms var(--s-ease);
}
.s-tut-skip:hover { border-color: rgba(255,255,255,.3); color: #e2e8f0; }
.s-tut-next {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none; color: #fff; padding: 6px 18px;
  border-radius: 8px; font-size: .78rem; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 8px rgba(37,99,235,.3);
  transition: all 150ms var(--s-ease);
}
.s-tut-next:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transform: translateY(-1px);
}

.s-result-section {
  animation: s-fadeUp 300ms var(--s-ease) both;
}
@keyframes s-fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Chart container -------------------------------------- */
.s-chart-wrap {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--s-radius);
  padding: 16px;
}
.s-chart-title {
  font-size: .82rem; font-weight: 600; color: var(--s-muted);
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: .03em;
}

/* --- Mini bar chart (CSS only) ---------------------------- */
.s-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
}
.s-bar-label { width: 32px; font-size: .75rem; color: var(--s-muted); text-align: right; }
.s-bar-track { flex: 1; height: 18px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.s-bar-fill  {
  height: 100%; border-radius: 4px;
  transition: width 400ms var(--s-ease);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px; font-size: .82rem; color: #fff; font-weight: 600;
}
.s-bar-fill.high   { background: linear-gradient(90deg, #22c55e, #16a34a); }
.s-bar-fill.medium { background: linear-gradient(90deg, #facc15, #eab308); color: #713f12; }
.s-bar-fill.low    { background: linear-gradient(90deg, #f87171, #dc2626); }

/* --- 3D Canvas -------------------------------------------- */
.s-canvas-wrap {
  border-radius: var(--s-radius);
  overflow: hidden;
  border: 1px solid var(--s-border);
  position: relative;
}
.s-canvas-badge {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  background: rgba(15,23,42,.7); color: #94a3b8;
  font-size: .82rem; padding: 4px 10px; border-radius: 20px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 200ms var(--s-ease);
}
.s-canvas-wrap:hover .s-canvas-badge { opacity: .4; }

/* Camera toolbar (bottom-left inside canvas) */
.s-cam-toolbar {
  position: absolute; bottom: 12px; left: 12px; z-index: 10;
  display: flex; align-items: center; gap: 2px;
  background: rgba(15,23,42,.75);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 3px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  opacity: .55;
  transition: opacity 200ms var(--s-ease);
}
.s-canvas-wrap:hover .s-cam-toolbar { opacity: 1; }
.s-cam-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
  padding: 0 7px;
  background: transparent;
  color: #cbd5e1;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  transition: all 120ms var(--s-ease);
  white-space: nowrap;
}
.s-cam-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.15);
}
.s-cam-btn:active { transform: scale(.93); }
.s-cam-icon { font-size: .9rem; line-height: 1; }
.s-cam-sep {
  width: 1px; height: 16px;
  background: rgba(255,255,255,.15);
  margin: 0 3px;
}
.s-cam-max {
  background: rgba(37,99,235,.3);
  color: #93c5fd;
  border-color: rgba(59,130,246,.3);
}
.s-cam-max:hover { background: rgba(37,99,235,.5); color: #fff; }

/* Floating help button (bottom-right of canvas) */
.s-help-fab {
  position: absolute; bottom: 14px; right: 14px; z-index: 10;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px 8px 12px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 24px;
  font-size: .82rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,.40), 0 0 0 0 rgba(37,99,235,.4);
  transition: all 200ms var(--s-ease);
  animation: s-help-pulse 2.5s ease-in-out 3;
}
.s-help-fab:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 6px 20px rgba(37,99,235,.50);
  transform: translateY(-1px) scale(1.04);
}
.s-help-fab:active { transform: scale(.96); }
.s-help-fab-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  font-size: .9rem; font-weight: 800;
  line-height: 1;
}
.s-help-fab-label { letter-spacing: .04em; }
@keyframes s-help-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(37,99,235,.40), 0 0 0 0 rgba(59,130,246,.5); }
  50% { box-shadow: 0 4px 14px rgba(37,99,235,.40), 0 0 0 8px rgba(59,130,246,0); }
}
.s-canvas-wrap:hover .s-help-fab { opacity: 1; }

/* Handle legend in action bar */
.s-handle-legend {
  font-size: .82rem; color: var(--s-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 1; min-width: 0;
}
.s-handle-legend kbd {
  display: inline-block;
  background: #f1f5f9; border: 1px solid var(--s-border);
  border-radius: 3px; padding: 0 4px;
  font-size: .82rem; font-weight: 600;
  font-family: inherit;
  color: var(--s-text);
  line-height: 1.6;
}

/* ======== Maximize / Fullscreen mode ======== */
.s-canvas-maximized {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9000 !important;
  background: #0f172a;
  display: flex;
  flex-direction: column;
}
.s-canvas-maximized .s-canvas-wrap {
  flex: 1;
  border: none;
  border-radius: 0;
}
/* canvas サイズは scene-editor.js の resizeRenderer() で直接管理 */
.s-canvas-maximized .s-action-bar {
  display: none;
}
.s-canvas-maximized .s-canvas-badge {
  top: 12px; right: 12px;
  font-size: .82rem; padding: 6px 14px;
}
.s-canvas-maximized .s-cam-toolbar {
  bottom: 16px; left: 16px;
  padding: 4px 6px;
  opacity: .7;
}

/* --- Inline validation ------------------------------------ */
.s-field-error {
  font-size: .82rem; color: var(--s-red);
  margin-top: 2px; padding-left: 2px;
}

/* --- Sidebar scrollable ----------------------------------- */
.s-sidebar {
  display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100vh - 88px); /* navbar 56px + page-padding 24px + 余白 8px */
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;          /* Firefox */
  scrollbar-color: #94a3b8 #f1f5f9;
}
.s-sidebar::-webkit-scrollbar { width: 6px; }
.s-sidebar::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.s-sidebar::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; min-height: 40px; }
.s-sidebar::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Compact sidebar cards */
.s-sidebar .s-card { margin: 0; }
.s-sidebar .s-card-header { padding: 5px 10px; font-size: .76rem; }
.s-sidebar .s-card-body { padding: 2px 10px 4px; }
.s-sidebar .s-form-row { min-height: 24px; padding: 1px 0; }
.s-sidebar .s-form-row + .s-form-row { border-top: none; }
.s-sidebar .s-form-input input,
.s-sidebar .s-form-input select { padding: 2px 6px; font-size: .78rem; }
.s-sidebar .s-form-label { font-size: .74rem; min-width: 48px; }
.s-sidebar .s-unit { font-size: .82rem; min-width: 20px; }
.s-sidebar .s-section-icon { width: 16px; height: 16px; font-size: .82rem; }
.s-sidebar .s-form-input label { white-space: nowrap; }

/* Sidebar sub-divider inside a card */
.s-econ-divider {
  font-size: .82rem;
  font-weight: 600;
  color: var(--s-muted, #6b7280);
  padding: 4px 0 2px;
  margin: 2px 0;
  border-top: 1px dashed var(--s-border, #e5e7eb);
}

/* --- Page layout ------------------------------------------ */
.s-page { padding: 24px; max-width: 1440px; margin: 0 auto; overflow-x: hidden; }
.s-page-title {
  font-size: 1.35rem; font-weight: 700; color: var(--s-text);
  display: flex; align-items: center; gap: 8px;
}
.s-page-sub { font-size: .82rem; color: var(--s-muted); }
.s-main-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
.s-main-grid > .s-sidebar {
  position: sticky;
  top: 72px;                  /* navbar 56px + 16px gap */
}
@media (max-width: 992px) {
  .s-main-grid { grid-template-columns: 1fr; }
}

/* --- Action bar (buttons row) ----------------------------- */
.s-action-bar {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center;
  padding: 8px 0;
}
.s-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: .82rem; font-weight: 500;
  border-radius: 6px; border: 1px solid var(--s-border);
  background: var(--s-surface); color: var(--s-text);
  cursor: pointer; white-space: nowrap; min-width: max-content;
  transition: all 150ms var(--s-ease);
}
.s-btn:hover { border-color: var(--s-accent); color: var(--s-accent); }
.s-btn.green { border-color: #bbf7d0; background: #f0fdf4; color: var(--s-green); }
.s-btn.green:hover { background: #dcfce7; }
.s-btn.red { border-color: #fecaca; background: #fef2f2; color: var(--s-red); }
.s-btn.red:hover:not(:disabled) { background: #fee2e2; }
.s-btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: auto; }

/* --- Collapse section header ------------------------------ */
.s-collapse-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  padding: 10px 16px;
  font-weight: 600; font-size: .82rem;
  color: var(--s-muted); text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--s-border);
  background: #f8fafc;
}
.s-collapse-header::after {
  content: '?'; margin-left: auto; font-size: .7rem;
  transition: transform 150ms var(--s-ease);
}
.s-collapse-header.collapsed::after { transform: rotate(-90deg); }

/* --- Override Bootstrap defaults for consistency ----------- */
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control, .form-select { font-size: .82rem; }

/* --- Panel Editor Overlay --------------------------------- */
.s-panel-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 150ms var(--s-ease);
}
.s-panel-dialog {
  background: var(--s-surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  display: flex; flex-direction: column;
}
.s-panel-dialog-header {
  padding: 16px 24px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--s-border);
}
.s-panel-dialog-header h3 {
  margin: 0; font-size: 1rem; font-weight: 700;
}
.s-panel-dialog-body {
  padding: 16px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.s-panel-dialog-body canvas {
  border-radius: 6px;
  cursor: crosshair;
}
.s-panel-dialog-footer {
  padding: 12px 24px 16px;
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--s-border);
}
.s-panel-legend {
  display: flex; gap: 16px; font-size: .75rem; color: var(--s-muted);
}
.s-panel-legend-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; vertical-align: middle; margin-right: 4px;
}

/* ============================================================
   Setup Wizard ? Premium Onboarding
   ============================================================ */
.s-wizard-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  opacity: 1;
  transition: opacity 500ms var(--s-ease);
}
.s-wizard-backdrop.s-wizard-hidden {
  opacity: 0; pointer-events: none;
}

.s-wizard-card {
  background: var(--s-surface);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  width: 100%; max-width: 560px;
  overflow: hidden;
  animation: s-wizardIn 400ms var(--s-ease) both;
}
@keyframes s-wizardIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* --- Progress strip --- */
.s-wizard-progress {
  display: flex; height: 4px; background: #e2e8f0;
}
.s-wizard-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 400ms var(--s-ease);
  border-radius: 0 2px 2px 0;
}

/* --- Header --- */
.s-wizard-header {
  padding: 32px 32px 0;
  text-align: center;
}
.s-wizard-icon {
  font-size: 2.8rem; line-height: 1;
  margin-bottom: 12px;
  display: block;
  animation: s-wizardPulse 2s ease-in-out infinite;
}
@keyframes s-wizardPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
.s-wizard-title {
  font-size: 1.35rem; font-weight: 700; color: var(--s-text);
  margin: 0 0 6px;
}
.s-wizard-sub {
  font-size: .85rem; color: var(--s-muted);
  margin: 0; line-height: 1.5;
}

/* --- Body --- */
.s-wizard-body {
  padding: 24px 32px 16px;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Step panels --- */
.s-wizard-step {
  display: none;
  animation: s-stepFade 300ms var(--s-ease) both;
}
.s-wizard-step.active { display: block; }
@keyframes s-stepFade {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* --- Wizard form rows --- */
.s-wiz-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
}
.s-wiz-row + .s-wiz-row { border-top: 1px solid #f1f5f9; }
.s-wiz-label {
  flex: 0 0 100px;
  font-size: .82rem; font-weight: 500;
  color: var(--s-text);
}
.s-wiz-input {
  flex: 1; display: flex; align-items: center; gap: 6px;
}
.s-wiz-input input,
.s-wiz-input select {
  width: 100%;
  border: 1px solid var(--s-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .88rem;
  background: #fff;
  color: var(--s-text);
  transition: border-color 150ms var(--s-ease), box-shadow 150ms var(--s-ease);
}
.s-wiz-input input:focus,
.s-wiz-input select:focus {
  border-color: var(--s-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.s-wiz-input input:focus:not(:focus-visible),
.s-wiz-input select:focus:not(:focus-visible) {
  outline: none;
}
.s-wiz-unit {
  font-size: .78rem; color: var(--s-muted);
  white-space: nowrap; flex-shrink: 0; min-width: 28px;
}
.s-wiz-hint {
  font-size: .82rem; color: var(--s-muted);
  margin: 4px 0 0 112px; line-height: 1.4;
}

/* --- Warning / info box --- */
.s-wiz-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .8rem; line-height: 1.55;
  margin-top: 12px;
}
.s-wiz-alert.info {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
}
.s-wiz-alert.warn {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
}
.s-wiz-alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* --- OSM choice cards --- */
.s-wiz-choice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 16px;
}
.s-wiz-choice-grid--3col {
  grid-template-columns: 1fr 1fr 1fr; gap: 10px;
}
@media (max-width: 600px) {
  .s-wiz-choice-grid { grid-template-columns: 1fr !important; }
}
.s-wiz-choice {
  border: 2px solid var(--s-border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms var(--s-ease);
  background: var(--s-surface);
}
.s-wiz-choice:hover {
  border-color: var(--s-accent);
  box-shadow: 0 4px 16px rgba(37,99,235,.12);
  transform: translateY(-2px);
}
.s-wiz-choice.selected {
  border-color: var(--s-accent);
  background: #eff6ff;
}
.s-wiz-choice-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.s-wiz-choice-title { font-size: .88rem; font-weight: 600; color: var(--s-text); }
.s-wiz-choice-desc  { font-size: .82rem; color: var(--s-muted); margin-top: 4px; line-height: 1.4; }

/* --- Mode accent colors --- */
.s-wiz-mode-light    { color: #059669; }
.s-wiz-mode-standard { color: #2563eb; }
.s-wiz-mode-premium  { color: #7c3aed; }

/* --- Footer --- */
.s-wizard-footer {
  padding: 16px 32px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; bottom: 0;
  background: var(--s-surface, #fff);
  z-index: 1;
}
.s-wiz-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 24px; font-size: .88rem; font-weight: 600;
  border-radius: 10px; border: none;
  cursor: pointer;
  transition: all 150ms var(--s-ease);
  min-height: 44px;
}
.s-wiz-btn.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.s-wiz-btn.primary:hover {
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  transform: translateY(-1px);
}
.s-wiz-btn.primary:disabled {
  opacity: .5; cursor: not-allowed; transform: none;
  box-shadow: none;
}
.s-wiz-btn.ghost {
  background: transparent; color: var(--s-muted);
  border: 1px solid var(--s-border);
}
.s-wiz-btn.ghost:hover { border-color: var(--s-accent); color: var(--s-accent); }

/* --- Step indicator dots --- */
.s-wizard-dots {
  display: flex; gap: 8px; justify-content: center;
  padding: 0 0 8px;
}
.s-wizard-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e2e8f0;
  transition: all 300ms var(--s-ease);
}
.s-wizard-dot.active {
  width: 24px; border-radius: 4px;
  background: var(--s-accent);
}
.s-wizard-dot.done { background: #93c5fd; }

/* ============================================================
   Result Section — Premium Design
   ============================================================ */

/* --- Result Header --- */
.s-result-header { margin-bottom: 20px; }
.s-result-header h2 {
  font-size: 1.5rem; font-weight: 700; color: var(--s-text);
  display: flex; align-items: center; gap: 10px; margin: 0;
}
.s-result-header p {
  font-size: .85rem; color: var(--s-muted); margin: 4px 0 0;
}

/* --- Notice banner --- */
.s-notice {
  padding: 12px 16px; border-radius: 10px;
  font-size: .78rem; line-height: 1.6;
}
.s-notice.warn {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #f59e0b; color: #92400e;
}

/* --- Hero KPI Cards (large) --- */
.s-hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 900px) {
  .s-hero-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .s-hero-grid { grid-template-columns: 1fr; }
}
.s-hero-card {
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: 16px;
  padding: 28px 24px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 200ms var(--s-ease), box-shadow 200ms var(--s-ease);
}
.s-hero-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.1);
}
.s-hero-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.s-hero-card.primary::before { background: linear-gradient(90deg, #22c55e, #16a34a); }
.s-hero-card.savings::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.s-hero-card.eco::before     { background: linear-gradient(90deg, #14b8a6, #0d9488); }
.s-hero-card.roi::before     { background: linear-gradient(90deg, #f59e0b, #d97706); }
.s-hero-icon { font-size: 2rem; margin-bottom: 8px; }
.s-hero-value {
  font-family: var(--s-mono); font-size: 2.2rem; font-weight: 700; line-height: 1.1;
}
.s-hero-card.primary .s-hero-value { color: #16a34a; }
.s-hero-card.savings .s-hero-value { color: #2563eb; }
.s-hero-card.eco     .s-hero-value { color: #0d9488; }
.s-hero-card.roi     .s-hero-value { color: #d97706; }
.s-hero-unit {
  font-size: .82rem; font-weight: 400; color: var(--s-muted); margin-left: 4px;
}
.s-hero-label {
  font-size: .82rem; font-weight: 600; color: var(--s-text);
  margin-top: 10px; letter-spacing: .02em;
}
.s-hero-sub {
  font-size: .82rem; color: var(--s-muted); margin-top: 4px;
}

/* --- Sub KPIs --- */
.s-sub-kpi-grid {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.s-sub-kpi {
  flex: 1 1 140px;
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  transition: box-shadow 150ms var(--s-ease);
}
.s-sub-kpi:hover { box-shadow: var(--s-shadow-lg); }
.s-sub-kpi-value {
  font-family: var(--s-mono); font-size: 1.35rem; font-weight: 700; color: var(--s-text);
}
.s-sub-kpi-value span {
  font-size: .82rem; font-weight: 400; color: var(--s-muted); margin-left: 2px;
}
.s-sub-kpi-label {
  font-size: .7rem; color: var(--s-muted); margin-top: 4px;
  text-transform: uppercase; letter-spacing: .04em;
}

/* --- Monthly Card --- */
.s-monthly-card .s-card-header {
  border-bottom: none; background: transparent; padding-bottom: 0;
}

/* --- Monthly Table --- */
.s-month-table {
  width: 100%; border-collapse: collapse; font-size: .82rem;
}
.s-month-table th {
  padding: 10px 12px; text-align: right;
  font-weight: 600; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--s-muted);
  border-bottom: 2px solid var(--s-border);
  background: #f8fafc;
}
.s-month-table th:first-child { text-align: left; }
.s-month-table td {
  padding: 10px 12px; text-align: right;
  border-bottom: 1px solid #f1f5f9;
  font-family: var(--s-mono); font-size: .8rem;
}
.s-month-table td:first-child {
  text-align: left; font-family: var(--s-font); font-weight: 500;
}
.s-month-table tbody tr { transition: background 100ms var(--s-ease); }
.s-month-table tbody tr:hover { background: #f8fafc; }
.s-month-table .s-month-total {
  font-weight: 700;
  border-top: 2px solid var(--s-border);
  background: #f8fafc;
}
.s-month-table .s-month-total td { border-bottom: none; }

/* --- Detail section (collapsible card) --- */
.s-detail-section { margin-top: 8px; }
.s-detail-section .s-chart-wrap + .s-chart-wrap { margin-top: 16px; }

/* --- Stagger animation for hero cards --- */
.s-hero-card:nth-child(1) { animation: s-fadeUp 400ms var(--s-ease) 100ms both; }
.s-hero-card:nth-child(2) { animation: s-fadeUp 400ms var(--s-ease) 200ms both; }
.s-hero-card:nth-child(3) { animation: s-fadeUp 400ms var(--s-ease) 300ms both; }
.s-sub-kpi { animation: s-fadeUp 300ms var(--s-ease) 400ms both; }
.s-monthly-card { animation: s-fadeUp 400ms var(--s-ease) 450ms both; }

/* ============================================================
   Premium UX Components
   ============================================================ */

/* --- Loading Overlay ---- */
.s-loading-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(15,23,42,.65);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
  animation: s-fadeIn 200ms var(--s-ease);
}
.s-loading-card {
  background: var(--s-surface);
  border-radius: 16px;
  padding: 40px 48px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  text-align: center;
  max-width: 380px;
  animation: s-helpSlide 300ms var(--s-ease);
}
.s-loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--s-accent);
  border-radius: 50%;
  animation: s-spin 800ms linear infinite;
  margin: 0 auto 16px;
}
@keyframes s-spin { to { transform: rotate(360deg); } }
.s-loading-title {
  font-size: 1.05rem; font-weight: 700; color: var(--s-text);
  margin: 0 0 6px;
}
.s-loading-sub {
  font-size: .82rem; color: var(--s-muted);
  margin: 0 0 16px; line-height: 1.5;
}
.s-loading-progress {
  width: 100%; height: 6px;
  background: #e2e8f0; border-radius: 3px;
  overflow: hidden;
}
.s-loading-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  border-radius: 3px;
  transition: width 300ms var(--s-ease);
  animation: s-progressPulse 2s ease-in-out infinite;
}
@keyframes s-progressPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .7; }
}
.s-loading-elapsed {
  font-size: .82rem; color: var(--s-muted);
  margin-top: 8px; font-family: var(--s-mono);
}

/* --- Toast Notification --- */
.s-toast-container {
  position: fixed; top: 72px; right: 24px; z-index: 9000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.s-toast {
  pointer-events: auto;
  background: var(--s-surface);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  min-width: 300px; max-width: 440px;
  animation: s-toastIn 400ms var(--s-ease);
  border-left: 4px solid var(--s-green);
}
.s-toast.error { border-left-color: var(--s-red); }
.s-toast.warn  { border-left-color: var(--s-amber); background: #fffbeb; }
.s-toast-icon { font-size: 1.3rem; flex-shrink: 0; }
.s-toast-body { flex: 1; }
.s-toast-title { font-size: .85rem; font-weight: 600; color: var(--s-text); }
.s-toast-msg { font-size: .75rem; color: var(--s-muted); margin-top: 2px; }
.s-toast-close {
  background: none; border: none; font-size: 1.1rem; color: var(--s-muted);
  cursor: pointer; padding: 4px; border-radius: 4px;
  transition: color 150ms; flex-shrink: 0;
}
.s-toast-close:hover { color: var(--s-text); }
@keyframes s-toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.s-toast.s-toast-out {
  animation: s-toastOut 300ms var(--s-ease) forwards;
}
@keyframes s-toastOut {
  to { opacity: 0; transform: translateX(40px) scale(.95); }
}

/* --- Confidence Badge --- */
.s-confidence {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: .82rem; font-weight: 600;
}
.s-confidence.high {
  background: #dcfce7; color: #15803d;
}
.s-confidence.medium {
  background: #fef3c7; color: #92400e;
}

/* --- Notice Info (existing but enhanced) --- */
.s-notice.info {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd; color: #1e40af;
}

/* --- Premium Footer --- */
.s-footer {
  background: #0f172a;
  padding: 24px 32px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-top: 48px;
}
.s-footer-brand {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: .85rem; color: #94a3b8;
  text-decoration: none;
}
.s-footer-brand .s-brand-logo { width: 22px; height: 22px; }
.s-footer-brand .s-brand-text .s-brand-hinata { color: #fbbf24; }
.s-footer-brand .s-brand-text .s-brand-cast   { color: #94a3b8; }
.s-footer-links {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.s-footer-link {
  font-size: .75rem; color: #64748b;
  text-decoration: none;
  transition: color 150ms;
  cursor: pointer;
  background: none; border: none;
  padding: 8px 4px; font-family: inherit;
}
.s-footer-link:hover { color: #cbd5e1; }
.s-footer-copy {
  font-size: .7rem; color: #475569;
  width: 100%; text-align: center;
  margin-top: 8px; padding-top: 12px;
  border-top: 1px solid #1e293b;
}

/* --- Keyboard shortcut badge --- */
.s-kbd {
  display: inline-block;
  padding: 1px 6px; border-radius: 4px;
  background: #f1f5f9; border: 1px solid #d1d5db;
  font-size: .82rem; font-family: var(--s-mono);
  color: var(--s-muted); line-height: 1.6;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

/* --- Result scroll target pulse --- */
.s-result-section.s-highlight {
  animation: s-highlightPulse 1.5s var(--s-ease);
}
@keyframes s-highlightPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.3); }
  50%  { box-shadow: 0 0 0 8px rgba(37,99,235,.08); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

/* --- KPI count-up initial state --- */
.s-hero-value[data-count] {
  transition: opacity 200ms;
}

/* --- Print styles --- */
@media print {
  .s-navbar, .s-fab-wrap, .s-sidebar, .s-canvas-wrap,
  .s-action-bar, .s-toast-container, .s-footer,
  .s-wizard-backdrop, .s-help-overlay, .s-panel-overlay,
  .s-consent-overlay,
  button[type="submit"], .s-notice { display: none !important; }

  body { background: #fff; font-size: 11pt; }
  .s-page { padding: 0; max-width: 100%; }
  .s-main-grid { display: block; }

  .s-result-section { animation: none; page-break-inside: avoid; }
  .s-hero-grid { gap: 12px; }
  .s-hero-card { border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
  .s-hero-card:hover { transform: none; box-shadow: none; }
  .s-hero-card::before { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  .s-sub-kpi { border: 1px solid #ccc; box-shadow: none; }
  .s-card { box-shadow: none; break-inside: avoid; }

  .s-month-table { font-size: 9pt; }
  .s-month-table th, .s-month-table td { padding: 6px 8px; }
  .s-month-table tbody tr:hover { background: transparent; }

  .s-chart-wrap { break-inside: avoid; }
  svg { max-width: 100% !important; }

  details { open: true; }
  details > summary { display: none; }
  details > .s-card-body, details > div { display: block !important; }

  @page { margin: 15mm; }
}

/* ============================================================
   Help Guide Modal
   ============================================================ */
.s-help-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: s-fadeIn 200ms var(--s-ease);
}
@keyframes s-fadeIn { from { opacity: 0; } to { opacity: 1; } }

.s-help-modal {
  background: var(--s-surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: min(820px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: s-helpSlide 300ms var(--s-ease);
}
@keyframes s-helpSlide { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

.s-help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--s-border);
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-radius: 12px 12px 0 0;
}
.s-help-header h2 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--s-text); }
.s-help-close {
  background: none; border: none; font-size: 1.6rem; color: var(--s-muted);
  cursor: pointer; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms var(--s-ease);
}
.s-help-close:hover { background: #fee2e2; color: var(--s-red); }

.s-help-body {
  overflow-y: auto; padding: 24px 28px;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}
.s-help-body::-webkit-scrollbar { width: 6px; }
.s-help-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.s-help-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-top: 1px solid var(--s-border);
  background: #f8fafc;
  border-radius: 0 0 12px 12px;
  font-size: .75rem; color: var(--s-muted);
}

/* --- Help sections --- */
.s-help-section { margin-bottom: 28px; }
.s-help-section:last-child { margin-bottom: 0; }
.s-help-section h3 {
  font-size: .95rem; font-weight: 700; color: var(--s-text);
  margin: 0 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--s-accent);
}
.s-help-section h4 {
  font-size: .85rem; font-weight: 600; color: var(--s-text);
  margin: 0 0 8px;
}

/* --- Quick start steps --- */
.s-help-steps { display: flex; flex-direction: column; gap: 14px; }
.s-help-step {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  background: #f8fafc; border-radius: 8px;
  border: 1px solid var(--s-border);
}
.s-help-step-num {
  flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--s-accent); color: #fff;
  font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.s-help-step strong { display: block; font-size: .88rem; margin-bottom: 4px; color: var(--s-text); }
.s-help-step p { margin: 0; font-size: .82rem; color: var(--s-muted); line-height: 1.6; }

/* --- FAQ accordion --- */
.s-help-faq {
  border: 1px solid var(--s-border); border-radius: 8px;
  margin-bottom: 8px; overflow: hidden;
  transition: box-shadow 150ms var(--s-ease);
}
.s-help-faq:hover { box-shadow: var(--s-shadow); }
.s-help-faq summary {
  padding: 12px 16px;
  font-size: .88rem; font-weight: 600; color: var(--s-text);
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  transition: background 150ms var(--s-ease);
}
.s-help-faq summary::-webkit-details-marker { display: none; }
.s-help-faq summary::before { content: '▸'; color: var(--s-accent); font-size: .7rem; transition: transform 150ms; }
.s-help-faq[open] summary::before { transform: rotate(90deg); }
.s-help-faq[open] summary { background: #f0f7ff; }
.s-help-faq-body {
  padding: 12px 16px 16px;
  font-size: .82rem; color: #374151; line-height: 1.7;
  border-top: 1px solid var(--s-border);
  background: #fafbfc;
}
.s-help-faq-body p { margin: 0 0 8px; }
.s-help-faq-body p:last-child { margin: 0; }
.s-help-faq-body ul { margin: 4px 0 8px; padding-left: 20px; }
.s-help-faq-body li { margin-bottom: 4px; }
.s-help-note {
  font-size: .76rem; color: var(--s-muted);
  padding: 8px 12px; background: #fffbeb;
  border-left: 3px solid var(--s-amber);
  border-radius: 0 4px 4px 0;
  margin-top: 8px;
}

/* --- Help table --- */
.s-help-table {
  width: 100%; border-collapse: collapse;
  font-size: .8rem; margin-top: 8px;
}
.s-help-table th {
  background: #f1f5f9; padding: 6px 10px;
  font-weight: 600; text-align: left;
  border-bottom: 2px solid var(--s-border);
}
.s-help-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e5e7eb;
}
.s-help-table tr:last-child td { border-bottom: none; }

/* --- 3D editor controls --- */
.s-help-controls { display: flex; flex-direction: column; gap: 6px; }
.s-help-control {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: #f8fafc;
  border-radius: 6px; font-size: .82rem;
}
.s-help-key {
  display: inline-block;
  padding: 3px 10px; border-radius: 4px;
  background: #1e293b; color: #e2e8f0;
  font-size: .82rem; font-weight: 600;
  font-family: var(--s-mono);
  min-width: 80px; text-align: center;
}
.s-help-handle {
  display: inline-block;
  width: 16px; height: 16px; border-radius: 50%;
  flex-shrink: 0;
}

/* --- Glossary --- */
.s-help-glossary dl { margin: 0; }
.s-help-glossary dt {
  font-weight: 700; font-size: .85rem; color: var(--s-accent);
  margin-top: 10px;
}
.s-help-glossary dt:first-child { margin-top: 0; }
.s-help-glossary dd {
  margin: 2px 0 0 0;
  font-size: .82rem; color: #374151; line-height: 1.6;
  padding-left: 16px;
  border-left: 2px solid #e2e6ea;
}

/* --- Disclaimer --- */
.s-help-disclaimer ul {
  margin: 0; padding: 0; list-style: none;
}
.s-help-disclaimer li {
  position: relative; padding: 8px 12px 8px 28px;
  font-size: .82rem; color: #374151; line-height: 1.6;
  background: #fffbeb; border-radius: 6px;
  margin-bottom: 6px;
}
.s-help-disclaimer li::before {
  content: '⚠'; position: absolute; left: 8px; top: 8px;
  font-size: .75rem;
}

/* --- Mobile adjustments --- */
@media (max-width: 640px) {
  .s-help-modal { width: 98vw; max-height: 94vh; border-radius: 8px; }
  .s-help-header, .s-help-body, .s-help-footer { padding-left: 16px; padding-right: 16px; }
  .s-help-header h2 { font-size: 1rem; }
}

/* --- Unsaved results warning banner ----------------------- */
.s-unsaved-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: var(--s-radius);
  font-size: .82rem;
  line-height: 1.6;
  color: #92400e;
  animation: s-unsaved-pulse 2s ease-in-out 3;
}
.s-unsaved-banner-icon { font-size: 1.2rem; flex-shrink: 0; }
.s-unsaved-banner-text { flex: 1; }
.s-unsaved-banner-save {
  background: #f59e0b; color: #fff; border: none; font-size: .78rem;
  font-weight: 700; padding: 6px 14px; border-radius: 6px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.s-unsaved-banner-save:hover { background: #d97706; }
.s-unsaved-banner-dismiss {
  background: none; border: none; color: #92400e; font-size: 1.1rem;
  cursor: pointer; padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.s-unsaved-banner-dismiss:hover { background: rgba(0,0,0,.08); }
@keyframes s-unsaved-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(245,158,11,.30); }
}
/* Attention re-trigger class (stronger shake + pulse) */
.s-unsaved-banner.s-unsaved-attention {
  animation: s-unsaved-shake .5s ease, s-unsaved-pulse 2s ease-in-out 3 .5s;
}
@keyframes s-unsaved-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-4px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}

/* --- Reduced motion preference ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Responsive: Smartphone (375px–768px)
   ============================================================ */

/* --- Canvas: prevent browser gestures on 3D canvas --- */
.s-canvas-wrap canvas { touch-action: none; }

/* --- Canvas height (P1) --- */
@media (max-width: 768px) {
    .s-canvas-wrap canvas { height: 50vh !important; min-height: 280px; }
    .s-navbar-help { padding: 8px 12px; min-height: 40px; }
    /* Make camera toolbar always visible on touch devices (no hover) */
    .s-cam-toolbar { opacity: 1; }
    .s-help-fab { opacity: 1; }
    .s-canvas-badge { opacity: .4; }
}

/* --- Wizard / Help / Loading padding (P0–P2) --- */
@media (max-width: 480px) {
    .s-wizard-header { padding: 20px 16px 0; }
    .s-wizard-body { padding: 16px 16px 12px; }
    .s-wizard-footer { padding: 12px 16px 20px; }

    .s-help-modal { width: 96vw; }
    .s-help-header { padding: 16px 16px; }
    .s-help-body { padding: 16px 16px; }
    .s-help-header h2 { font-size: 1rem; }

    .s-loading-card { max-width: 90vw; padding: 24px 20px; }
    .s-loading-title { font-size: .95rem; }
    .s-loading-sub { font-size: .78rem; }
}

/* --- 375px minimum breakpoint (P2) --- */
@media (max-width: 375px) {
    .s-wizard-card { border-radius: 0; }
    .s-action-bar { gap: 4px 6px; }
    .s-btn { padding: 6px 10px; font-size: .78rem; }
}

/* ============================================================
   Responsive: Comprehensive Smartphone (375px) Fixes
   ============================================================ */

/* --- Settings page form rows (used in Settings.cshtml) --- */
.s-settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  align-items: flex-start;
}
.s-settings-label {
  flex: 0 0 180px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--s-text);
  padding-top: 4px;
}
.s-settings-unit {
  font-size: .75rem;
  color: var(--s-muted);
  font-weight: 400;
  margin-left: 4px;
}
.s-settings-input {
  flex: 0 0 160px;
  width: 160px;
  border: 1px solid var(--s-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .85rem;
  background: #fff;
  color: var(--s-text);
  box-sizing: border-box;
}
.s-settings-input:focus {
  border-color: var(--s-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.s-settings-input:focus:not(:focus-visible) {
  outline: none;
}
select.s-settings-input {
  width: 200px;
  flex: 0 0 200px;
}
.s-settings-desc {
  flex: 1 1 100%;
  font-size: .78rem;
  color: var(--s-muted);
  line-height: 1.6;
  padding-left: 0;
  margin-top: 4px;
}

/* --- Footer links wrap on mobile --- */
@media (max-width: 640px) {
  .s-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
  }
  .s-footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
  }
}

/* --- Toast notification: prevent overflow on mobile --- */
@media (max-width: 480px) {
  .s-toast-container {
    right: 8px;
    left: 8px;
  }
  .s-toast {
    min-width: unset;
    max-width: 100%;
    width: 100%;
  }
}

/* --- Unsaved results banner: wrap on mobile --- */
@media (max-width: 640px) {
  .s-unsaved-banner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .s-unsaved-banner-text {
    flex: 1 1 100%;
  }
  .s-unsaved-banner-save {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* --- Hero card values: smaller on mobile --- */
@media (max-width: 520px) {
  .s-hero-value {
    font-size: 1.6rem;
  }
  .s-hero-card {
    padding: 20px 16px 16px;
  }
}

/* --- Sub-KPI: prevent value text overflow --- */
@media (max-width: 480px) {
  .s-sub-kpi {
    flex: 1 1 100%;
  }
  .s-sub-kpi-value {
    font-size: 1.1rem;
    word-break: break-all;
  }
}

/* --- Action bar: wrap and hide handle legend on mobile --- */
@media (max-width: 768px) {
  .s-action-bar {
    flex-wrap: wrap;
  }
  .s-handle-legend {
    display: none;
  }
}

/* --- Canvas badge: truncate text on small screens --- */
@media (max-width: 640px) {
  .s-canvas-badge {
    font-size: .7rem;
    padding: 3px 8px;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (max-width: 480px) {
  .s-canvas-badge {
    display: none;
  }
}

/* --- Wizard form rows: stack on mobile --- */
@media (max-width: 480px) {
  .s-wiz-row {
    flex-wrap: wrap;
  }
  .s-wiz-label {
    flex: 1 1 100%;
  }
  .s-wiz-hint {
    margin-left: 0;
  }
  .s-addr-input-row {
    flex-direction: column;
  }
  .s-addr-input-row input {
    width: 100% !important;
  }
  .s-addr-input-row button {
    width: 100%;
  }
}

/* --- What-if 3-column grid: stack on mobile --- */
@media (max-width: 640px) {
  .s-whatif-grid {
    grid-template-columns: 1fr !important;
  }
}

/* --- Tooltip: allow wrapping on small screens --- */
@media (max-width: 640px) {
  .s-tip::after {
    white-space: normal;
    max-width: 200px;
    left: 0;
    transform: scale(.95);
  }
  .s-tip:hover::after {
    transform: scale(1);
  }
}

/* --- Consent dialog: stack buttons on narrow screens --- */
@media (max-width: 400px) {
  .s-consent-footer {
    flex-direction: column;
    gap: 8px;
  }
  .s-consent-cancel,
  .s-consent-submit {
    width: 100%;
    text-align: center;
  }
}

/* --- Coach mark: adjust position for mobile --- */
@media (max-width: 640px) {
  .s-coach-mark {
    bottom: 70px;
    right: 12px;
    width: calc(100% - 24px);
  }
}

/* --- FAB: compact on mobile --- */
@media (max-width: 480px) {
  .s-fab-wrap {
    bottom: 16px;
    right: 12px;
    left: 12px;
    max-width: unset;
  }
  .s-fab {
    padding: 12px 20px;
    font-size: .85rem;
  }
  .s-fab-notice {
    max-width: 100%;
    font-size: .78rem;
  }
}

/* --- Page padding: reduce on mobile --- */
@media (max-width: 768px) {
  .s-page {
    padding: 8px;
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .s-main-grid {
    overflow-x: hidden;
    max-width: 100%;
  }
  .s-canvas-wrap {
    max-width: 100%;
    overflow: hidden;
  }
  .s-btn {
    min-width: auto;
  }
}
@media (max-width: 480px) {
  .s-page {
    padding: 4px;
  }
}

/* --- Sidebar in 1-column mode: spacing --- */
@media (max-width: 992px) {
  .s-sidebar {
    max-height: none;
    overflow-y: visible;
    gap: 8px;
  }
}

/* --- Settings page: stack label/input on mobile --- */
@media (max-width: 640px) {
  .s-settings-label {
    flex: 1 1 100%;
  }
  .s-settings-input,
  select.s-settings-input {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* --- Navbar brand: hide on very small screens if needed --- */
@media (max-width: 360px) {
  .s-navbar {
    padding: 0 12px;
  }
  .s-brand-text {
    font-size: .9rem;
  }
}

/* --- ROI summary stats: wrap gracefully --- */
@media (max-width: 640px) {
  .s-roi-card .s-card-body > div[style*="display:flex"][style*="justify-content:center"] {
    gap: 8px 16px;
  }
}

/* --- Editor help overlay: mobile-friendly --- */
@media (max-width: 480px) {
  #editorHelpOverlay > div {
    padding: 20px 16px !important;
    max-width: calc(100vw - 32px) !important;
    width: calc(100vw - 32px) !important;
  }
}

/* --- Help FAB in canvas: adjust on small screens --- */
@media (max-width: 480px) {
  .s-help-fab {
    padding: 6px 12px 6px 8px;
    font-size: .75rem;
    bottom: 10px;
    right: 10px;
  }
  .s-help-fab-icon {
    width: 18px;
    height: 18px;
    font-size: .75rem;
  }
}

/* --- Camera toolbar: compact on mobile --- */
@media (max-width: 480px) {
  .s-cam-toolbar {
    bottom: 8px;
    left: 8px;
    gap: 1px;
    padding: 2px 3px;
  }
  .s-cam-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 4px;
    font-size: .72rem;
  }
}

/* --- Result header: smaller on mobile --- */
@media (max-width: 480px) {
  .s-result-header h2 {
    font-size: 1.2rem;
  }
}

/* --- Panel editor dialog: mobile-friendly --- */
@media (max-width: 480px) {
  .s-panel-dialog {
    max-width: 96vw;
    max-height: 96vh;
  }
  .s-panel-dialog-header {
    padding: 12px 16px 10px;
  }
  .s-panel-dialog-body {
    padding: 12px 16px;
  }
  .s-panel-dialog-footer {
    padding: 10px 16px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .s-panel-legend {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* --- Wizard title: smaller on very narrow screens --- */
@media (max-width: 400px) {
  .s-wizard-title {
    font-size: 1.1rem;
  }
  .s-wizard-icon {
    font-size: 2rem;
  }
  .s-wiz-choice {
    padding: 14px 12px;
  }
  .s-wiz-choice-icon {
    font-size: 1.5rem;
  }
}

/* --- Wizard choice grid 3-col: stack on very small --- */
@media (max-width: 400px) {
  .s-wiz-choice-grid--3col {
    grid-template-columns: 1fr !important;
  }
}

/* --- Form input box-sizing for mobile overflow prevention --- */
.s-form-input input,
.s-form-input select,
.s-wiz-input input,
.s-wiz-input select {
  box-sizing: border-box;
  min-width: 0;
}

/* --- Hero value: prevent overflow on mobile --- */
@media (max-width: 520px) {
  .s-hero-value {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* --- Tables inside cards: ensure parent allows horizontal scroll --- */
@media (max-width: 640px) {
  .s-card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Sub-page content: prevent horizontal overflow --- */
@media (max-width: 480px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* --- Utility Classes (inline style 削減用) -------------------- */

/* テーブルセル: padding + border の頻出パターン */
.s-cell      { padding: 3px 6px; border: 1px solid var(--s-border); }
.s-cell-left { padding: 3px 6px; border: 1px solid var(--s-border); text-align: left; }
.s-cell-c    { padding: 3px 6px; border: 1px solid var(--s-border); text-align: center; }
.s-cell-lg   { padding: 6px 10px; border: 1px solid var(--s-border); }

/* テーブルヘッダー: 比較表用 */
.s-th        { padding: 4px 6px; text-align: center; border: 1px solid var(--s-border); }
.s-th-left   { padding: 4px 6px; text-align: left; border: 1px solid var(--s-border); }

/* 行背景: ストライプ */
.s-row-alt   { background: var(--s-surface-2, #f8fafc); }

/* フレックスレイアウト */
.s-flex      { display: flex; }
.s-flex-wrap { display: flex; flex-wrap: wrap; }
.s-flex-col  { display: flex; flex-direction: column; }
.s-flex-center { display: flex; align-items: center; }
.s-flex-between { display: flex; justify-content: space-between; align-items: center; }
.s-flex-end  { display: flex; justify-content: flex-end; }
.s-gap-2     { gap: 4px; }
.s-gap-4     { gap: 8px; }
.s-gap-6     { gap: 12px; }
.s-gap-8     { gap: 16px; }

/* テキスト */
.s-text-sm   { font-size: .75rem; }
.s-text-xs   { font-size: .82rem; }
.s-text-muted { color: var(--s-muted); }

/* ============================================================
   Mobile UI: Bottom Sheet / Tabs / FAB / Action Bar / Hero KPI
   ============================================================ */

/* --- M1: Sidebar → Bottom Sheet (mobile) --- */
@media (max-width: 768px) {
    .s-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        background: #fff;
        border-radius: 16px 16px 0 0;
        z-index: 90;
        transform: translateY(calc(100% - 48px));
        transition: transform 0.3s ease;
        overflow-y: auto;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        -webkit-overflow-scrolling: touch;
    }
    .s-sidebar.s-sheet-open {
        transform: translateY(0);
    }
    .s-sidebar::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 12px auto;
        position: sticky;
        top: 0;
        z-index: 1;
    }
}

/* --- M2: Mobile Tab Bar (editor / settings switch) --- */
@media (max-width: 768px) {
    .s-mobile-tabs {
        display: flex;
        position: sticky;
        top: 56px;
        z-index: 80;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .s-mobile-tab {
        flex: 1;
        padding: 10px;
        text-align: center;
        border: none;
        background: none;
        font-weight: 500;
        color: #6b7280;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        font-size: .85rem;
    }
    .s-mobile-tab.active {
        color: #2563eb;
        border-bottom-color: #2563eb;
    }
}
@media (min-width: 769px) {
    .s-mobile-tabs { display: none; }
}

/* --- M3: FAB full-width on mobile --- */
@media (max-width: 768px) {
    .s-fab-wrap {
        position: fixed;
        bottom: 56px;
        left: 16px;
        right: 16px;
        z-index: 95;
    }
    .s-fab {
        width: 100%;
        border-radius: 12px;
        padding: 14px 16px;
    }
}

/* --- M4: Action bar icon-only on mobile --- */
@media (max-width: 768px) {
    .s-action-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 4px;
        padding: 6px 8px;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .s-action-bar .s-btn .s-btn-text {
        /* モバイルでも短縮ラベルは表示（アイコンだけでは不明なため） */
        display: inline;
        font-size: .7rem;
    }
    .s-action-bar .s-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* --- M18: Result Hero KPI sticky on mobile --- */
@media (max-width: 768px) {
    .s-result-hero {
        position: sticky;
        top: 56px;
        z-index: 70;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        padding: 12px 16px;
    }
}

/* --- Mobile sheet toggle button --- */
@media (min-width: 769px) {
    .s-sheet-toggle { display: none; }
}
@media (max-width: 768px) {
    .s-sheet-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        padding: 10px 16px;
        margin-top: 8px;
        background: #eff6ff;
        color: #2563eb;
        border: 1px solid #bfdbfe;
        border-radius: 8px;
        font-size: .85rem;
        font-weight: 600;
        cursor: pointer;
    }
}

/* --- P2-1: Mobile building list --- */
@media (min-width: 769px) {
    .s-mobile-building-list { display: none; }
}
.s-mobile-building-list {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}
.s-mobile-bldg-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: .82rem;
}
.s-mobile-bldg-item button {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 8px;
    font-size: .85rem;
}

/* --- P2-2: PC guide section (mobile only) --- */
@media (min-width: 769px) {
    .s-mobile-pc-guide { display: none; }
}
