:root {
  --bg-1: #0f2027;
  --bg-2: #203a43;
  --bg-3: #2c5364;
  --panel: #ffffff;
  --panel-border: #d7e3e8;
  --accent: #1c7a8c;
  --accent-dark: #155a67;
  --text: #1d2b30;
  --muted: #5b6f76;
  --ok: #1f8f5f;
  --no: #c0473f;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2), var(--bg-3));
  min-height: 100vh;
}

.site-header {
  text-align: center;
  padding: 30px 16px 6px;
  color: #eaf6f8;
}
.site-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  letter-spacing: 0.5px;
}
.site-header .subtitle {
  margin: 10px auto 0;
  max-width: 620px;
  color: #b9d3d9;
  font-size: clamp(0.92rem, 2vw, 1.05rem);
  line-height: 1.5;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px 16px 56px;
}

.stage-col { flex: 1 1 520px; min-width: 300px; max-width: 920px; }
#stage canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
}

.score-bar {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  color: #cfe6ea;
  font-size: 0.92rem;
}
.score-bar .actions { display: flex; gap: 10px; }

.panel {
  flex: 1 1 340px;
  min-width: 290px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.card h2 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.card .step { color: var(--muted); font-size: 0.86rem; margin: 0 0 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.9rem; color: var(--muted); }
select {
  font-size: 1rem;
  padding: 11px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  background: #f9fcfd;
  color: var(--text);
  width: 100%;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
button {
  font: inherit;
  font-weight: 600;
  padding: 11px 16px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
  flex: 1 1 auto;
}
button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: #e7eef0; color: var(--accent-dark); }
button.secondary:hover { background: #d4e0e3; }
button.ghost { background: transparent; color: #cfe6ea; border: 1px solid #4a6b74; }
button.ghost:hover { background: rgba(255,255,255,0.08); }

/* explain panel */
.explain {
  border-radius: 10px;
  padding: 14px 16px;
  background: #eef7f9;
  border: 1px dashed var(--accent);
  color: var(--accent-dark);
}
.explain.muted { background: #f1f3f4; border-color: #c4ccce; color: var(--muted); }
.explain-head { font-weight: 700; font-size: 1.02rem; margin-bottom: 6px; }
.explain-eq {
  font-family: "Cascadia Code", "SF Mono", Consolas, monospace;
  background: rgba(0,0,0,0.06);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.95rem;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.explain-obs { margin: 0; color: var(--text); font-size: 0.94rem; line-height: 1.5; }

/* notebook */
#notebook {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 230px;
  overflow-y: auto;
}
#notebook li {
  display: flex;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid #eef2f3;
  font-size: 0.9rem;
  line-height: 1.45;
}
#notebook li:last-child { border-bottom: none; }
#notebook li.empty { color: var(--muted); border: none; }
.nb-n {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* identify result */
.result {
  margin: 14px 0 0;
  padding: 0;
  font-size: 0.96rem;
  line-height: 1.5;
}
.result:empty { display: none; }
.result.ok { color: var(--ok); font-weight: 600; }
.result.no { color: var(--no); font-weight: 600; }
.result.warn { color: #b9821f; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #11272d;
  color: #eaf6f8;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
