:root {
  color-scheme: light;
  --bg: #f1ebdf;
  --bg-soft: #f8f4ec;
  --bg-deep: #dfd2bc;
  --panel: #fffdf8;
  --panel-tint: #f5efe3;
  --border: #d0c2ab;
  --border-strong: #a89270;
  --text: #1f1b16;
  --muted: #655d50;
  --primary: #184d3a;
  --primary-strong: #0f3225;
  --accent: #b8682e;
  --danger: #b64443;
  --danger-soft: #fff1ef;
  --code-bg: #49443c;
  --code-text: #f1eadf;
  --shadow: 0 10px 24px rgba(33, 26, 17, 0.06);
  --radius-xl: 10px;
  --radius-lg: 7px;
  --radius-md: 5px;
  --radius-sm: 3px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), transparent 22%),
    repeating-linear-gradient(
      90deg,
      rgba(24, 77, 58, 0.02) 0,
      rgba(24, 77, 58, 0.02) 1px,
      transparent 1px,
      transparent 44px
    ),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(184, 104, 46, 0.09), transparent 20%),
    radial-gradient(circle at 88% 14%, rgba(24, 77, 58, 0.07), transparent 22%);
  opacity: 0.75;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: min(1660px, calc(100% - 28px));
  margin: 14px auto 24px;
}

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
  padding: 18px 20px 16px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.98) 0%, rgba(245, 239, 227, 0.98) 100%);
}

.hero::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0 66%, var(--accent) 66% 100%);
}

.hero::after {
  display: none;
}

.hero__copy,
.hero__stats {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

.hero h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.hero__description {
  max-width: 920px;
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

.hero__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-self: start;
}

.stat-card {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.74);
}

.stat-card:nth-child(2) {
  border-left-color: var(--accent);
}

.stat-card:nth-child(3) {
  border-left-color: var(--border-strong);
}

.stat-card__label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card__value {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  line-height: 1;
}

.stat-card__value--status {
  color: var(--primary);
}

.stat-card__value--status.is-dirty {
  color: var(--accent);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(380px, 1fr) minmax(420px, 1.06fr);
  gap: 14px;
  align-items: start;
}

.settings-panel,
.editor-panel,
.result-panel {
  min-height: 680px;
  padding: 16px;
}

.settings-panel {
  position: sticky;
  top: 12px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98) 0%, rgba(250, 245, 236, 0.98) 100%);
}

.editor-panel,
.result-panel {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98) 0%, rgba(247, 242, 233, 0.92) 100%);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head--stack {
  justify-content: flex-start;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

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

.control-box {
  display: grid;
  gap: 6px;
}

.control-box label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.control-box input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.control-box input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
}

.control-box input:focus,
.editor-card__image-name:focus,
.editor-card__transform-field input:focus,
.editor-card__textarea:focus,
#output:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 77, 58, 0.12);
}

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

.button-grid button:last-child {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.ghost-button,
.tab-button,
.editor-card__remove-btn,
.refresh-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}

.secondary-button,
.ghost-button,
.tab-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.editor-card__remove-btn {
  border: 1px solid rgba(182, 68, 67, 0.3);
  background: var(--danger-soft);
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover,
.editor-card__remove-btn:hover,
.refresh-preview-btn:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.tab-button:disabled,
.editor-card__remove-btn:disabled,
.refresh-preview-btn:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status {
  margin: 14px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  color: #31433a;
  line-height: 1.55;
  word-break: keep-all;
}

.status.error {
  border-color: rgba(182, 68, 67, 0.28);
  border-left-color: var(--danger);
  background: #fff5f4;
  color: var(--danger);
}

.guide-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.guide-item {
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(247, 241, 232, 0.56);
}

.guide-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.guide-item span {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.result-panel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.panel-tools,
.tab-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-button.is-active {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.editor-list {
  display: grid;
  gap: 10px;
  max-height: 780px;
  overflow: auto;
  padding-right: 4px;
}

.empty-box {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(249, 245, 237, 0.82);
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  word-break: keep-all;
}

.editor-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
}

.editor-card[open] {
  border-color: var(--border-strong);
}

.editor-card__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
  background:
    linear-gradient(90deg, rgba(247, 241, 232, 0.95) 0 12px, transparent 12px 100%);
}

.editor-card__summary::-webkit-details-marker {
  display: none;
}

.editor-card__summary-left {
  min-width: 0;
}

.editor-card__summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-card__title {
  margin: 0;
  font-size: 15px;
  line-height: 1.15;
}

.editor-card__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(24, 77, 58, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(24, 77, 58, 0.08);
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meta-pill--neutral {
  border-color: rgba(160, 144, 117, 0.26);
  background: rgba(160, 144, 117, 0.1);
  color: var(--muted);
}

.editor-card__body {
  display: grid;
  gap: 14px;
  padding: 0 12px 12px;
  border-top: 1px solid rgba(208, 194, 171, 0.8);
}

.editor-card__section {
  display: grid;
  gap: 10px;
}

.editor-card__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
}

.editor-card__section-head h4 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.editor-card__section-head span {
  font-size: 11px;
  color: var(--muted);
}

.editor-card__section-head code,
.guide-item code,
.hero__description code {
  padding: 2px 6px;
  border: 1px solid rgba(24, 77, 58, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(24, 77, 58, 0.08);
  color: var(--primary-strong);
  font-family: Consolas, Monaco, monospace;
  font-size: 0.95em;
}

.editor-card__image-list {
  display: grid;
  gap: 8px;
}

.editor-card__image-item {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(208, 194, 171, 0.86);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fffdf8 0%, rgba(245, 239, 227, 0.82) 100%);
}

.editor-card__image-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.editor-card__image-name {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.editor-card__check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.84);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.editor-card__check input[type="checkbox"] {
  inline-size: 16px;
  block-size: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.editor-card__transform {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.editor-card__transform.is-disabled {
  opacity: 0.5;
}

.editor-card__transform-field {
  display: grid;
  gap: 4px;
}

.editor-card__transform-field span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.editor-card__transform-field input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.editor-card__textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  resize: vertical;
  line-height: 1.72;
  font-family: Consolas, Monaco, monospace;
}

.editor-card__empty {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(247, 241, 232, 0.48);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

#output,
#previewFrame {
  width: 100%;
  min-height: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

#output {
  padding: 14px;
  background: var(--code-bg);
  color: var(--code-text);
  resize: vertical;
  line-height: 1.7;
  font-family: Consolas, Monaco, monospace;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

#output::placeholder {
  color: rgba(241, 234, 223, 0.58);
}

#previewFrame {
  background: #fdfbf7;
}

.refresh-preview-btn {
  min-width: 120px;
  border: 1px solid var(--border);
  background: #f6f1e8;
  color: var(--text);
  box-shadow: none;
}

.refresh-preview-btn.is-dirty {
  border-color: rgba(184, 104, 46, 0.48);
  background: #fff0e2;
  color: #8c4d1f;
}

@media (max-width: 1450px) {
  .workspace-grid {
    grid-template-columns: minmax(300px, 0.95fr) minmax(360px, 1fr);
  }

  .result-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

  #output,
  #previewFrame {
    min-height: 580px;
  }
}

@media (max-width: 1080px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero::after {
    display: none;
  }

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

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

  .settings-panel {
    position: static;
  }

  .settings-panel,
  .editor-panel,
  .result-panel {
    min-height: auto;
  }

  .editor-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 16px, 1660px);
    margin-top: 10px;
  }

  .hero,
  .settings-panel,
  .editor-panel,
  .result-panel {
    padding: 14px;
    border-radius: 8px;
  }

  .panel-head,
  .editor-card__summary,
  .editor-card__section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .result-panel__actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .button-grid,
  .editor-card__image-top,
  .editor-card__transform {
    grid-template-columns: 1fr;
  }

  .editor-card__summary-right {
    justify-content: space-between;
  }

  #output,
  #previewFrame {
    min-height: 460px;
  }
}
