:root {
  /* default theme: dark */
  color-scheme: dark;
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.08);
  --cardBorder: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.7);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --accent: #7c3aed;
  --danger: #ef4444;
  --ring: 0 0 0 4px rgba(124, 58, 237, 0.25);
  --bgRad1: #1b2a6b;
  --bgRad2: #5b1b6b;
  --bgRad3: #116b5a;
  --kbdBg: rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --card: rgba(255, 255, 255, 0.75);
  --cardBorder: rgba(15, 23, 42, 0.12);
  --text: rgba(15, 23, 42, 0.92);
  --muted: rgba(15, 23, 42, 0.65);
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.15);
  --bgRad1: #dbeafe;
  --bgRad2: #fce7f3;
  --bgRad3: #d1fae5;
  --kbdBg: rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, var(--bgRad1) 0%, transparent 55%),
    radial-gradient(1000px 700px at 90% 15%, var(--bgRad2) 0%, transparent 55%),
    radial-gradient(900px 700px at 45% 95%, var(--bgRad3) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 24px;
}

.app {
  width: min(920px, 100%);
  display: grid;
  gap: 16px;
}

.header {
  padding: 12px 4px;
}

.headerTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.title {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 36px);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.tabs {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tabBtn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tabBtn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
}

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

.tabBtn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.tabBtn.is-active {
  border-color: rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(59, 130, 246, 0.22));
}

html[data-theme="light"] .tabBtn {
  border-color: rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.55);
}

html[data-theme="light"] .tabBtn:hover {
  background: rgba(255, 255, 255, 0.75);
}

html[data-theme="light"] .tabBtn.is-active {
  border-color: rgba(124, 58, 237, 0.35);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(59, 130, 246, 0.16));
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .tabBtn {
    border-color: rgba(15, 23, 42, 0.14);
    background: rgba(255, 255, 255, 0.55);
  }

  html:not([data-theme]) .tabBtn:hover {
    background: rgba(255, 255, 255, 0.75);
  }

  html:not([data-theme]) .tabBtn.is-active {
    border-color: rgba(124, 58, 237, 0.35);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(59, 130, 246, 0.16));
  }
}

.tabPanels {
  display: grid;
  gap: 16px;
}

.tabPanel {
  display: none;
}

.tabPanel.is-active {
  display: grid;
  gap: 16px;
}

.panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 18px;
}

.result {
  display: grid;
  gap: 12px;
  padding: 6px 0 10px;
}

.balls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 52px;
}

.ball {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.02em;
  user-select: none;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transform: translateY(6px) scale(0.98);
  opacity: 0;
  animation: pop 420ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes pop {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.ball.yellow {
  background: radial-gradient(circle at 30% 25%, #fff2a6 0%, #f59e0b 42%, #b45309 100%);
  color: #2a1a06;
}
.ball.blue {
  background: radial-gradient(circle at 30% 25%, #bfe0ff 0%, #3b82f6 45%, #1e3a8a 100%);
  color: #08142f;
}
.ball.red {
  background: radial-gradient(circle at 30% 25%, #ffd1d1 0%, #ef4444 45%, #7f1d1d 100%);
  color: #2b0b0b;
}
.ball.gray {
  background: radial-gradient(circle at 30% 25%, #f1f5f9 0%, #94a3b8 45%, #334155 100%);
  color: #0b1220;
}
.ball.green {
  background: radial-gradient(circle at 30% 25%, #c6ffe7 0%, #10b981 45%, #064e3b 100%);
  color: #03221a;
}

.resultText {
  margin: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.22);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(59, 130, 246, 0.85));
  border-color: rgba(255, 255, 255, 0.18);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn.icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.iconGlyph {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.iconText {
  font-weight: 800;
}

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

.panelHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panelTitle {
  margin: 0;
  font-size: 16px;
}

.panelHint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.history {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

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

.historyTime {
  color: var(--muted);
  font-size: 12px;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--kbdBg);
}

.footer {
  color: var(--muted);
  text-align: center;
  padding: 4px 0 0;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    color-scheme: light;
    --bg: #f8fafc;
    --card: rgba(255, 255, 255, 0.75);
    --cardBorder: rgba(15, 23, 42, 0.12);
    --text: rgba(15, 23, 42, 0.92);
    --muted: rgba(15, 23, 42, 0.65);
    --shadow: 0 18px 60px rgba(15, 23, 42, 0.15);
    --bgRad1: #dbeafe;
    --bgRad2: #fce7f3;
    --bgRad3: #d1fae5;
    --kbdBg: rgba(15, 23, 42, 0.06);
  }
}

.contactForm {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.field {
  display: grid;
  gap: 8px;
}

.label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.input,
.textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.5;
}

.input:focus-visible,
.textarea:focus-visible {
  box-shadow: var(--ring);
  border-color: rgba(124, 58, 237, 0.55);
}

html[data-theme="light"] .input,
html[data-theme="light"] .textarea {
  border-color: rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.65);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .input,
  html:not([data-theme]) .textarea {
    border-color: rgba(15, 23, 42, 0.14);
    background: rgba(255, 255, 255, 0.65);
  }
}

.formHint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hpField {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.formActions {
  margin-top: 4px;
}

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

.tmHint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tmActions {
  margin-top: 0;
}

.tmStatus {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tmLayout {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(240px, 1fr);
  gap: 14px;
  align-items: start;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.14);
  padding: 16px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.dropzone:hover {
  border-color: rgba(124, 58, 237, 0.55);
  background: rgba(255, 255, 255, 0.06);
}

.dropzone.is-dragover {
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(59, 130, 246, 0.12);
  transform: translateY(-1px);
}

.dropzone:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.dropzoneTitle {
  font-weight: 950;
  letter-spacing: -0.01em;
}

.dropzoneSub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tmPreview {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 240px;
}

.tmPreviewImg {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  display: none;
}

.tmPreviewImg.is-visible {
  display: block;
}

.tmHiddenCanvas {
  display: none;
}

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

.tmVerdict {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  padding: 12px 14px;
  line-height: 1.55;
  font-weight: 800;
}

.tmVerdictTitle {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

.tmVerdictMain {
  margin: 0;
  font-size: 18px;
}

.tmVerdictSub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.tmRow {
  display: grid;
  gap: 6px;
}

.tmRowTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tmClassName {
  font-weight: 900;
}

.tmProb {
  color: var(--muted);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tmTrack {
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.tmFill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.95), rgba(59, 130, 246, 0.85));
}

html[data-theme="light"] .tmPreview,
html[data-theme="light"] .tmVerdict,
html[data-theme="light"] .tmTrack,
html[data-theme="light"] .dropzone {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.55);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .tmPreview,
  html:not([data-theme]) .tmVerdict,
  html:not([data-theme]) .tmTrack,
  html:not([data-theme]) .dropzone {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.55);
  }
}

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

.tmHint a,
.prose a {
  color: color-mix(in srgb, var(--text) 86%, transparent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tmHint a:hover,
.prose a:hover {
  color: var(--text);
}

.prose {
  display: grid;
  gap: 12px;
  line-height: 1.65;
  color: var(--text);
}

.proseHeader {
  display: grid;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .proseHeader {
  border-bottom-color: rgba(15, 23, 42, 0.12);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .proseHeader {
    border-bottom-color: rgba(15, 23, 42, 0.12);
  }
}

.proseTitle {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 30px);
  letter-spacing: -0.02em;
}

.proseMeta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.prose h2 {
  margin: 14px 0 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.prose p,
.prose li {
  color: color-mix(in srgb, var(--text) 92%, transparent);
}

.prose ul,
.prose ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.16);
}

html[data-theme="light"] .prose code {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.65);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .prose code {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.65);
  }
}

.callout {
  border-radius: 16px;
  border: 1px solid rgba(124, 58, 237, 0.28);
  background: rgba(124, 58, 237, 0.12);
  padding: 12px 14px;
}

.fineprint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
