:root {
  --bg: #14110f;
  --panel: #1e1a17;
  --ink: #f2ebe3;
  --muted: #a89888;
  --line: #3a322b;
  --accent: #c45c3e;
  --accent-dim: #8a3f2a;
  --ok: #6a9a6a;
  --font: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --ui: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, #2a1f1a 0%, transparent 50%),
    radial-gradient(ellipse at 90% 80%, #1a2220 0%, transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1.65;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.header h1 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.75rem;
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
}

.header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.header-row h1 { margin-bottom: 0; }

.logout-link {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.logout-link:hover { color: var(--ink); }

.login-wrap { max-width: 420px; }

.login-panel button { width: 100%; }

.login-error {
  margin: 0 0 0.85rem;
  color: #e08a72;
  font-size: 0.92rem;
}

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

.panel {
  margin-top: 1.5rem;
  padding: 1.25rem 1.35rem;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 4px;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.hint {
  font-weight: 400;
  opacity: 0.75;
  margin-left: 0.35rem;
}

textarea,
select,
input[type="text"],
input[type="password"],
input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #0f0d0b;
  color: var(--ink);
  color-scheme: dark;
  font: inherit;
  resize: vertical;
}

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

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.grow { flex: 1 1 10rem; }

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}

.check input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.file-list li:last-child { border-bottom: none; }

.file-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.file-list .empty {
  color: var(--muted);
  padding: 0.25rem 0;
}

.file-list a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.file-list a:hover { text-decoration: underline; }

#refresh-outputs {
  margin-top: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

button[type="submit"],
.btn {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 3px;
  background: var(--accent);
  color: #fff8f4;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button[type="submit"]:hover,
.btn:hover { background: var(--accent-dim); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status { margin: 0 0 0.75rem; color: var(--ink); }

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

#bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.35s ease;
}

.prose {
  white-space: pre-wrap;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.98rem;
}

#plan-chapters {
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

#plan-chapters li { margin-bottom: 0.45rem; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.result-head h2 { margin: 0; }

.preview {
  margin: 0;
  max-height: 28rem;
  overflow: auto;
  padding: 1rem;
  background: #0c0a09;
  border: 1px solid var(--line);
  border-radius: 3px;
  white-space: pre-wrap;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.8;
}

h2, h3 {
  font-family: var(--font);
  font-weight: 600;
}

h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--muted); }
