:root {
  --bg: #0e1116;
  --card: #161b23;
  --ink: #e8edf2;
  --muted: #8b94a3;
  --accent: #4f8cff;
  --accent2: #26d9a5;
  --border: #26303d;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; }
a { color: var(--accent); }

header {
  padding: 1rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #10141b, var(--bg));
}
header h1 { margin: 0; font-size: 1.4rem; letter-spacing: .02em; }
header .tagline { flex: 1; margin: 0; color: var(--muted); font-size: .9rem; }

main { max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.25rem;
}
.card label, .aside-label { display: block; margin-bottom: .45rem; font-weight: 600; font-size: .95rem; }
textarea, input {
  width: 100%;
  background: #10151d;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  padding: .55rem .6rem;
  font-size: .95rem;
  font-family: inherit;
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); }

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row.space { justify-content: space-between; }
button {
  font: inherit; cursor: pointer;
  border: none; border-radius: 8px;
  padding: .5rem .9rem;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #3f77e8; }
button.secondary { background: var(--accent2); color: #06251a; }
button.secondary:disabled, button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.hint, .status { color: var(--muted); font-size: .85rem; }
.wordcount { color: var(--muted); font-size: .8rem; }

.essay-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; background: #0f1420; padding: .9rem; margin-top: .5rem; }
pre.essay { white-space: pre-wrap; word-wrap: break-word; font: inherit; line-height: 1.5; color: var(--ink); }

.controls { margin-top: .6rem; }
.thread { border-top: 1px solid var(--border); margin-top: .8rem; padding-top: .4rem; }
.thread .qa { font-size: .86rem; color: var(--muted); padding: .2rem 0; }

dialog {
  background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem 1.4rem; max-width: 440px;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.settings-form h3 { margin-top: 0; }
.settings-form label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.settings-form input { margin-bottom: .7rem; }
.settings-form .note { font-size: .78rem; color: var(--muted); }
.settings-form .row { justify-content: flex-end; margin-top: .5rem; }