:root {
  --ink: #1a1410;
  --paper: #f3ead6;
  --line: #c9b89a;
  --red: #b42318;
  --muted: #5c4e3a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: #2a231c;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
}
.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  background: #efe4cc;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 4px;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.2em; font-weight: 600; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); letter-spacing: 0.06em; }
.seal-mini {
  width: 36px; height: 36px;
  border: 2px solid var(--red);
  color: var(--red);
  display: grid; place-items: center;
  font-size: 18px;
  flex: 0 0 auto;
  transform: rotate(-8deg);
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 15px;
}
.stage-wrap {
  position: relative;
  margin: 4px auto 0;
  width: min(calc(100% - 32px), calc((100dvh - 340px) * 0.75));
  max-height: calc(100dvh - 340px);
  background: #d9cbb0;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  box-shadow: 0 10px 28px rgba(40, 24, 8, 0.18);
}
@media (max-width: 959px) {
  .studio .workspace { display: flex; flex-direction: column; }
  .studio .panel { display: contents; }
  .studio .lead { order: 1; padding: 4px 16px 0; }
  .studio .stage-wrap { order: 2; }
  .studio .more { order: 3; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
}
#stage {
  width: 100%;
  height: 100%;
  display: block;
}
.loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(243, 234, 214, 0.82);
  letter-spacing: 0.18em;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
.loading.hide { display: none; }
.panel, .lead, .more {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
.lead, .more { padding: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-head span, .slider span, .check span { font-size: 13px; color: var(--muted); letter-spacing: 0.06em; }
#charCount.at-limit { color: #8a3b24; }
.field input[type="text"] {
  width: 100%;
  min-height: 44px;
  font-size: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f7f1e3;
  border-radius: 6px;
  outline: none;
}
.row { display: flex; gap: 8px; }
.seg {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  background: #e7dcc4;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  min-height: 44px;
  padding: 8px 6px;
  font-size: 14px;
  line-height: 1.15;
  color: #5c4e3a;
  border-radius: 6px;
}
.seg button.on {
  background: #2c241c;
  color: #f3ead6;
}
.seg-wide button { font-size: 13px; }
#fmtBar button {
  flex: 1 1 30%;
  white-space: normal;
}
.slider { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.slider span { flex: 0 0 3.2em; }
.slider input { flex: 1; height: 44px; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.actions { display: flex; gap: 8px; }
.secondary, .pay {
  border: 0;
  width: 100%;
  min-height: 48px;
  padding: 12px 10px;
  border-radius: 8px;
  font-size: 16px;
  letter-spacing: 0.06em;
}
.secondary { background: #8a6a4a; color: #fff; }
.pay { background: #c24a3a; color: #fff; }
.hint.price { line-height: 1.35; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.hint { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.hint.warn { color: #8a3b24; }
.hint.muted { opacity: 0.9; }
.legal {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  justify-content: center;
  padding: 4px 12px calc(12px + env(safe-area-inset-bottom));
}
.legal a {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 6px;
}
button { font-family: inherit; cursor: pointer; }
.page { padding: 28px 20px 48px; }
.page h1 { font-size: 28px; margin: 8px 0 12px; letter-spacing: 0.04em; }
.page p { font-size: 16px; line-height: 1.5; }
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  background: #1d1712;
  color: #f3ead6;
  text-decoration: none;
  letter-spacing: 0.06em;
  font-size: 16px;
}

@media (min-width: 960px) {
  .studio { max-width: 1160px; }
  .studio .workspace {
    display: grid;
    grid-template-columns: minmax(300px, auto) minmax(360px, 1fr);
    gap: 22px;
    align-items: start;
    padding: 6px 22px 0;
  }
  .studio .stage-wrap {
    margin: 0;
    width: min(100%, 440px, calc((100dvh - 88px) * 0.75));
    max-height: calc(100dvh - 88px);
    justify-self: center;
  }
  .studio .panel {
    display: flex;
    padding: 0 0 8px;
    max-height: calc(100dvh - 88px);
    overflow: auto;
  }
}
