:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef3f8;
  --text: #172033;
  --muted: #5d6b82;
  --line: #d6dee8;
  --accent: #0f766e;
  --accent-strong: #0d5f59;
  --danger: #b42318;
  --shadow: 0 20px 55px rgba(15, 23, 42, 0.12);
  font-family:
    "Pretendard",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.dark {
  color-scheme: dark;
  --bg: #101623;
  --panel: #172033;
  --panel-soft: #202b40;
  --text: #f8fafc;
  --muted: #b6c2d2;
  --line: #334155;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --danger: #fca5a5;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.16), transparent 26rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 21px;
  box-shadow: var(--shadow);
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.language-select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  box-shadow: var(--shadow);
}

.guide-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

body.dark .guide-link {
  color: #06201d;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel,
.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.section:first-child {
  padding-top: 0;
  border-top: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
  letter-spacing: 0;
}

.upload {
  display: grid;
  gap: 10px;
}

.file-input {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-button,
.action-button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  border: 1px solid var(--line);
}

.mode-button.active,
.action-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

body.dark .mode-button.active,
body.dark .action-button.primary {
  color: #06201d;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input[type="number"],
input[type="date"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
}

.hint,
.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status strong {
  color: var(--accent-strong);
}

.stage {
  min-height: 620px;
  overflow: hidden;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 620px;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.16) 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

canvas {
  display: block;
  width: 100%;
  min-height: 620px;
  cursor: crosshair;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  pointer-events: none;
}

.magnifier {
  position: absolute;
  width: 188px;
  height: 188px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: none;
  transform: translate(18px, -50%);
  z-index: 2;
}

.magnifier[hidden] {
  display: none;
}

.magnifier canvas {
  width: 184px;
  height: 184px;
  min-height: 184px;
  cursor: none;
}

.magnifier-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

.point-list {
  max-height: 220px;
  overflow: auto;
}

.delete-button {
  color: var(--danger);
  background: transparent;
  cursor: pointer;
}

.comments {
  margin-top: 20px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calibration-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.calibration-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 14px;
}

.calibration-item strong {
  color: var(--text);
}

.calibration-delete {
  color: var(--danger);
  background: transparent;
  cursor: pointer;
}

.series-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.series-button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.series-button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.series-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: currentColor;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 20px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.site-footer a {
  color: inherit;
}

.adfit-banner {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 20px;
  overflow: hidden;
}

.adfit-banner-mobile {
  display: none;
}

.adsense-banner {
  width: 100%;
  margin-top: 20px;
  overflow: hidden;
}

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

  .stage,
  .canvas-wrap,
  canvas {
    min-height: 480px;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 16px;
  }

  .adfit-banner-desktop {
    display: none;
  }

  .adfit-banner-mobile {
    display: flex;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid,
  .mode-grid,
  .action-row {
    grid-template-columns: 1fr;
  }
}
