:root {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2430;
  --surface-3: #272d3c;
  --border: #2e3547;
  --border-strong: #414b63;
  --text: #eef1f7;
  --text-muted: #98a2b8;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --cyan: #38bdf8;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--accent-hover);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #111;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Workspace Layout */
.workspace {
  display: grid;
  grid-template-columns: 340px minmax(420px, 1fr) 360px;
  gap: 16px;
  padding: 16px 20px 28px;
  max-width: 1760px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.step-badge {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #111;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* Cards */
.asset-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.asset-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35);
}

.asset-card.is-dragover {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
}

.formfactor-card {
  cursor: default;
}

.asset-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.asset-card h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
}

.tag-accent {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.tag-green {
  background: var(--green-soft);
  color: var(--green);
}

.paste-indicator {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.asset-card.is-active .paste-indicator {
  opacity: 1;
}

/* Inputs & Buttons */
input[type="url"],
input[type="text"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.url-row {
  display: flex;
  gap: 6px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drop-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  flex: 1;
}

.dim-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 11.5px;
}

.btn-primary {
  background: var(--accent);
  color: #111;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: #303749;
}

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-outline:hover {
  background: rgba(56, 189, 248, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-3);
}

/* Status & Scrape Gallery */
.status-msg {
  font-size: 11.5px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
}

.status-msg.is-error {
  background: var(--danger-soft);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.status-msg.is-success {
  background: var(--green-soft);
  color: #a7f3d0;
}

.scrape-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 175px;
  overflow-y: auto;
  padding-top: 2px;
}

.thumb-btn {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: #0b0d12;
  aspect-ratio: 4 / 3;
  cursor: pointer;
}

.thumb-btn:hover {
  border-color: var(--cyan);
}

.thumb-btn.is-chosen {
  border-color: var(--accent);
}

.thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.is-selected {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent);
}

.chip-xs {
  padding: 2px 8px;
  font-size: 11px;
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Stage (Center) */
.panel-stage {
  min-height: 680px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--surface-3);
  color: var(--text);
}

.stage-toggles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.05), transparent 55%),
    repeating-conic-gradient(#13161f 0% 25%, #171b26 0% 50%) 50% / 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

#stageCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.empty-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 17, 23, 0.72);
  padding: 20px;
  text-align: center;
  pointer-events: none;
}

.empty-box {
  max-width: 440px;
  background: rgba(23, 26, 35, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.empty-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.stage-caption {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 2px;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}

.control-label output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.control-item input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

/* Right Column: Bridge */
.bridge-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bridge-box h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}

.bridge-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.action-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.ai-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ai-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 6px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ai-tab.is-active {
  background: var(--surface-3);
  color: var(--accent-hover);
}

.ai-notice {
  font-size: 11.5px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.ai-notice.is-claude {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.bridge-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.lang-switch {
  display: flex;
  gap: 4px;
}

.sheet-preview-details {
  font-size: 12px;
  color: var(--text-muted);
}

.sheet-preview-details summary {
  cursor: pointer;
  padding: 4px 0;
}

#sheetCanvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-top: 6px;
  display: block;
  background: #0b0d12;
}

/* Toast & Modal */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.modal {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 560px;
  width: calc(100% - 32px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.modal-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.help-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.help-list strong {
  color: var(--text);
}

/* Responsive */
@media (max-width: 1340px) {
  .workspace {
    grid-template-columns: 320px 1fr;
  }
  .panel-bridge {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
