:root {
  --paper: #e7e0d4;
  --paper-2: #f6f1e8;
  --ink: #1c1915;
  --muted: #6f685d;
  --line: #d5cdbf;
  --clay: #8d3f2e;
  --clay-ink: #fff8f3;
  --studio: #1a1714;
  --shadow: 0 18px 40px rgba(40, 28, 18, 0.08);
  color: var(--ink);
  background: var(--paper);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(255, 250, 242, 0.9), transparent 60%),
    var(--paper);
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 2px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 12px;
}

.top h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.top p { margin: 0; color: var(--muted); }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.78fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.stage {
  position: relative;
  min-height: 0;
  border-radius: 22px;
  overflow: hidden;
  background: var(--studio);
  box-shadow: var(--shadow);
}

#view { width: 100%; height: 100%; display: block; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: #ebe4d8;
  pointer-events: none;
}

.stage-empty strong {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.8rem;
  font-weight: 560;
  margin-bottom: 8px;
}

.stage-empty span { color: #b7aea1; max-width: 28ch; }

.stage.has-face .stage-empty { display: none; }

.caption {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 64px;
  margin: 0;
  color: #f6f1e8;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}

.stage-tools {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.stage-tools button, .ghost, .text-button {
  border: 1px solid rgba(255, 248, 240, 0.18);
  background: rgba(20, 16, 13, 0.45);
  color: #f4eee6;
  border-radius: 999px;
  padding: 8px 14px;
}

.panel {
  min-height: 0;
  overflow: auto;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 16px 28px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 18px 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.panel h2:first-child { margin-top: 0; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }

.field span, .card label span { color: var(--muted); font-size: 0.86rem; }

input[type="text"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 12px;
  padding: 10px 12px;
}

textarea { min-height: 68px; resize: vertical; }

.drop {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 16px;
  border: 1.5px dashed #c3b8a6;
  border-radius: 16px;
  background: #fbf7f1;
  text-align: center;
  color: var(--muted);
}

.drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.drop.over { border-color: var(--clay); background: #fff8f4; color: var(--ink); }

.note { color: var(--muted); font-size: 0.92rem; margin: 8px 0 0; }

.row { display: flex; gap: 8px; align-items: center; }

.primary, .add {
  border: 0;
  background: var(--ink);
  color: var(--paper-2);
  border-radius: 999px;
  padding: 10px 16px;
}

.add { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.primary:disabled { opacity: 0.45; cursor: default; }

.card {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.card header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }

.card header input { font-family: Fraunces, Georgia, serif; font-size: 1.05rem; }

.card label { display: grid; gap: 4px; margin-bottom: 8px; }

.card footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.text-button {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 6px 0;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  margin-bottom: 10px;
}

.bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.bubble.user { align-self: flex-end; background: #1c1915; color: #f6f1e8; border-color: #1c1915; }

.bubble .who {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 3px;
}

.talk-form { display: flex; gap: 8px; }

.talk-form input { flex: 1; }

.error { color: var(--clay); }

@media (max-width: 860px) {
  body { height: auto; min-height: 100dvh; }
  .layout { grid-template-columns: 1fr; }
  .stage { height: 62dvh; }
  .top { padding-bottom: 8px; }
  .top p { display: none; }
}
