:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171b22;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --accent: #c9a227;
}

* {
  box-sizing: border-box;
}

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

.top {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #2a3140;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.top h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.nav a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 1rem;
  font-size: 0.95rem;
}

.nav a:hover {
  text-decoration: underline;
}

.sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  align-items: flex-start;
}

.panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 1rem;
  flex: 1 1 260px;
  max-width: 100%;
}

.panel.grow {
  flex: 3 1 400px;
}

.prefs-fieldset {
  border: 1px solid #2a3140;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}

.prefs-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.pref-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  font-size: 0.88rem;
}

.pref-row input {
  margin-top: 0.2rem;
}

.derived-readout {
  font-size: 0.88rem;
  border: 1px solid #2a3140;
  border-radius: 6px;
  padding: 0.75rem;
  background: #12151c;
}

.derived-readout table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.derived-readout th,
.derived-readout td {
  text-align: left;
  padding: 0.2rem 0.35rem;
  border-bottom: 1px solid #2a3140;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

button {
  background: var(--accent);
  color: #1a1404;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

input[type="email"],
input[type="password"],
input[type="date"],
input[type="text"] {
  width: 100%;
  max-width: 28rem;
  margin: 0.35rem 0 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #2a3140;
  background: #0f1115;
  color: var(--text);
  font: inherit;
}

textarea {
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #2a3140;
  background: #0f1115;
  color: var(--text);
  font: inherit;
}

label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

label.inline {
  margin: 0.5rem 0;
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.log {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #0b0d11;
  border-radius: 6px;
  overflow: auto;
  max-height: 50vh;
  font-size: 0.85rem;
  color: #c5cad5;
}

.log.small {
  max-height: 8rem;
}

.wb-ai-status {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid #2a3140;
  border-radius: 6px;
}

.wb-ai-status[hidden] {
  display: none !important;
}

.wb-ai-progress-track {
  height: 6px;
  border-radius: 3px;
  background: #2a3140;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.wb-ai-progress-bar {
  height: 100%;
  width: 35%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #e8d48a, var(--accent));
  animation: wb-ai-indeterminate 1.1s ease-in-out infinite;
}

@keyframes wb-ai-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(320%);
  }
}

.wb-ai-error {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid #8b3a3a;
  background: #241418;
  color: #f0c4c4;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.wb-ai-error[hidden] {
  display: none !important;
}

.wb-ai-error strong {
  color: #fff;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.hero {
  padding: 2rem 1.5rem 3rem;
  max-width: 44rem;
}

.hero-title {
  font-size: 1.75rem;
  margin: 0 0 1rem;
  line-height: 1.25;
}

.hero-lead {
  font-size: 1.05rem;
  line-height: 1.55;
  color: #d4d8e0;
}

.hero-points {
  margin: 1.25rem 0;
  padding-left: 1.2rem;
  line-height: 1.5;
  color: #c9ced8;
}

.hero-points li {
  margin-bottom: 0.6rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

a.cta {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  background: var(--accent);
  color: #1a1404;
  font-weight: 600;
  text-decoration: none;
}

a.cta.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.account-layout {
  flex-direction: column;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.inline-form {
  margin: 1rem 0;
}

select {
  max-width: 28rem;
  margin: 0.35rem 0 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #2a3140;
  background: #0f1115;
  color: var(--text);
  font: inherit;
}

.entity-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.entity-item {
  border: 1px solid #2a3140;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
}

.row-actions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.row-actions button {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
}

.play-shell {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  align-items: stretch;
}

.play-chat {
  flex: 2 1 320px;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}

.play-side {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-log {
  flex: 1;
  min-height: 200px;
  max-height: 45vh;
  overflow: auto;
  background: #0b0d11;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-line {
  margin-bottom: 0.65rem;
  line-height: 1.45;
  font-size: 0.95rem;
}

.chat-line.you {
  color: #a8c7ff;
}

.chat-line.narrator {
  color: #e2e5eb;
}

.ai-busy {
  margin: 0.35rem 0 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  background: #1e2430;
  border: 1px solid #3d4a60;
  color: var(--accent);
  font-size: 0.9rem;
  animation: ai-busy-pulse 1.2s ease-in-out infinite;
}

.ai-busy[hidden] {
  display: none !important;
}

@keyframes ai-busy-pulse {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

.send-hint {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.8rem;
}

.sheet-root,
.scene-root {
  font-size: 0.9rem;
  line-height: 1.45;
}

.small-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.75rem 0 0.25rem;
}

ul.kv {
  margin: 0;
  padding-left: 1.1rem;
}

pre.block {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
}

.scene-desc {
  margin: 0.35rem 0 0;
}

.dice-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: #c5cad5;
}

.sheet-block {
  max-height: 42vh;
  overflow: auto;
}

.scene-block {
  max-height: 36vh;
  overflow: auto;
}

.creator-page .creator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.skill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
  max-height: 14rem;
  overflow: auto;
  padding: 0.25rem;
  border: 1px solid #2a3140;
  border-radius: 8px;
}

.skill-pill {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  cursor: pointer;
}

.shop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.5rem 0;
}

.shop-table th,
.shop-table td {
  border: 1px solid #2a3140;
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.shop-table button {
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  margin-right: 0.25rem;
}
