:root {
  --bg-dark: #0f1115;
  --bg-elevated: #141820;
  --panel-bg: #1a1d23;
  --accent: #60a5fa;
  --accent-soft: #93c5fd;
  --accent-glow: rgba(96, 165, 250, 0.28);
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --border: #2d333f;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --editor-block-gap: 28px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Pretendard", system-ui, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(ellipse 70% 46% at 50% -18%, rgba(96, 165, 250, 0.14), transparent),
    radial-gradient(ellipse 50% 36% at 100% 12%, rgba(96, 165, 250, 0.05), transparent);
}

.app-container {
  min-height: 100vh;
}

.main-content {
  max-width: 1288px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.app-header {
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(96, 165, 250, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.logo-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-title-row h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo-title-row .accent {
  color: var(--accent);
}

.header-tagline {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

.btn-to-dashboard {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn-to-dashboard:hover {
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.12);
  color: #dbeafe;
}

.btn-to-dashboard::before {
  content: "←";
  font-size: 12px;
  opacity: 0.85;
}

.editor-ad {
  margin: 0 0 var(--editor-block-gap);
  min-height: var(--itz-ad-height, 90px);
  border-radius: var(--radius);
  background: var(--bg-control, #0a0c10);
  border: 1px dashed var(--border);
  display: block;
  overflow: hidden;
  line-height: 0;
}

.editor-ad.editor-ad-exempt {
  position: relative;
  z-index: 50;
  isolation: isolate;
}

.mode-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  margin-bottom: 8px;
  background: linear-gradient(180deg, #0f1115 70%, transparent);
}

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-btn,
.btn-ghost,
.btn-primary {
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}

.mode-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  padding: 8px 14px;
}

.mode-btn.is-active {
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(96, 165, 250, 0.16);
  color: #dbeafe;
}

.mode-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  padding: 8px 14px;
}

.btn-ghost:hover {
  border-color: rgba(96, 165, 250, 0.45);
}

.btn-primary {
  border: 0;
  background: var(--accent);
  color: #0b1220;
  padding: 8px 16px;
}

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

.mode-note {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-dim);
}

.section-jump {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}

.side-nav {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.nav-item small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-item.is-active {
  background: var(--panel-bg);
  border-color: var(--border);
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 28px;
  min-height: 420px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.panel h3 {
  margin: 22px 0 10px;
  font-size: 14px;
  color: var(--accent-soft);
}

.lead,
.note,
.field-hint {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
}

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

.warn {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  font-size: 13px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}

input,
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  background: #12151b;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.choice,
.check-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.choice input,
.check-line input {
  width: auto;
  margin-top: 3px;
}

.choice small,
.check-line small {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-weight: 500;
}

.choice--danger,
.check-line.is-danger {
  border-color: rgba(248, 113, 113, 0.4);
}

.chip-grid,
.check-stack {
  display: grid;
  gap: 8px;
}

.chip-grid {
  grid-template-columns: 1fr 1fr;
}

.more {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px 8px;
}

.more summary {
  cursor: pointer;
  font-weight: 650;
  padding: 10px 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.arch-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 16px;
}

.howto {
  margin: 8px 0 28px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.howto h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.howto ol,
.howto ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

.howto code {
  font-size: 12px;
  background: var(--bg-control, #0b0d12);
  padding: 1px 6px;
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--panel-bg, #1e293b);
  border: 1px solid var(--border);
  color: #e2e8f0;
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.toast.is-error {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.preview-dialog {
  width: min(920px, 94vw);
  max-height: 80vh;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-bg, #0f1115);
  color: var(--text-main);
  padding: 0;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.preview-code {
  margin: 0;
  padding: 16px;
  overflow: auto;
  max-height: calc(80vh - 56px);
  font-size: 12px;
  line-height: 1.45;
  color: #cbd5e1;
}

.tool-guide {
  max-width: none;
}

@media (max-width: 860px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  .main-content {
    padding: 20px 14px calc(120px + env(safe-area-inset-bottom, 0px));
  }

  .logo-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .logo-title-row h1 {
    font-size: 1.35rem;
    line-height: 1.25;
  }

  .header-tagline {
    font-size: 13.5px;
    line-height: 1.55;
  }

  .btn-to-dashboard {
    min-height: 40px;
  }

  .mode-bar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 0 0 8px;
    background: none;
  }

  .modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mode-btn {
    min-height: 42px;
    text-align: center;
  }

  .mode-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 17, 21, 0.94);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .mode-actions .btn-ghost {
    min-height: 44px;
    width: 100%;
    font-size: 13px;
    padding: 8px 8px;
  }

  .mode-actions .btn-primary {
    grid-column: 1 / -1;
    min-height: 44px;
    width: 100%;
  }

  .mode-note {
    margin-bottom: 10px;
  }

  .section-jump {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
  }

  .section-jump-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
  }

  .section-jump select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
    font-weight: 650;
    min-height: 44px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .side-nav {
    display: none;
  }

  .panel {
    padding: 16px 16px 22px;
    min-height: 0;
  }

  .panel h2 {
    font-size: 17px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }

  textarea {
    min-height: 96px;
  }

  .grid2,
  .chip-grid {
    grid-template-columns: 1fr;
  }

  .howto {
    padding: 16px;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }

  .preview-dialog {
    width: 100%;
    max-width: 100vw;
    max-height: 92vh;
    margin: 0;
    border-radius: 12px 12px 0 0;
  }

  .editor-ad,
  .editor-ad .adsbygoogle,
  .editor-ad[data-adsense-empty="1"] {
    min-height: var(--itz-ad-height, 90px);
  }
}

/* itz-theme-contrast */
html[data-theme="light"] .option-card label,
html[data-theme="light"] .option-hint,
html[data-theme="light"] .path-hint,
html[data-theme="light"] .range-val,
html[data-theme="light"] .preset-label,
html[data-theme="light"] .chips-label,
html[data-theme="light"] .size-pill {
  color: #0f172a !important;
}
html[data-theme="light"] .chip:not(.active):not(.is-on),
html[data-theme="light"] .preset-btn:not(.active) {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .chip.active {
  background: var(--accent, #3b82f6) !important;
  color: #ffffff !important;
}
html[data-theme="light"] .path-row input,
html[data-theme="light"] .option-card input[type="number"],
html[data-theme="light"] .option-card input[type="text"] {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .btn-pick-file {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .media-summary-panel {
  background: #f1f5f9;
}
html[data-theme="light"] .media-summary-title,
html[data-theme="light"] .media-summary-hint,
html[data-theme="light"] .media-summary-item dt,
html[data-theme="light"] .media-summary-item dd {
  color: #0f172a;
}
html[data-theme="dark"] .chip:not(.active):not(.is-on) {
  color: #e2e8f0;
}
html[data-theme="dark"] .chip.active {
  color: #ffffff;
}
html[data-theme="dark"] .range-val {
  color: #e2e8f0;
}
html[data-theme="dark"] .path-row input,
html[data-theme="dark"] .option-card input[type="number"],
html[data-theme="dark"] .option-card input[type="text"] {
  color: #ffffff;
}

/* itz-theme-controls */
html[data-theme="light"] .toggle-card {
  background: var(--bg-control, #f8fafc) !important;
  border-color: var(--border, #d8dee8);
  color: #0f172a;
}
html[data-theme="light"] .toggle-card-title,
html[data-theme="light"] .option-label,
html[data-theme="light"] .check-label {
  color: #0f172a !important;
}
html[data-theme="light"] .toggle-card-desc,
html[data-theme="light"] .option-hint,
html[data-theme="light"] .choice small,
html[data-theme="light"] .check-line small {
  color: #475569 !important;
}
html[data-theme="light"] .toggle-card:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 12%, #ffffff) !important;
  border-color: color-mix(in srgb, var(--accent) 42%, #d8dee8);
}
html[data-theme="light"] .toggle-card.is-disabled,
html[data-theme="light"] .toggle-card.is-disabled:has(input:checked) {
  opacity: 0.72;
  background: var(--bg-control-muted, #e8eef4) !important;
}
html[data-theme="light"] .toggle-card.is-disabled .toggle-card-title,
html[data-theme="light"] .toggle-card.is-disabled .toggle-card-desc {
  color: #64748b !important;
}
html[data-theme="light"] .option-select,
html[data-theme="light"] .option-field select {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .choice,
html[data-theme="light"] .check-line {
  background: var(--bg-control, #f8fafc) !important;
  color: #0f172a;
}
html[data-theme="light"] .mode-chip:not(.active):not(.is-on) {
  background: var(--bg-control, #f8fafc) !important;
  color: #334155 !important;
}
html[data-theme="light"] .mode-chip.active,
html[data-theme="light"] .mode-chip.is-on {
  background: var(--accent, #3b82f6) !important;
  color: #ffffff !important;
}
html[data-theme="light"] .size-pill:not(:has(input:checked)) {
  background: #f8fafc !important;
  color: #334155 !important;
}
html[data-theme="light"] .size-pill:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 16%, #ffffff) !important;
  color: #0c4a6e !important;
}
html[data-theme="light"] .btn-pick-file:hover:not(:disabled) {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .toast {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .preview-dialog {
  background: #ffffff !important;
  color: #0f172a !important;
}
html[data-theme="light"] .howto code {
  background: #e8eef4 !important;
  color: #0f172a !important;
}
html[data-theme="light"] .btn-action--download:not(.is-disabled) {
  color: #0f766e !important;
}
html[data-theme="dark"] .toggle-card-title,
html[data-theme="dark"] .option-label {
  color: var(--text-main, #e2e8f0);
}
html[data-theme="dark"] .toggle-card-desc,
html[data-theme="dark"] .option-hint,
html[data-theme="dark"] .choice small,
html[data-theme="dark"] .check-line small {
  color: var(--text-subtle, #94a3b8);
}
html[data-theme="dark"] .option-select {
  background: var(--bg-control, #0f1318);
  color: var(--text-main, #e2e8f0);
}
html[data-theme="dark"] .path-row input {
  background: var(--bg-control, #0f1318);
  color: var(--text-main, #ffffff);
}
html[data-theme="dark"] .mode-chip:not(.active):not(.is-on) {
  color: #cbd5e1;
}
html[data-theme="dark"] .size-pill:has(input:checked) {
  color: #e0f2fe;
}
