:root {
  color-scheme: light;
  --paper: #f8f6f0;
  --ink: #0a0a08;
  --muted: #77766f;
  --line: #d8d4c9;
  --panel: #fbfaf6;
  --accent: #8f2f20;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body-cn: "Songti SC", "STSongti-SC-Regular", "Hiragino Mincho ProN", "Noto Serif CJK SC", "Times New Roman", serif;
  --font-display-cn: "Songti SC", "STSongti-SC-Black", "Hiragino Mincho ProN", "Noto Serif CJK SC", "STSong", serif;
  --font-display-en: "Bodoni 72", Didot, "Bodoni 72 Oldstyle", "Bodoni 72 Smallcaps", Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eeece5;
  color: var(--ink);
  font-family: var(--font-ui);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(260px, 310px);
  min-height: 100vh;
}

.panel {
  padding: 24px;
  background: var(--panel);
  border-color: var(--line);
  border-style: solid;
}

.panel-left {
  border-width: 0 1px 0 0;
}

.panel-right {
  border-width: 0 0 0 1px;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--ink);
  font-family: var(--font-display-cn);
  font-size: 24px;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.eyebrow,
small {
  color: var(--muted);
  font-size: 12px;
}

.control-group {
  display: grid;
  gap: 14px;
  margin-bottom: 26px;
}

.control-group h2 {
  font-size: 13px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  color: #3c3b36;
  font-size: 13px;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid #cfcabe;
  border-radius: 6px;
  background: #fffef9;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

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

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 47, 32, 0.12);
}

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

input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid #cfcabe;
  border-radius: 6px;
  background: transparent;
  padding: 3px;
}

.file-drop {
  justify-items: center;
  gap: 3px;
  border: 1px dashed #aaa397;
  border-radius: 8px;
  padding: 18px;
  cursor: pointer;
  text-align: center;
}

.file-drop input {
  display: none;
}

.file-drop span {
  font-weight: 700;
}

.segmented,
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

button {
  min-height: 38px;
  border: 1px solid #beb7aa;
  border-radius: 6px;
  background: #fffef9;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--ink);
}

button.active,
#exportButton {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.ghost-button {
  color: #5d332d;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 22px 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar > div {
  display: grid;
  gap: 2px;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
}

.poster {
  position: relative;
  width: min(52vh, 440px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 26px 80px rgba(33, 31, 25, 0.24);
}

.image-stage {
  position: absolute;
  inset: 0 0 auto 0;
  height: 50%;
  overflow: hidden;
}

.image-stage img {
  display: none;
  position: absolute;
  max-width: none;
  max-height: none;
  object-fit: fill;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.image-stage.has-image img {
  display: block;
}

#emptyHint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(10, 10, 8, 0.16);
  font-size: 18px;
  letter-spacing: 0;
}

.image-stage.has-image #emptyHint {
  display: none;
}

.poster-copy {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.body-preview {
  position: absolute;
  left: 66px;
  right: 66px;
  top: 1044px;
  color: var(--ink);
  font-family: var(--font-body-cn);
  font-weight: 500;
  font-synthesis: none;
  font-size: 34px;
  line-height: 1.12;
  white-space: pre-line;
}

.divider {
  position: absolute;
  left: 66px;
  right: 66px;
  top: 1348px;
  height: 2px;
  background: var(--ink);
}

.title-stack {
  position: absolute;
  left: 66px;
  right: 44px;
  top: 1386px;
  color: var(--ink);
}

.english-preview {
  font-family: var(--font-display-en);
  font-size: 118px;
  font-weight: 700;
  font-synthesis: none;
  line-height: 0.82;
}

.title-preview {
  margin-top: 6px;
  font-family: var(--font-display-cn);
  font-size: 132px;
  font-weight: 900;
  font-synthesis: none;
  line-height: 0.92;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(260px, 320px) 1fr;
  }

  .panel-right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    border-width: 1px 0 0 0;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--panel);
  }

  .app-shell {
    display: block;
  }

  .panel {
    padding: 18px;
    border-width: 0 0 1px 0;
  }

  .panel-right {
    display: block;
  }

  .workspace {
    padding: 18px;
    background: #eeece5;
  }

  .poster {
    width: min(92vw, 390px);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -18px -18px 16px;
    padding: 14px 18px;
    background: rgba(238, 236, 229, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }

  #exportButton {
    min-width: 86px;
  }

  .segmented,
  .preset-grid {
    gap: 8px;
  }
}
