:root {
  color-scheme: dark;
  font-family: "Noto Sans KR", Inter, "Apple SD Gothic Neo", system-ui, sans-serif;
  --page: #11110f;
  --panel: #171714;
  --panel-raised: #1d1d19;
  --input: #20201c;
  --line: #2c2b26;
  --line-strong: #3b3932;
  --muted: #918e84;
  --soft: #c8c3b7;
  --text: #eeeae1;
  --accent: #ded7c9;
  --accent-hover: #f1ede4;
  --accent-ink: #1c1b17;
  --grid: rgba(255,255,255,0.035);
  --shadow: rgba(0,0,0,0.28);
  --glass: rgba(17,17,15,0.88);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #e8e4da;
  --panel: #f2eee5;
  --panel-raised: #faf7f0;
  --input: #eae5da;
  --line: #d2cbbd;
  --line-strong: #bbb3a5;
  --muted: #777168;
  --soft: #5d5850;
  --text: #25231f;
  --accent: #302e29;
  --accent-hover: #181713;
  --accent-ink: #f7f3ea;
  --grid: rgba(42,39,33,0.045);
  --shadow: rgba(60,53,43,0.12);
  --glass: rgba(242,238,229,0.9);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: linear-gradient(145deg, var(--page), color-mix(in srgb, var(--page) 90%, var(--panel-raised)));
  color: var(--text);
}

button, input, select { font: inherit; }
button, select, input[type="date"], input[type="color"], input[type="checkbox"] { cursor: pointer; }
.app-shell { min-height: 100vh; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 11px; font-size: 15px; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-family: ui-monospace, monospace; font-weight: 900; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle { height: 36px; padding: 3px; display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); }
.theme-toggle button { width: 29px; border: 0; border-radius: 7px; display: grid; place-items: center; background: transparent; color: var(--muted); }
.theme-toggle button.is-active { background: var(--panel-raised); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.theme-toggle svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 0 15px; color: var(--text); font-size: 13px; font-weight: 700; transition: transform 150ms ease, border-color 150ms ease, background 150ms ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-ghost { background: transparent; border-color: var(--line); }
.button-ghost:hover { background: var(--panel-raised); }
.button-primary { background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; gap: 8px; }
.button-primary:hover { background: var(--accent-hover); }
.button-primary svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.workspace { min-height: calc(100vh - 72px); display: grid; grid-template-columns: minmax(340px, 430px) minmax(0, 1fr); }
.control-panel { border-right: 1px solid var(--line); padding: 36px clamp(24px, 3vw, 42px) 60px; background: color-mix(in srgb, var(--panel) 94%, transparent); }
.panel-heading { margin-bottom: 36px; }
.panel-heading .eyebrow { margin: 0 0 10px; color: var(--muted); font: 700 10px/1 ui-monospace, monospace; letter-spacing: 0.14em; }
.panel-heading h1 { margin: 0; font-size: 25px; letter-spacing: -0.04em; }
.panel-heading > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.settings-section { padding: 0 0 30px; margin: 0 0 30px; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; margin-bottom: 0; }
.settings-section h2 { margin: 0 0 17px; color: var(--soft); font-size: 12px; letter-spacing: 0.01em; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field, .range-field, .color-field { display: grid; gap: 8px; }
.field-wide { margin-bottom: 12px; }
.field span, .range-field > span, .color-field > span:first-child { color: var(--muted); font-size: 11px; font-weight: 650; }
.field small, .range-field small { color: color-mix(in srgb, var(--muted) 74%, transparent); font-weight: 500; }

.field input, .field select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--text); padding: 0 12px; outline: none; font-size: 13px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.field input:focus, .field select:focus { border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.field input::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 11px) 17px; background-size: 4px 4px; background-repeat: no-repeat; }

.range-field { margin-top: 18px; }
.range-field-compact { margin: 0 0 20px; }
.range-field > span { display: flex; align-items: center; gap: 6px; }
.range-field output { margin-left: auto; color: var(--soft); font: 600 11px/1 ui-monospace, monospace; }
input[type="range"] { width: 100%; height: 3px; appearance: none; background: var(--line-strong); border-radius: 99px; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--line-strong); }

.segmented { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border: 1px solid var(--line); background: var(--input); border-radius: 9px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 8px; border-radius: 6px; text-align: center; color: var(--muted); font-size: 11px; cursor: pointer; }
.segmented input:checked + label { background: var(--panel-raised); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); }

.color-control { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.color-control input { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; overflow: hidden; background: transparent; }
.color-control input::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input::-webkit-color-swatch { border: 0; border-radius: 4px; }
.color-control code { color: var(--soft); font: 500 11px/1 ui-monospace, monospace; text-transform: uppercase; }

.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 18px; cursor: pointer; }
.switch-row span { display: grid; gap: 4px; }
.switch-row strong { font-size: 12px; }
.switch-row small { color: var(--muted); font-size: 10px; }
.switch-row input { width: 37px; height: 21px; flex: 0 0 auto; appearance: none; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--input); position: relative; transition: 150ms ease; }
.switch-row input::after { content: ""; position: absolute; width: 15px; height: 15px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); transition: 150ms ease; }
.switch-row input:checked { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked::after { left: 18px; background: var(--accent-ink); }

.preview-panel { min-width: 0; padding: 32px clamp(24px, 5vw, 76px); display: flex; flex-direction: column; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; color: var(--muted); font-size: 11px; }
.preview-status { display: flex; align-items: center; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--soft); box-shadow: 0 0 0 4px color-mix(in srgb, var(--soft) 10%, transparent); }
.preview-size-label { margin-left: 9px; padding-left: 9px; border-left: 1px solid var(--line); color: var(--muted); font: 600 9px/1 ui-monospace, monospace; }
.text-button { border: 0; background: none; color: var(--soft); font-size: 11px; }
.text-button:hover { color: var(--text); }

.preview-stage { min-height: 430px; flex: 1; padding: clamp(18px, 4vw, 48px); border: 1px solid var(--line); border-radius: 20px; display: grid; place-items: center; overflow: auto; background-color: var(--panel); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 22px 22px; box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 3%, transparent), 0 24px 70px var(--shadow); }

.widget-frame { --widget-bg: #1e1e1e; --widget-fg: #e0ffff; --widget-size: 64px; --widget-fitted-size: var(--widget-size); --widget-title-base-size: 16px; --widget-title-size: var(--widget-title-base-size); --widget-note-base-size: 14px; --widget-note-size: var(--widget-note-base-size); --widget-weight: 700; --widget-spacing: 0px; --widget-radius: 0px; --widget-align: center; --widget-font: "Noto Sans KR", system-ui, sans-serif; width: min(100%, 760px); min-height: 210px; border-radius: var(--widget-radius); padding: clamp(22px, 5vw, 52px); display: flex; flex-direction: column; justify-content: center; text-align: var(--widget-align); background: var(--widget-bg); color: var(--widget-fg); overflow: hidden; transition: background 180ms ease, color 180ms ease, border-radius 180ms ease; }
.widget-frame.is-transparent { background: transparent; }
.widget-title { margin: 0 0 10px; opacity: 0.64; font-family: var(--widget-font); font-size: var(--widget-title-size); font-weight: 550; letter-spacing: 0.04em; }
.widget-title:empty, .widget-note:empty { display: none; }
.widget-count { margin: 0; font-family: var(--widget-font); font-size: var(--widget-fitted-size); font-weight: var(--widget-weight); letter-spacing: var(--widget-spacing); line-height: 1.05; white-space: nowrap; }
.widget-note { margin: 12px 0 0; opacity: 0.62; font-family: var(--widget-font); font-size: var(--widget-note-size); font-weight: 450; letter-spacing: 0.02em; }
.widget-frame.has-shadow .widget-count { text-shadow: 0 5px 24px rgba(0,0,0,0.42); }

#widgetFrame { position: relative; height: 240px; min-height: 120px; max-height: 640px; flex: 0 0 auto; }
.preview-resizer { position: absolute; z-index: 2; padding: 0; border: 2px solid rgba(255,255,255,0.72); background: rgba(17,19,24,0.82); touch-action: none; opacity: 0.72; transition: opacity 120ms ease, border-color 120ms ease, background 120ms ease; }
.preview-resizer:hover, .preview-resizer:focus-visible { opacity: 1; border-color: #f0ece4; background: #24231f; outline: none; }
.preview-resizer:focus-visible { box-shadow: 0 0 0 2px rgba(255,255,255,0.2); }
.preview-resizer-x { width: 12px; height: 72px; right: 8px; top: 50%; transform: translateY(-50%); border-radius: 99px; cursor: ew-resize; }
.preview-resizer-y { width: 96px; height: 12px; left: 50%; bottom: 8px; transform: translateX(-50%); border-radius: 99px; cursor: ns-resize; }
.preview-resizer-both { width: 34px; height: 30px; right: 8px; bottom: 8px; border-top: 0; border-left: 0; border-right-width: 4px; border-bottom-width: 4px; border-radius: 0 0 5px; background: transparent; cursor: nwse-resize; }

.link-card { margin-top: 18px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--panel-raised) 88%, transparent); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.link-card strong { font-size: 12px; }
.link-card p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
kbd { border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 4px; background: var(--input); color: var(--soft); font: 500 9px ui-monospace, monospace; }
.mini-button { min-height: 34px; flex: 0 0 auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--soft); display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; }
.mini-button svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.mini-button:hover { border-color: var(--line-strong); color: var(--text); }

.usage-guide { margin-top: 18px; padding: clamp(22px, 3vw, 30px); border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, var(--panel-raised), var(--panel)); }
.guide-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.guide-heading > p { max-width: 280px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.guide-eyebrow { margin: 0 0 7px; color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: 0.14em; }
.guide-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.035em; }
.guide-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0; padding: 24px 0; list-style: none; }
.guide-steps li { min-width: 0; padding: 0 20px; border-right: 1px solid var(--line); }
.guide-steps li:first-child { padding-left: 0; }
.guide-steps li:last-child { padding-right: 0; border-right: 0; }
.step-number { display: block; margin-bottom: 13px; color: var(--muted); font: 700 10px/1 ui-monospace, monospace; }
.guide-steps strong { display: block; font-size: 12px; letter-spacing: -0.02em; }
.guide-steps p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; word-break: keep-all; }
.guide-steps b { color: var(--soft); font-weight: 650; }
.guide-note { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); }
.guide-note > span { width: 18px; height: 18px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 800 11px/1 Georgia, serif; }
.guide-note p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.guide-note strong { color: var(--text); font-weight: 700; }

.embed-shell { display: none; width: 100vw; height: 100vh; min-height: 100%; }
.embed-shell .widget-frame { width: 100%; height: 100%; min-height: 100%; padding: clamp(8px, 4vmin, 52px); border-radius: min(var(--widget-radius), 12vmin); }
body.embed-mode { overflow: hidden; background: transparent; }
body.embed-mode .app-shell, body.embed-mode .toast { display: none; }
body.embed-mode .embed-shell { display: flex; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-raised); color: var(--text); box-shadow: 0 16px 50px var(--shadow); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { min-height: 650px; }
  .guide-heading { align-items: start; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding: 0 16px; }
  .brand > span:last-child { display: none; }
  .theme-toggle { height: 34px; }
  .theme-toggle button { width: 26px; }
  .button { padding: 0 11px; }
  .button-primary svg { display: none; }
  .workspace { min-height: calc(100vh - 64px); }
  .control-panel, .preview-panel { padding-left: 18px; padding-right: 18px; }
  .preview-stage { min-height: 330px; border-radius: 16px; }
  .widget-frame { min-height: 180px; padding: 22px 16px; }
  .link-card p { line-height: 1.5; }
  .guide-heading { display: grid; gap: 10px; }
  .guide-heading > p { max-width: none; }
  .guide-steps { grid-template-columns: 1fr; padding-bottom: 20px; }
  .guide-steps li, .guide-steps li:first-child, .guide-steps li:last-child { padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .guide-steps li:last-child { border-bottom: 0; }
  .step-number { margin-bottom: 8px; }
}

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