:root {
  --bg: #fdf6ec;
  --surface: #ffffff;
  --border: #e8ddc8;
  --accent: #e07a5f;
  --accent-dark: #c85f45;
  --text: #3d3229;
  --muted: #8a7d6b;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.logo { font-size: 2rem; }
header h1 { font-size: 1.4rem; font-weight: 700; }
header p { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.field { margin-bottom: 20px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

button, .btn-primary {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

button:hover, .btn-primary:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.hidden { display: none !important; }

#progress-panel, #result-panel {
  margin-top: 32px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#progress-step { font-size: 1rem; margin-bottom: 14px; }

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

#progress-pct {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.error { color: #c0392b; margin-top: 10px; }

.warning {
  color: #8a6d1f;
  background: #fdf3d8;
  border: 1px solid #f0dfa0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

#result-panel h2 { margin-bottom: 16px; }

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

#cover-dimensions { margin-top: 12px; }

.thumbnails {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.thumbnails img {
  width: 140px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 4px;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 24px 0;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

.tab-btn:hover { background: transparent; color: var(--text); }

.tab-btn.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

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

.settings-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 28px 0 16px;
}

.settings-heading:first-child { margin-top: 0; }

.setting-status.configured { color: #2e7d32; }
.setting-status.env { color: #8a6d1f; }
.setting-status.unconfigured { color: var(--muted); }

.saved-msg {
  color: #2e7d32;
  font-size: 0.85rem;
  margin-top: 10px;
}

.saved-msg.error { color: #c0392b; }

.auto-generate-box {
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
}

.auto-generate-box label {
  color: var(--accent-dark);
}

.auto-generate-box textarea {
  margin-bottom: 10px;
}

#auto-generate-status.error { color: #c0392b; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 0.9rem;
}

.btn-secondary:hover { background: var(--bg); }

.btn-small {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.history-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.history-card-title { flex: 1; min-width: 0; }
.history-card-title h3 { font-size: 1.05rem; }
.history-card-title .subtitle-display { margin-top: 2px; }

.history-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.title-edit-form { display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.title-edit-form input { font-size: 0.95rem; padding: 6px 10px; }
.title-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.title-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.title-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.title-suggestion:hover { border-color: var(--accent); }
.title-suggestion .hint { margin: 0; }

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

.status-badge.status-done { background: #dff0d8; color: #2e7d32; }
.status-badge.status-error { background: #f8d7da; color: #c0392b; }
.status-badge.status-running { background: #fdf3d8; color: #8a6d1f; }

.history-card .result-actions { margin-top: 14px; }

.history-pages {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.page-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}

.page-thumb.needs-fix { border-color: #e0a72f; border-width: 2px; }

.page-thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.page-thumb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  font-size: 0.78rem;
}

.page-prompt-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 6px;
  padding: 6px 10px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.3;
  resize: vertical;
}

.page-thumb-status {
  padding: 0 10px 8px;
  margin: 0 !important;
}

.page-from-scratch {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 0 10px 8px;
  cursor: pointer;
}

.page-from-scratch input {
  width: auto;
  margin-top: 2px;
  flex-shrink: 0;
}

.page-text-section {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}

.page-text-section label {
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.page-text-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
  resize: vertical;
  margin-bottom: 6px;
}

.page-text-instruction {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.page-text-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.page-text-status {
  margin-top: 4px !important;
}

.history-description {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.history-description .description-input {
  margin-bottom: 10px;
}

.description-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.description-status.error { color: #c0392b; }

/* --- Hardcover coloring book generator additions --- */

header { position: relative; }

.logout-link {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--muted);
}

main { max-width: 760px; }

.field-row {
  display: flex;
  gap: 16px;
}

.field-row .field { flex: 1; }

.preset-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.preset-btn:hover { border-color: var(--accent); }
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-thumb img {
  background: #fff;
  border: 1px solid var(--border);
}

.thumbnails img {
  background: #fff;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 { font-size: 1.1rem; margin: 8px 0 20px; }
.login-card label { text-align: left; }
.login-card button { margin-top: 16px; width: 100%; }

.design-idea {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 4px 0;
}

@media (max-width: 620px) {
  .field-row { flex-direction: column; gap: 0; }
  .logout-link { position: static; transform: none; margin-left: auto; }
}
