:root {
  color-scheme: light;
  --paper: #fbfaf4;
  --cream: #f6f3eb;
  --parchment: #f3f1e6;
  --line: #d6d0c2;
  --ink: #2c2a22;
  --olive: #46422f;
  --muted: #6f6f5e;
  --copper: #cd6934;
  --serif: "Minerva Modern", "Cormorant Garamond", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.designer-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.viewer-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(251, 250, 244, 0.22), rgba(243, 241, 230, 0.88)),
    radial-gradient(circle at 54% 40%, rgba(255, 255, 255, 0.92), rgba(246, 243, 235, 0) 31rem),
    var(--cream);
}

.viewer-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(44, 42, 34, 0.05), transparent 32%, transparent 70%, rgba(44, 42, 34, 0.06));
}

.viewer-copy {
  position: absolute;
  z-index: 2;
  top: 34px;
  left: clamp(20px, 4vw, 56px);
  max-width: 380px;
}

.viewer-copy p,
.panel-heading p {
  margin: 0 0 12px;
  color: var(--copper);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.viewer-copy h1,
.panel-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.12;
}

.viewer-copy h1 {
  font-size: clamp(28px, 3.2vw, 46px);
}

.viewer {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
}

.status-bar {
  position: absolute;
  z-index: 2;
  left: clamp(20px, 4vw, 56px);
  right: clamp(20px, 4vw, 56px);
  bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(70, 66, 47, 0.24);
  color: var(--muted);
  font-size: 12px;
}

.tuning-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  overflow: auto;
  padding: 42px 34px;
  background: var(--paper);
}

.panel-heading h2 {
  font-size: 34px;
}

.accent-line {
  display: block;
  width: 54px;
  height: 1px;
  margin-top: 18px;
  background: var(--copper);
}

.height-card {
  display: grid;
  gap: 18px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.height-card label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.height-card strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
}

.height-scope {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.option-group {
  display: grid;
  gap: 12px;
}

.option-group > span {
  color: var(--muted);
  font-size: 13px;
}

.option-grid {
  display: grid;
  gap: 10px;
}

.option-summary {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 8px 10px 8px 8px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 244, 0.72);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease;
}

.option-summary:hover,
.option-summary[aria-expanded="true"] {
  border-color: var(--ink);
  background: var(--paper);
}

.option-summary img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  object-position: center;
  background: var(--cream);
}

.option-summary span:not(.option-chevron) {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-chevron {
  width: 10px;
  height: 10px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  color: var(--olive);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 180ms ease;
}

.option-summary[aria-expanded="true"] .option-chevron {
  transform: rotate(225deg) translateY(-1px);
}

.option-grid-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(251, 250, 244, 0.62);
  color: var(--olive);
  cursor: pointer;
  font-size: 13px;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.option-card img {
  width: 100%;
  aspect-ratio: 1.35 / 1;
  object-fit: cover;
  object-position: center;
  background: var(--cream);
}

.option-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-card.is-selected {
  border-color: var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.metal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--olive);
  cursor: pointer;
  font-size: 13px;
}

.metal-option.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.metal-dot {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(44, 42, 34, 0.28);
  border-radius: 50%;
  background: var(--metal);
}

.effect-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.effect-toggle input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--copper);
  cursor: pointer;
}

.effect-toggle input:disabled {
  cursor: default;
}

.effect-toggle span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.effect-toggle strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.effect-toggle small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--copper);
}

.setting-output {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.setting-output code {
  display: block;
  min-height: 72px;
  overflow-wrap: anywhere;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--olive);
  line-height: 1.55;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.button-dark {
  background: var(--ink);
  color: var(--paper);
}

.button-light {
  background: transparent;
  color: var(--ink);
}

.copy-status {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .designer-shell {
    grid-template-columns: 1fr;
  }

  .viewer-stage {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .viewer {
    height: 68vh;
    min-height: 480px;
  }

  .viewer-copy {
    top: 24px;
  }

  .status-bar {
    flex-direction: column;
  }

  .tuning-panel {
    height: auto;
    min-height: 32vh;
    padding: 28px 22px;
  }
}
