:root {
  --accent: #f4741c;
  --accent-hover: #ff8533;
  --accent-soft: rgba(244, 116, 28, 0.13);
  --accent-line: rgba(244, 116, 28, 0.4);

  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.16);
  --bad: #f85149;
  --bad-soft: rgba(248, 81, 73, 0.16);

  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, monospace;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root, [data-theme="dark"] {
  --bg: #191919;
  --topbar-bg: rgba(25, 25, 25, 0.7);
  --code: #232323;
  --ink: #f1f1f1;
  --muted: #a8a8a8;
  --line: #2f2f2f;
  --hairline: rgba(255, 255, 255, 0.075);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-line: rgba(255, 255, 255, 0.12);
  --t-key: #9cdcfe;
  --t-str: #ce9178;
  --t-num: #b5cea8;
  --t-bool: #569cd6;
  --t-null: #569cd6;
}

[data-theme="light"] {
  --bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.7);
  --code: #f7f6f3;
  --ink: #37352f;
  --muted: #787774;
  --line: #e9e9e7;
  --hairline: rgba(55, 53, 47, 0.09);
  --glass: rgba(55, 53, 47, 0.05);
  --glass-line: rgba(55, 53, 47, 0.12);
  --t-key: #0451a5;
  --t-str: #a31515;
  --t-num: #098658;
  --t-bool: #0000ff;
  --t-null: #0000ff;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable both-edges; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
b, strong { font-weight: 600; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 14px 40px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.1px; }
.brand-logo { width: 30px; height: 30px; object-fit: contain; }
.theme-toggle {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: transparent; border: 0;
  color: var(--muted); cursor: pointer;
  transition: color .3s var(--ease), background .35s var(--ease), transform .35s var(--ease);
}
.theme-toggle:hover { color: var(--accent); background: var(--glass); transform: rotate(12deg); }
.theme-toggle:active { transform: scale(0.8) rotate(-20deg); }
.theme-toggle svg { width: 20px; height: 20px; animation: iconIn .5s var(--ease); }

.layout {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 44px 40px 90px;
  display: grid; grid-template-columns: 256px 1fr; gap: 60px; align-items: start;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; gap: 24px; padding: 28px 20px 70px; }
  .nav { position: static !important; }
  .tabs {
    flex-direction: row !important; flex-wrap: wrap;
    max-height: none; overflow: visible; padding-bottom: 0;
    -webkit-mask-image: none; mask-image: none;
  }
}
#trainer:not([hidden]) { animation: fadeUp .5s var(--ease); }

.nav { position: sticky; top: 100px; align-self: start; }
.progress-row { display: flex; align-items: center; margin-bottom: 18px; padding: 0 14px; }
.progress { font-size: 13px; color: var(--muted); }
.progress b { color: var(--accent); font-weight: 700; }
.reset-mini { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; font-family: inherit; transition: color .25s var(--ease); }
.reset-mini:hover { color: var(--accent); }

.tabs {
  display: flex; flex-direction: column; gap: 3px;
  max-height: min(calc(100vh - 190px), 486px); overflow-y: auto; padding-bottom: 36px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 52px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 52px), transparent);
}
.tabs::-webkit-scrollbar { width: 0; height: 0; }
.tabs { scrollbar-width: none; }
.tab {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 11px 14px; border-radius: 11px; border: 0;
  background: transparent; color: var(--muted);
  font-size: 14.5px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.tab:hover { background: var(--glass); color: var(--ink); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tab.done::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.main { min-width: 0; }
.brief { margin-bottom: 30px; }
.brief-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--accent); font-weight: 700; }
.mode-title { font-weight: 700; font-size: 30px; line-height: 1.12; letter-spacing: -0.6px; margin: 12px 0 14px; }
.mode-desc { color: var(--ink); font-size: 16px; font-weight: 500; line-height: 1.6; margin: 0 0 18px; max-width: 760px; }

.theory { border-bottom: 1px solid var(--line); padding: 0 0 16px; margin-top: 4px; }
.theory-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.theory-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .42s var(--ease); }
.theory-wrap.open { grid-template-rows: 1fr; }
.theory-wrap > .brief-theory { overflow: hidden; min-height: 0; }
.theory-wrap.open > .brief-theory { padding-top: 12px; }
.theory-toggle { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 0; background: transparent; border: 0; color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit; transition: color .25s var(--ease); }
.theory-toggle:hover { color: var(--accent-hover); }
.theory-arrow { width: 16px; height: 16px; transition: transform .42s var(--ease); }
.theory-toggle.open .theory-arrow { transform: rotate(180deg); }
.brief-theory { color: var(--ink); font-size: 14.5px; line-height: 1.78; max-width: 760px; }
.brief-theory code { font-family: var(--mono); background: var(--code); color: var(--accent); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.brief-theory b { color: var(--ink); }

.work { min-width: 0; }
.card { margin-bottom: 16px; }
.brief > *, .card > * { animation: fadeUp .4s var(--ease) backwards; }
.brief > *:nth-child(2), .card > *:nth-child(2) { animation-delay: .05s; }
.brief > *:nth-child(3), .card > *:nth-child(3) { animation-delay: .1s; }
.brief > *:nth-child(4), .card > *:nth-child(4) { animation-delay: .15s; }
.card > *:nth-child(5) { animation-delay: .2s; }
.json-grid > * { animation: fadeUp .4s var(--ease) backwards; }
.json-grid > *:nth-child(2) { animation-delay: .09s; }
.editor { margin-top: 14px; }
.task-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.task-bar .step { font-size: 13px; color: var(--muted); }
.task-bar .counter { font-size: 14px; color: var(--ink); }
.task-bar .counter b { color: var(--accent); }
.prompt { font-size: 16px; font-weight: 500; margin: 0 0 16px; color: var(--ink); line-height: 1.5; }
.prompt b { color: var(--accent); }

.json-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .json-grid { grid-template-columns: 1fr; } }
.json-box {
  background: var(--code);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.85;
  overflow-x: auto; white-space: pre; color: var(--ink);
  transition: border-color .3s var(--ease);
}
.json-box .label { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.tok { border-radius: 5px; padding: 0 2px; transition: background .3s var(--ease), outline-color .3s var(--ease); }
.tok[data-path] { cursor: pointer; }
.tok-key { color: var(--t-key); }
.tok-str { color: var(--t-str); }
.tok-num { color: var(--t-num); }
.tok-bool { color: var(--t-bool); }
.tok-null { color: var(--t-null); }
.tok.sel-ok { background: var(--ok-soft); outline: 1px solid var(--ok); animation: popIn .32s var(--ease); }
.tok.sel-bad { background: var(--bad-soft); outline: 1px solid var(--bad); }

.codeblock { white-space: normal; padding: 14px 12px; }
.codeline { display: block; white-space: pre; padding: 2px 10px; border-radius: 6px; cursor: pointer; transition: background .25s var(--ease); }
.codeline:hover { background: rgba(127, 127, 127, 0.12); }
.codeline.sel-ok { background: var(--ok-soft); outline: 1px solid var(--ok); animation: popIn .32s var(--ease); }
.codeline.sel-bad { background: var(--bad-soft); outline: 1px solid var(--bad); }

.editor {
  width: 100%; min-height: 220px;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.7;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--code);
  color: var(--ink); resize: none; tab-size: 2;
  transition: border-color .25s var(--ease);
}
.editor:focus { outline: none; border-color: var(--muted); }

.spec { margin: 0 0 14px; border: 1px solid var(--glass-line); border-radius: 16px; overflow: hidden; }
.spec-row { display: grid; grid-template-columns: 1fr 130px 1fr; border-top: 1px solid var(--line); }
.spec-row:first-child { border-top: 0; }
.spec-row > div { padding: 12px 16px; font-size: 14.5px; }
.spec-row .k { font-family: var(--mono); color: var(--accent); }
.spec-row .t { color: var(--muted); font-size: 12.5px; align-self: center; }
.spec-row .v { font-family: var(--mono); color: var(--ink); }
.spec-head { background: var(--glass); }
.spec-head > div { padding: 9px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }

.convert { display: flex; align-items: center; gap: 16px; margin: 4px 0 6px; flex-wrap: wrap; }
.convert .from { font-family: var(--mono); font-size: 16px; background: var(--code); color: var(--ink); padding: 11px 15px; border-radius: 11px; border: 1px solid var(--line); }
.convert .arrow { color: var(--accent); font-size: 18px; }
.answer-input { font-family: var(--mono); font-size: 16px; padding: 11px 15px; border-radius: 11px; border: 1px solid var(--line); background: var(--code); color: var(--ink); min-width: 240px; transition: border-color .25s var(--ease); }
.answer-input:focus { outline: none; border-color: var(--muted); }

.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 11px 22px; font-size: 14.5px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .25s var(--ease), transform .15s var(--ease), border-color .25s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--glass); color: var(--ink); border: 1px solid var(--glass-line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn-ghost:hover { border-color: var(--muted); }
.feedback { margin-top: 18px; padding: 13px 16px; border-radius: 12px; font-size: 14.5px; display: none; }
.feedback.show { display: block; animation: fadeUp .3s var(--ease); }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }

.intro { max-width: 740px; margin: 0 auto; padding: 40px 24px 40px; animation: fadeUp .5s var(--ease); }
.intro-eyebrow { font-size: 13px; color: var(--accent); font-weight: 600; letter-spacing: .3px; }
.intro-title { font-size: 44px; font-weight: 800; letter-spacing: -1.2px; margin: 10px 0 22px; }
.intro-hero {
  display: flex; align-items: center; gap: 22px;
  border: 1px solid var(--glass-line); border-radius: 22px;
  padding: 38px 36px; margin: 0 0 36px;
  background: linear-gradient(135deg, rgba(244, 116, 28, 0.16), rgba(244, 116, 28, 0.03));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.hero-glyph { flex: 0 0 auto; width: 84px; height: 84px; border-radius: 20px; display: grid; place-items: center; font-family: var(--mono); font-size: 38px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.hero-name { line-height: 1.04; }
.hero-name span { display: block; font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.hero-name b { display: block; font-size: 19px; font-weight: 500; color: var(--muted); }
.hero-tag { margin-left: auto; align-self: flex-start; font-size: 12px; color: var(--muted); border: 1px solid var(--glass-line); padding: 5px 12px; border-radius: 999px; }
.intro-block { margin-bottom: 20px; }
.intro-block h2 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.intro-block p { color: var(--ink); font-size: 15.5px; font-weight: 500; line-height: 1.72; margin: 0 0 10px; }
.intro-block ul { color: var(--ink); font-size: 15.5px; font-weight: 500; line-height: 1.7; margin: 0; padding-left: 20px; }
.intro-block li { margin-bottom: 8px; }
.intro-block li::marker { color: var(--muted); }
.intro-start { display: block; margin: 22px auto 0; background: var(--ink); color: var(--bg); font-size: 15px; padding: 14px 32px; transition: filter .25s var(--ease); }
.intro-start:hover { filter: brightness(0.88); }
.intro-start:active { filter: brightness(0.78); }
@media (max-width: 640px) { .intro { padding: 34px 20px 70px; } .intro-title { font-size: 32px; } .intro-hero { padding: 26px 22px; flex-wrap: wrap; } }

.site-footer { margin-top: auto; position: relative; }
.site-footer::before { content: ""; position: absolute; top: 0; left: 44px; right: 44px; height: 1px; background: var(--line); }
.site-footer-inner {
  max-width: 1240px; margin: 0 auto; padding: 20px 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.footer-ver { font-size: 13px; color: var(--muted); letter-spacing: .2px; }
.footer-credit {
  font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .25s var(--ease);
}
.footer-credit:hover { color: var(--accent); }
@media (max-width: 640px) { .site-footer-inner { padding: 9px 20px; } }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { transform: scale(0.5); } 55% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes iconIn { from { opacity: 0; transform: rotate(-130deg) scale(0.35); } to { opacity: 1; transform: rotate(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
