/* 아이디포토 — 유틸리티·정밀(그리드/가이드 강조, 중립 배경).
 * 무채색 크롬 + 단일 시안(cyan) 액센트. 캔버스·가이드가 주인공. */

/* ============ 토큰 (dark 기본) ============ */
:root,
[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161922;
  --surface-2: #1d212c;
  --ink: #eceef3;
  --muted: #8b909c;
  --faint: #5b6070;
  --line: #2a2e38;
  --line-soft: #1f222b;
  --accent: #22d3ee;
  --accent-deep: #06b6d4;
  --accent-ink: #04242b;
  --pass: #34d399;
  --fail: #fb7185;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --guide: #22d3ee;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --ink: #14161c;
  --muted: #626776;
  --faint: #9aa0ad;
  --line: #e3e5ea;
  --line-soft: #ecedf1;
  --accent: #0891b2;
  --accent-deep: #0e7490;
  --accent-ink: #ffffff;
  --pass: #059669;
  --fail: #e11d48;
  --shadow: 0 14px 40px rgba(20, 20, 30, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --guide: #0891b2;
  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, "Apple SD Gothic Neo", 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;
}

[hidden] { display: none !important; }

/* ============ 헤더 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 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; }
.logo {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
}
.brand h1 { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.brand p .accent { color: var(--accent); font-weight: 600; }

.offline-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600; color: var(--pass);
  background: color-mix(in srgb, var(--pass) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--pass) 30%, transparent);
  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);
}

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.14s ease;
}
.icon-btn:hover { background: var(--surface-2); }

/* ============ 레이아웃 ============ */
.wrap {
  max-width: 1320px; margin: 0 auto;
  padding: 18px 20px 60px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  margin-bottom: 22px;
}
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 15px; font-weight: 600; }
.panel-title.sub { margin-bottom: 6px; }
.panel-note, .hint { color: var(--muted); font-size: 12px; }
.hint { margin: 8px 0 0; }

.stage-panel { display: flex; flex-direction: column; gap: 14px; }

/* ============ 업로드 ============ */
.drop-zone {
  position: relative;
  border: 2px dashed color-mix(in srgb, var(--muted) 50%, transparent);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.drop-zone:hover, .drop-zone.drag {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.drop-icon { font-size: 30px; }
.drop-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 15px; }
.drop-hint { color: var(--muted); font-size: 12.5px; max-width: 360px; }
.drop-zone .btn.primary { pointer-events: auto; margin-top: 4px; }

.replace-btn { align-self: flex-start; }

/* ============ 버튼/셀렉트 ============ */
.btn, .select {
  height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.14s ease, transform 0.06s ease, border-color 0.14s ease;
}
.btn { padding: 0 14px; }
.select { padding: 0 10px; width: 100%; }
.btn:hover, .select:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; }

/* ============ 크롭 ============ */
.crop-wrap { display: flex; flex-direction: column; gap: 10px; }
.crop-stage { display: flex; justify-content: center; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.crop-frame { position: relative; width: 100%; max-width: 640px; aspect-ratio: 640 / 480; }
.crop-canvas, .crop-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; border-radius: 6px;
}
.crop-overlay { pointer-events: none; }
.crop-canvas { background: var(--surface-2); touch-action: none; cursor: grab; }
.crop-canvas:active { cursor: grabbing; }

.controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  margin-top: 4px;
}
.ctrl { display: flex; flex-direction: column; gap: 5px; }
.ctrl label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.ctrl-actions { grid-column: 1 / -1; align-items: flex-end; }
.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--line);
  outline: none; cursor: pointer;
}
.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,.3); cursor: pointer;
}
.range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); cursor: pointer;
}

/* ============ 규격 정보 ============ */
.spec-info { margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; }
.si-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.si-row:last-child { border-bottom: none; }
.si-row dt { font-size: 12px; color: var(--muted); margin: 0; }
.si-row dd { margin: 0; font-size: 13px; font-weight: 500; text-align: right; }
.disclaimer { margin: 10px 0 0; font-size: 11px; color: var(--muted); line-height: 1.55; }

/* ============ 내보내기 ============ */
.preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; }
.preview-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.preview-canvas-wrap {
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-2) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px; display: flex; align-items: center; justify-content: center;
  max-width: 100%;
}
.preview-canvas { display: block; max-width: 100%; height: auto; max-height: 280px; border-radius: 3px; }
.actual-size { font-size: 11.5px; color: var(--muted); text-align: center; }

.export-panel .ctrl { margin-bottom: 10px; }
.export-actions { display: flex; gap: 8px; margin-top: 6px; }
.export-actions .btn { flex: 1 1 auto; }

.soon-panel { opacity: 0.7; }
.soon-panel .panel-title { color: var(--muted); }

/* ============ 인포 / FAQ ============ */
.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 22px;
}
.info-panel .info-title { font-family: "Space Grotesk", sans-serif; font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.info-body { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0; }
.faq { border-bottom: 1px solid var(--line-soft); padding: 8px 0; }
.faq:last-child { border-bottom: none; }
.faq summary { cursor: pointer; font-size: 13px; font-weight: 600; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "▸ "; color: var(--accent); }
.faq[open] summary::before { content: "▾ "; }
.faq p { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.65; }

/* ============ 푸터 ============ */
.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.foot-link { color: var(--accent); text-decoration: none; }
.foot-link:hover { text-decoration: underline; }

/* ============ 광고 슬롯 ============ */
.ad-slot { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 18px; min-height: 56px; display: none; }
.ad-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.ad-ph { color: var(--faint); font-size: 11px; margin-top: 6px; }

/* ============ 토스트 ============ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; 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); }

/* ============ 반응형 ============ */
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .controls { grid-template-columns: 1fr; }
  .brand p { display: none; }
}

@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,.14);
  --i18n-switch-border: rgba(128,128,128,.3);
  --i18n-switch-active-bg: rgba(34,211,238,.22);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-border: rgba(128,128,128,.3);
}
[data-theme="dark"] .i18n-switch { --i18n-switch-fg: rgba(255,255,255,.9); --i18n-switch-menu-bg: #161922; }
[data-theme="light"] .i18n-switch { --i18n-switch-fg: rgba(20,20,25,.92); --i18n-switch-menu-bg: #ffffff; }
