/* 오지포지 — 크리에이티브 스튜디오 크롬. 무채색 셸 + 단일 인디고 액센트.
 * 캔버스(유저 작품)가 주인공; UI는 절제. */

/* ============ 토큰 (dark 기본) ============ */
:root,
[data-theme="dark"] {
  --bg: #0e0f14;
  --bg-2: #08090d;
  --surface: #16181f;
  --surface-2: #1d2029;
  --ink: #eceef3;
  --muted: #8b909c;
  --faint: #5b6070;
  --line: #2a2e38;
  --line-soft: #1f222b;
  --accent: #818cf8;
  --accent-deep: #6366f1;
  --accent-ink: #0b0d17;
  --pass: #34d399;
  --fail: #fb7185;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-2: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --ink: #14161c;
  --muted: #626776;
  --faint: #9aa0ad;
  --line: #e3e5ea;
  --line-soft: #ecedf1;
  --accent: #4f46e5;
  --accent-deep: #4338ca;
  --accent-ink: #ffffff;
  --pass: #059669;
  --fail: #e11d48;
  --shadow: 0 14px 40px rgba(20, 20, 30, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Pretendard", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.18s ease, color 0.18s ease;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ 헤더 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.brand h1 {
  margin: 0; font-family: "Space Grotesk", sans-serif;
  font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
}
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.brand .accent { color: var(--accent); font-weight: 600; }

.offline-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: var(--radius-pill);
}
.offline-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pass) 22%, transparent);
}

/* ============ 레이아웃 ============ */
.wrap {
  max-width: 1320px; margin: 0 auto;
  padding: 18px 20px 40px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.controls { padding: 6px 18px 18px; }

/* ============ 컨트롤 블록 ============ */
.ctrl-block { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.ctrl-block:last-of-type { border-bottom: none; }
.ctrl-head {
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px; color: var(--muted); font-weight: 500;
  display: inline-flex; align-items: baseline; gap: 5px;
}
.field-label .unit { font-size: 10.5px; color: var(--faint); }
.opt-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 12px;
}
.opt-grid .field { margin: 0; }

input[type="text"], textarea, select {
  width: 100%;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-family: inherit; font-size: 13.5px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
textarea { resize: vertical; min-height: 56px; line-height: 1.45; }
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b909c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px; cursor: pointer;
}

/* range */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: var(--line); cursor: pointer; margin: 6px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
.range-val {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  color: var(--ink); font-variant-numeric: tabular-nums;
}

/* color input */
.color-input {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 4px 8px 4px 4px;
}
.color-input input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 24px; padding: 0; border: none;
  background: none; cursor: pointer; border-radius: 5px;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 4px; }
.color-input code {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}

/* segmented control */
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 3px; gap: 2px; width: fit-content;
}
.seg-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 5px; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* preset grid */
.preset-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.preset-card {
  position: relative; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 11px 12px; cursor: pointer; text-align: left;
  font-family: inherit; color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.preset-card:hover { border-color: var(--accent); }
.preset-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
}
.preset-name { font-size: 12.5px; font-weight: 600; }
.preset-meta {
  font-family: "JetBrains Mono", monospace; font-size: 10.5px;
  color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums;
}
.preset-thumb {
  position: absolute; top: 10px; right: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-radius: 3px;
}
.preset-card.active .preset-thumb { box-shadow: 0 0 0 2px var(--surface); }

/* checkbox */
.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink); margin-top: 12px; cursor: pointer;
}
.check input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
}

/* actions */
.actions-row { display: flex; gap: 10px; padding-top: 16px; }
.btn {
  height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 0 18px; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); flex: 1 1 auto;
}
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-ghost { background: transparent; }

/* ============ 프리뷰 ============ */
.preview { padding: 16px; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.panel-title {
  font-family: "Space Grotesk", sans-serif; font-size: 15px; font-weight: 700;
}
.size-info {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.canvas-wrap {
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%)
    50% / 20px 20px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; display: flex; align-items: center; justify-content: center;
  min-height: 240px; overflow: hidden;
}
#ogCanvas {
  max-width: 100%; max-height: 60vh; height: auto; width: auto;
  box-shadow: var(--shadow); border-radius: 4px;
  background: #fff;
}
.preview-note { color: var(--muted); font-size: 11.5px; margin: 10px 0 0; text-align: center; }

/* ============ 광고 슬롯 ============ */
.ad-slot {
  border: 1px dashed var(--line); border-radius: var(--radius);
  margin: 0 0 18px; padding: 14px; text-align: center;
  color: var(--faint); font-size: 12px; position: relative;
  min-height: 56px;
}
.ad-slot .ad-label {
  position: absolute; top: 6px; left: 10px;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint);
}
.ad-slot .ad-ph { padding-top: 14px; }
.ad-slot:not(.is-preview):not(.is-live) { display: none; }

/* ============ 정보 섹션 ============ */
.info { margin-top: 26px; }
.info h2 {
  font-family: "Space Grotesk", sans-serif; font-size: 16px; font-weight: 700;
  margin: 22px 0 8px;
}
.info p, .info dd { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin: 0 0 8px; }
.info dt { color: var(--ink); font-weight: 600; font-size: 13.5px; margin-top: 14px; }
.faq dt:first-of-type { margin-top: 0; }

/* ============ 푸터 ============ */
.foot {
  max-width: 1320px; margin: 0 auto; padding: 18px 20px 50px;
  border-top: 1px solid var(--line); margin-top: 20px;
}
.foot a { color: var(--muted); font-size: 12.5px; text-decoration: none; }
.foot a:hover { color: var(--accent); }

/* ============ 토스트 ============ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

[hidden] { display: none !important; }

/* ============ 반응형 ============ */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  #ogCanvas { max-height: 48vh; }
}
@media (max-width: 560px) {
  .preset-grid { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .wrap { padding: 14px 14px 36px; }
}

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

/* 언어 스위처 테마 브릿지 */
.i18n-switch {
  --i18n-switch-bg: rgba(128,128,128,.12);
  --i18n-switch-border: rgba(128,128,128,.28);
  --i18n-switch-active-bg: rgba(129,140,248,.2);
  --i18n-switch-active-fg: #818cf8;
  --i18n-switch-menu-border: rgba(128,128,128,.28);
}
[data-theme="dark"] .i18n-switch { --i18n-switch-fg: rgba(255,255,255,.9); --i18n-switch-menu-bg: #16181f; }
[data-theme="light"] .i18n-switch { --i18n-switch-fg: rgba(20,22,28,.92); --i18n-switch-menu-bg: #ffffff; }
