:root {
  --bg: #fcfcfd;
  --panel: #ffffff;
  --text: #1b1d21;
  --muted: #5f6572;
  --line: #e6e8ee;
  --accent: #1f6fd7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #f4f8ff, #fcfcfd 45%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer a {
  color: #35527e;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.footer a:hover {
  border-bottom-color: #35527e;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.github-logo {
  width: 16px;
  height: 16px;
}

.footer-sep {
  margin: 0 8px;
  color: #96a0b2;
}

.top h1 {
  margin: 0;
  font-size: 1.7rem;
}

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

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.top-copy {
  min-width: 0;
}

.top-repo-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: #35527e;
  text-decoration: none;
  border: 1px solid #d7deec;
  background: #f5f7fb;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 0.85rem;
  font-weight: 700;
}

.top-repo-link:hover {
  background: #eef3ff;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(20, 35, 70, 0.06);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.grid-meta {
  margin: -4px 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.draw-stack {
  width: 100%;
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

#draw-canvas,
#grid-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#draw-canvas {
  touch-action: none;
  z-index: 1;
}

#grid-canvas {
  pointer-events: none;
  z-index: 2;
}

.controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  background: #f5f7fb;
  border: 1px solid #dce2ee;
  color: #243040;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #eef3ff;
}

.field {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
}

.status {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
}

#network-canvas {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: block;
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}

.output-panel {
  margin-top: 16px;
}

.seo-copy {
  margin-top: 16px;
}

.seo-copy p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.seo-copy p:last-child {
  margin-bottom: 0;
}

.seo-copy a {
  color: #35527e;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.seo-copy a:hover {
  border-bottom-color: #35527e;
}

.output-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.output-head p {
  margin: 0;
  font-weight: 700;
}

.output-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

.digit-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  background: #fff;
}

.digit {
  font-size: 0.9rem;
  font-weight: 700;
}

.prob-chart {
  height: 56px;
  width: 100%;
  border: 1px solid #dce2ee;
  border-radius: 8px;
  margin: 6px 0;
  background: linear-gradient(180deg, #f6f9ff, #ffffff);
  position: relative;
  overflow: hidden;
}

.prob-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #86b9ff 0%, #2e78e8 100%);
  transition: height 100ms linear;
}

.prob-value {
  font-size: 0.75rem;
  color: var(--muted);
}

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

  #network-canvas {
    height: 320px;
  }
}

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

  .output-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
