:root {
  --paper: rgba(255, 251, 245, 0.95);
  --ink: #211816;
  --muted: #6f5a4a;
  --accent: #8f2a24;
  --line: rgba(33, 24, 22, 0.12);
  --shadow: 0 20px 60px rgba(78, 44, 26, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(143, 42, 36, 0.16), transparent 28%),
    linear-gradient(180deg, #f6efe6 0%, #eddfca 100%);
}

body.locked { overflow: hidden; }
button, input, textarea { font: inherit; }

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(22, 15, 14, 0.38);
  backdrop-filter: blur(14px);
}

.login-gate.hidden { display: none; }

.login-card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.login-card { width: min(440px, 100%); padding: 28px; }

.page { width: min(1240px, calc(100vw - 28px)); margin: 0 auto; padding: 28px 0 40px; }
.hero { margin-bottom: 18px; padding: 28px; }

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

h1, h2, button { font-family: "LXGW WenKai", "KaiTi", serif; }
h1 { margin: 0 0 10px; font-size: clamp(32px, 5vw, 58px); line-height: 1.05; }
.lede, .hint, .status, .history-item span, .history-item time { color: var(--muted); }

.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; }
.panel { padding: 22px; }

.panel-head,
.status-row,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 { margin: 0; font-size: 24px; }

.login-form label, .generate-form label { display: block; margin-bottom: 14px; }

input, textarea {
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(111, 90, 74, 0.22);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus {
  outline: 2px solid rgba(143, 42, 36, 0.14);
  border-color: rgba(143, 42, 36, 0.3);
}

.primary, .ghost, .history-item {
  border-radius: 16px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.primary { padding: 14px 18px; color: #fff7ef; border: none; background: linear-gradient(135deg, #8f2a24, #c26b39); }
.ghost { padding: 10px 14px; background: rgba(255, 255, 255, 0.7); }

.generate-form { display: grid; gap: 16px; margin-bottom: 18px; }
.history-list { display: grid; gap: 10px; }
.history-item { width: 100%; padding: 14px; text-align: left; background: rgba(255, 255, 255, 0.58); }
.history-item.active { border-color: rgba(143, 42, 36, 0.3); background: rgba(143, 42, 36, 0.08); }
.history-item strong, .history-item span, .history-item time { display: block; }

.output {
  min-height: 360px;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.85;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fffdf9;
  overflow: auto;
}

.prompt-box {
  min-height: 120px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fffdf9;
}

.image-preview {
  width: 100%;
  max-width: 680px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #fffdf9;
  display: block;
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .page { width: min(100vw - 18px, 1000px); }
  .panel-head, .status-row, .action-row { align-items: flex-start; flex-direction: column; }
}
