:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #11151a;
  --panel-2: #171c22;
  --line: #2a313a;
  --text: #f4f6f8;
  --muted: #929ba7;
  --accent: #82f7c4;
  --accent-strong: #b2ffe0;
  --danger: #ff9d9d;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(130, 247, 196, 0.05), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.35rem 1.5rem 1rem;
}

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

.topbar p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.topbar-actions {
  display: flex;
  gap: 0.6rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.62rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.button:hover {
  border-color: #48515d;
  background: #1c2229;
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #07110d;
  font-weight: 700;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1rem;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
}

.viewer-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(17, 21, 26, 0.94);
  box-shadow: var(--shadow);
}

.viewer-card {
  min-width: 0;
  overflow: hidden;
}

.canvas-shell {
  position: relative;
  min-height: 42rem;
  height: calc(100vh - 7.4rem);
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    #090b0e;
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#editorCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.canvas-help {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  max-width: calc(100% - 2rem);
  padding: 0.52rem 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 0.65rem;
  background: rgba(8, 10, 13, 0.72);
  color: #c7cdd4;
  font-size: 0.74rem;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.panel {
  align-self: start;
  overflow: hidden;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.muted,
.assumption,
.convention {
  color: var(--muted);
}

.muted {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.75rem;
  color: #c8ced5;
  font-size: 0.77rem;
}

.field input {
  width: 100%;
  min-height: 2.45rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  outline: none;
  background: #0d1115;
  color: var(--text);
  padding: 0.58rem 0.68rem;
}

.field input:focus {
  border-color: rgba(130, 247, 196, 0.65);
  box-shadow: 0 0 0 3px rgba(130, 247, 196, 0.08);
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 2rem;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.assumption,
.convention {
  margin: 0.75rem 0 0;
  font-size: 0.72rem;
  line-height: 1.55;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.22rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.68rem;
}

.status.ok {
  border-color: rgba(130, 247, 196, 0.28);
  background: rgba(130, 247, 196, 0.08);
  color: var(--accent);
}

.status.error {
  border-color: rgba(255, 157, 157, 0.28);
  background: rgba(255, 157, 157, 0.08);
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.metric {
  min-width: 0;
  padding: 0.72rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #0d1115;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.67rem;
}

.metric strong {
  display: block;
  margin-top: 0.24rem;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font-size: 0.72rem;
}

.text-button:disabled {
  color: #505862;
  cursor: default;
}

.matrix,
.points-output {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #0a0d10;
  color: #d9dee4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.6;
  overflow: auto;
}

.matrix {
  padding: 0.75rem;
}

.details {
  padding: 0.95rem 1rem 1rem;
}

.details summary {
  color: #cfd5db;
  cursor: pointer;
  font-size: 0.78rem;
  user-select: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0.85rem 0 0;
}

.detail-grid > div {
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.68rem;
  background: #0d1115;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.66rem;
}

.detail-grid dd {
  margin: 0.22rem 0 0;
  font-size: 0.82rem;
}

.points-output {
  margin-top: 0.6rem;
  padding: 0.68rem;
  white-space: pre-wrap;
}

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

  .canvas-shell {
    min-height: 34rem;
    height: 62vh;
  }

  .panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .details {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.8rem;
    padding-inline: 0.9rem;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1;
  }

  .layout {
    padding-inline: 0.9rem;
  }

  .canvas-shell {
    min-height: 27rem;
    height: 58vh;
  }

  .panel {
    display: block;
  }
}

.resolve-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric strong.out-of-range {
  color: var(--danger);
}

.calculation-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.55;
}
