:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --line: #d9dde4;
  --text: #19202a;
  --muted: #586474;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.topbar h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}
.sub { margin: 0; color: var(--muted); }
.badge {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 360px;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.controls label {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
}
.controls select {
  margin-top: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  font-size: 1rem;
}
.status-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fafbfd;
  margin: 14px 0;
}
.mode-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9eef8;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.status-text { color: var(--muted); }
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
  font-weight: 700;
  cursor: pointer;
}
button.primary {
  background: #111827;
  color: white;
}
button:hover { transform: translateY(-1px); }
.notes summary { cursor: pointer; font-weight: 700; }
.notes p { color: var(--muted); line-height: 1.45; }

.target-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fbfbfb;
}
.target-surface {
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: crosshair;
}
.target-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.results-panel h2 { margin-top: 0; }
.sec-card {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.sec-brand {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 16px;
}
.sec-empty { color: var(--muted); }
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.metric-label {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 6px;
}
.metric-value {
  font-size: 1.15rem;
  font-weight: 800;
}
.sec-callout {
  margin-top: 14px;
  border: 1px dashed #c7d1e0;
  border-radius: 14px;
  padding: 12px;
  background: #f8fbff;
  line-height: 1.4;
}
.sec-footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }
}


/* MATRIX BACK BUTTON */
.matrix-back-btn {
  position: fixed;
  top: 15px;
  left: 15px;
  padding: 10px 14px;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  cursor: pointer;
  z-index: 9999;
}

.matrix-back-btn:hover {
  background: rgba(0,0,0,0.9);
}


/* MATRIX DISTANCE CONTROL */
.distance-control {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
  align-items: center;
}

.distance-control input,
.distance-control select {
  width: 100%;
}

.distance-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0 18px;
}

.distancePreset {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}

.distancePreset:hover {
  background: rgba(255,255,255,0.12);
}


/* HIDE SEC PREVIEW (Matrix cleanup) */
.results-panel,
#secCard {
  display: none !important;
}


/* SCOPE CORRECTION UNDER MATRIX TARGET */
.scope-correction-panel {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0, 224, 255, 0.10);
  border: 1px solid rgba(0, 224, 255, 0.35);
  text-align: center;
  box-shadow: 0 0 14px rgba(0, 224, 255, 0.18);
}

.scope-correction-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.scope-correction-text {
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1.45;
}


/* HEADER TIGHTEN */
.sim-title {
  margin-bottom: 4px;
}

.sim-subtitle {
  margin-top: 2px;
  opacity: 0.8;
}


/* MATRIX STRIP TIGHTEN */
.mode-strip,
.results-strip {
  margin: 6px 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.2;
}

/* reduce gap under header */
.sim-header + .mode-strip,
.sim-header + .results-strip {
  margin-top: 4px;
}

/* tighten text spacing inside */
.mode-strip div,
.results-strip div {
  margin: 2px 0;
}

/* keep it compact but readable */
.mode-strip button,
.results-strip button {
  padding: 6px 10px;
  font-size: 0.85rem;
}


/* ALIGN MATRIX STRIP TO TARGET WIDTH */
.status-wrap {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.mode-pill,
.status-text {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
