* { box-sizing: border-box; margin: 0; padding: 0; }

:root,
html[data-theme="ecg"] {
  --navy: #10233f;
  --navy-2: #1a3358;
  --gold: #c4a36a;
  --gold-hover: #d4b57e;
  --gold-2: #ad8b4e;
  --ink: #1c2430;
  --muted: #6d645b;
  --paper: #f4f1eb;
  --line: #e3ddd3;
  --card: #ffffff;
  --header-bg: #10233f;
  --header-fg: #ffffff;
  --header-muted: rgba(255, 255, 255, 0.72);
  --header-line: #c4a36a;
  --soft: #faf8f5;
  --radius: 2px;
  --accent-ink: #10233f;
  --font: "Geist", "Inter", sans-serif;
  --display: "Geist", "Inter", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 3px solid var(--header-line);
}

.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.theme-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--header-line);
  border-radius: 999px;
  background: transparent;
}

.theme-switch button {
  border: 0;
  background: transparent;
  color: var(--header-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.theme-switch button.active {
  background: var(--gold);
  color: var(--accent-ink);
}

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

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.brand-name {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  line-height: 1.1;
}

.brand-tag {
  margin-top: 2px;
  color: var(--header-muted);
  font-size: 13px;
}

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.upload-zone {
  padding: 88px 28px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  max-width: 820px;
  margin: 28px auto;
  box-shadow: 0 16px 40px rgba(16, 35, 63, 0.06);
}

.upload-kicker {
  color: var(--gold-2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.upload-zone h1,
.inquiry-card h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 40px;
  color: var(--navy);
  margin-bottom: 12px;
}

.upload-btn {
  display: inline-block;
  margin-top: 22px;
  padding: 14px 28px;
  background: var(--gold);
  color: var(--accent-ink);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.upload-btn:hover { background: var(--gold-hover); }

.upload-hint {
  color: var(--muted);
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.5;
}

.upload-status {
  color: var(--navy-2);
  margin-top: 16px;
  font-weight: 500;
  min-height: 20px;
}

.upload-error {
  color: #9b2c2c;
  margin-top: 16px;
  padding: 12px 20px;
  background: #fdecec;
  display: inline-block;
}

.upload-error:empty { display: none; }

.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: white;
  padding: 40px 56px;
  box-shadow: 0 12px 40px rgba(16, 35, 63, 0.16);
  text-align: center;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e7e1d8;
  border-top-color: var(--navy);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text { font-size: 15px; color: var(--navy); font-weight: 600; }

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: start;
}

.canvas-wrap {
  position: relative;
  order: 2;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px;
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  max-width: 100%;
  max-height: 82vh;
  display: block;
  cursor: default;
}

.scene-labels { position: absolute; inset: 0; pointer-events: none; }

.panel {
  order: 1;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 16px;
  max-height: 86vh;
  overflow-y: auto;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  padding: 9px 8px;
  border: 1px solid var(--line);
  background: #faf8f5;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.tab.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.panel-title {
  margin: 4px 0 12px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
}

.selection-window {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #faf8f5;
  min-height: 96px;
}

.selection-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-2);
  font-weight: 700;
  margin-bottom: 10px;
}

.selection-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.selection-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}

.selection-item + .selection-item { border-top: 1px solid var(--line); }

.selection-item img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  flex: 0 0 54px;
}

.selection-zone {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.selection-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
}

#generate-btn { margin-top: 0; }

.generate-status {
  margin: 8px 0 0;
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
}

.btn-primary,
.btn-want,
.btn-secondary {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  color: var(--accent-ink);
  border: none;
}

.btn-primary:hover { background: var(--gold-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

.btn-want {
  margin-top: 0;
  background: var(--navy);
  color: white;
  border: none;
}

.btn-want:hover { background: var(--navy-2); }

.btn-secondary {
  margin-top: 8px;
  background: white;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn-secondary:hover { background: #faf8f5; }

.subcat-filter {
  width: 100%;
  padding: 9px 10px;
  margin: 16px 0 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  background: white;
  color: var(--ink);
}

.thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.material-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  background: white;
}

.material-card:hover { border-color: var(--gold); }

.material-card.active {
  border-color: var(--navy);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.material-card img {
  width: 100%;
  height: 168px;
  object-fit: contain;
  object-position: center;
  background: #f6f5f2;
  display: block;
}

.material-title {
  font-size: 12px;
  line-height: 1.3;
  padding: 8px;
  color: var(--navy);
  font-weight: 600;
}

.inquiry-modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 63, 0.55);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.inquiry-modal[hidden] { display: none; }

.inquiry-card {
  width: min(520px, 100%);
  background: white;
  padding: 28px 28px 22px;
  position: relative;
  max-height: 92vh;
  overflow: auto;
  border-top: 3px solid var(--gold);
}

.inquiry-card h2 { font-size: 32px; }

.inquiry-lead {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.inquiry-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--navy);
}

.inquiry-attach {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  background: #faf8f5;
  border: 1px solid var(--line);
}

.inquiry-file {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--navy);
}

.inquiry-file img {
  width: 64px;
  height: 48px;
  object-fit: cover;
}

.inquiry-form,
#inquiry-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#inquiry-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

#inquiry-form input,
#inquiry-form textarea {
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 500;
}

.inquiry-error {
  color: #9b2c2c;
  font-size: 13px;
  min-height: 0;
}

.inquiry-error:empty { display: none; }

.inquiry-done {
  padding: 12px 0 4px;
  color: var(--navy);
  line-height: 1.5;
}

.use-note {
  max-width: 560px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.use-code {
  display: block;
  margin: 14px auto 0;
  padding: 10px 12px;
  max-width: 100%;
  overflow: auto;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--navy);
  font-size: 12px;
  text-align: left;
  white-space: pre-wrap;
}

html.is-embed .demo-only,
html.is-embed .use-note,
html.is-embed .use-code {
  display: none;
}

html[data-theme="cabinet"] {
  --navy: #242424;
  --navy-2: #3a3a3a;
  --gold: #c6e056;
  --gold-hover: #d4ec74;
  --gold-2: #6f8f12;
  --ink: #1d1d1d;
  --muted: #5e5e5e;
  --paper: #f3f3f1;
  --line: #e4e4e0;
  --header-bg: #ffffff;
  --header-fg: #1d1d1d;
  --header-muted: #6b6b6b;
  --header-line: #ececec;
  --soft: #f7f7f5;
  --radius: 999px;
  --accent-ink: #1d1d1d;
  --font: "Manrope", "Inter", sans-serif;
  --display: "Marcellus SC", "Times New Roman", serif;
}

html[data-theme="cabinet"] .brand-copy { display: none; }

html[data-theme="cabinet"] .brand-logo { height: 54px; }

html[data-theme="cabinet"] .upload-zone h1,
html[data-theme="cabinet"] .panel-title,
html[data-theme="cabinet"] .inquiry-card h2 {
  font-weight: 400;
  letter-spacing: 0.04em;
}

html[data-theme="cabinet"] .upload-zone,
html[data-theme="cabinet"] .panel,
html[data-theme="cabinet"] .canvas-wrap,
html[data-theme="cabinet"] .inquiry-card {
  border-radius: 16px;
}

html[data-theme="cabinet"] .tab,
html[data-theme="cabinet"] .material-card {
  border-radius: 12px;
}

html.is-embed body {
  min-height: 100%;
}

html.is-embed .app {
  padding: 12px;
}

html.is-embed .upload-zone {
  margin: 8px auto;
  padding: 56px 20px;
}

@media (max-width: 900px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .panel { max-height: none; }
  .upload-zone h1 { font-size: 32px; }
  .brand-tag { display: none; }
}
