:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe2ea;
  --primary: #0f766e;
  --accent: #ea580c;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: radial-gradient(circle at 20% 15%, #fff4dd 0%, #f8fafc 40%, #eef6f4 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(32px);
  opacity: 0.35;
}

.bg-shape.a {
  width: 340px;
  height: 340px;
  right: -80px;
  top: 50px;
  background: #f59e0b;
}

.bg-shape.b {
  width: 280px;
  height: 280px;
  left: -80px;
  bottom: 90px;
  background: #0891b2;
}

.topbar {
  max-width: 1380px;
  margin: 20px auto 12px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.portal-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.layout {
  max-width: 1380px;
  margin: 0 auto 28px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.panel section {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
}

.help-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  border: 1px solid #b9ced2;
  background: #f0f7f8;
  color: #0f4c5c;
  padding: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
}

.help-icon:hover {
  background: #e2f0f2;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

button {
  border: 1px solid #bdd4d2;
  background: #ecf8f7;
  color: #0f3d38;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #e0f2f1;
}

.run-btn {
  width: 100%;
  border: 1px solid #115e59;
  background: linear-gradient(160deg, #0f766e, #0e5a53);
  color: #fff;
}

.control {
  margin-bottom: 8px;
  display: grid;
  gap: 4px;
}

.control label {
  font-size: 0.82rem;
  color: #334155;
}

.control output {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: "IBM Plex Mono", monospace;
}

.control input[type="range"] {
  width: 100%;
}

.control select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  font-family: inherit;
}

.control.dual {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.footer-controls {
  display: grid;
  gap: 8px;
}

.content {
  display: grid;
  gap: 12px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.score-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  padding: 12px;
  box-shadow: var(--shadow);
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
  font-family: "IBM Plex Mono", monospace;
}

.model-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
  box-shadow: var(--shadow);
}

.model-panel h2 {
  margin: 0 0 8px;
  font-size: 1.03rem;
}

.model-panel p {
  margin: 6px 0;
}

.tier-body {
  display: grid;
  gap: 12px;
}

.tier-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tier-summary div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fbfb;
}

.tier-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tier-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
}

.tier-chip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.tier-chip p {
  margin: 3px 0;
  font-size: 0.8rem;
}

.tier-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  padding: 3px 9px;
  font-size: 0.8rem;
  font-family: "IBM Plex Mono", monospace;
}

.tier-aa {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.tier-a {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.tier-b {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.tier-nr {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.tier-na {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
}

.tier-plus-block {
  border: 1px dashed #c9d6e6;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.tier-plus-block h3 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tier-fail-list {
  margin: 0;
  padding-left: 18px;
}

.tier-fail-list li {
  margin: 0 0 4px;
  color: #475569;
  font-size: 0.82rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chart {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  min-height: 280px;
  overflow: hidden;
}

.chart-wide {
  grid-column: 1 / -1;
}

.status {
  margin: 0;
  color: #0f766e;
  font-weight: 600;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.help-modal.open {
  display: block;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
}

.help-dialog {
  position: relative;
  width: min(680px, calc(100vw - 28px));
  margin: 8vh auto 0;
  background: #ffffff;
  border: 1px solid #dbe2ea;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.22);
  padding: 14px;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.help-header h3 {
  margin: 0;
  font-size: 1rem;
}

.help-close {
  border: 1px solid #d0dde0;
  background: #f7fbfb;
  color: #334155;
  padding: 6px 10px;
}

.help-body {
  padding-top: 10px;
}

.help-body p {
  margin: 0 0 8px;
  color: #334155;
  line-height: 1.45;
}

.help-body p:last-child {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .topbar {
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 740px) {
  .score-grid,
  .tier-grid,
  .tier-summary,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .preset-row {
    grid-template-columns: 1fr;
  }
}
