/* The Weight of It — styles. Mobile-first; a single grey dark theme. */

:root {
  --bg: #1c1c1e;
  --surface: #262628;
  --surface-2: #313134;
  --ink: #e8e8ea;
  --muted: #9a9aa0;
  --line: #3a3a3d;
  --accent: #e0a458;
  --accent-ink: #1c1c1e;
  --accent-soft: #3a3127;
  --good: #6cc08f;
  --bad: #ec7b6b;
  --warn-bg: #3b3220;
  --warn-ink: #f2d38a;
  --info-bg: #2c2c2f;
  --you-bg: #3a3a3e;
  --you-ink: #f2f2f4;
  --oos-bg: #22303a;
  --oos-ink: #b8d3e6;
  --phone-bg: #111113;
  --phone-ink: #f2f2f5;
  --phone-muted: #8d8d96;
  --phone-line: #26262a;
  --im-them: #2a2a2e;
  --im-them-ink: #f2f2f5;
  --im-me: #2f6fdf;
  --im-me-ink: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 14px;
  --gutter: 16px;
  --topbar-h: 58px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.muted {
  color: var(--muted);
}

.fineprint {
  color: var(--muted);
  font-size: 14px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row.nowrap {
  flex-wrap: nowrap;
}

.row.nowrap > .input {
  flex: 1;
  min-width: 0;
}

/* ---------- Icons and buttons ---------- */

.icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  list-style: none;
}

.icon-btn::-webkit-details-marker {
  display: none;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
  background: var(--accent);
}

.btn.danger {
  color: var(--bad);
}

.btn.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

.btn.big {
  min-height: 52px;
  padding: 14px 24px;
  font-size: 17px;
}

.btn.block {
  width: 100%;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 680px;
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  margin: 0 8px;
  border-radius: 8px;
  background: var(--accent);
  flex: none;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title .t1 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title .t2 {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
}

.menu {
  position: relative;
}

.menu-pop {
  position: absolute;
  right: 0;
  top: 48px;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 30;
}

.menu-pop button {
  display: block;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  font-size: 15px;
}

.menu-pop button:hover:not(:disabled) {
  background: var(--surface-2);
}

/* ---------- Banners, cards, errors ---------- */

.banner {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--info-bg);
  font-size: 15px;
}

.banner.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.banner.nudge {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.pad {
  padding: 16px;
  margin: 16px 0;
}

.section-title {
  margin: 28px 0 10px;
  font-family: var(--serif);
  font-size: 20px;
}

.card .section-title {
  margin-top: 0;
}

.error-box {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--bad);
  border-radius: 12px;
  background: var(--surface);
}

.error-msg {
  margin: 0 0 10px;
  color: var(--bad);
  font-weight: 600;
}

.raw-wrap {
  margin-bottom: 10px;
  font-size: 14px;
}

.raw {
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg {
  margin: 12px 0 0;
  font-size: 15px;
}

.msg.ok {
  color: var(--good);
}

.msg.err {
  color: var(--bad);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Typing indicator ---------- */

.typing {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-style: italic;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: blink 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dots i {
    animation: none;
    opacity: 0.6;
  }
  .phone {
    animation: none !important;
  }
}

/* ---------- Home ---------- */

.hero {
  padding: 28px 0 8px;
}

.hero-sub {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.35;
}

.story-list {
  display: grid;
  gap: 12px;
}

.story-card {
  overflow: hidden;
}

.story-open {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 16px 16px 8px;
  border: 0;
  background: none;
  text-align: left;
}

.story-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
}

.story-meta {
  color: var(--muted);
  font-size: 14px;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 16px;
}

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.empty {
  padding: 8px 0;
}

/* ---------- Forms / new game ---------- */

.form {
  padding-bottom: 48px;
}

.step {
  margin: 24px 0;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 20px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
}

.step .input {
  margin-top: 10px;
}

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

.chip {
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}

.option span {
  color: var(--muted);
  font-size: 14px;
}

.option.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.sample {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
}

.sample.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.sample-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
}

.sample-meta {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sample-hook {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.banner.sample-chosen {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 600;
  font-size: 15px;
}

.seg3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.seg3.seg2 {
  grid-template-columns: repeat(2, 1fr);
}

.mode-choice {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.mode-card strong {
  font-size: 17px;
}

.mode-card span {
  color: var(--muted);
  font-size: 14px;
}

.mode-card:hover,
.mode-card:focus-visible {
  border-color: var(--accent);
}

.seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.seg span {
  color: var(--muted);
  font-size: 12px;
}

.seg.on {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.form .card .row {
  margin-top: 12px;
}

/* ---------- Story feed ---------- */

.feed {
  padding-top: 8px;
  padding-bottom: 180px;
}

.turn {
  scroll-margin-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px);
  margin: 0 0 8px;
}

.chapter {
  margin: 36px 0 12px;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.25;
  text-align: center;
}

.chapter::after {
  content: '';
  display: block;
  width: 48px;
  height: 2px;
  margin: 12px auto 0;
  background: var(--accent);
  opacity: 0.6;
}

.you {
  max-width: 85%;
  margin: 20px 0 10px auto;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--you-bg);
  color: var(--you-ink);
}

.you.oos {
  background: var(--oos-bg);
  color: var(--oos-ink);
}

.you-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.7;
}

.you-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.narrative {
  margin: 10px 0;
}

.narrative.aside {
  padding: 12px 14px;
  border-left: 3px solid var(--oos-ink);
  border-radius: 4px 12px 12px 4px;
  background: var(--oos-bg);
  color: var(--oos-ink);
}

.stamp {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.narrative.aside .stamp {
  color: inherit;
  opacity: 0.8;
}

.prose {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.6;
}

.prose p {
  margin: 0.6em 0;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose blockquote {
  margin: 0.8em 0;
  padding-left: 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.prose table {
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.meters {
  margin: 6px 0 4px;
}

.meter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
}

.mname {
  font-weight: 600;
}

.mchip.up .mdelta {
  color: var(--good);
  font-weight: 700;
}

.mchip.down .mdelta {
  color: var(--bad);
  font-weight: 700;
}

.mval {
  color: var(--muted);
}

.why {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.why summary {
  cursor: pointer;
  width: max-content;
  padding: 4px 0;
}

.why ul {
  margin: 4px 0;
  padding-left: 18px;
}

.note-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.msg-line {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.msg-line .icon {
  width: 18px;
  height: 18px;
}

.ending {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.ending-label {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.ended-panel {
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.ended-panel p {
  margin-top: 0;
}

/* ---------- Composer ---------- */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.composer-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px var(--gutter) 10px;
}

.mode-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.mode-chip {
  min-height: 34px;
  padding: 4px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.mode-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.mode-chip.ask {
  margin-left: auto;
}

.mode-chip.ask.on {
  background: var(--oos-bg);
  border-color: var(--oos-ink);
  color: var(--oos-ink);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 200px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 17px;
  line-height: 1.4;
  resize: none;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}

.send-btn.small {
  width: 38px;
  height: 38px;
  background: var(--im-me);
  color: #fff;
}

.send-btn.small .icon {
  width: 18px;
  height: 18px;
}

/* ---------- Phone ---------- */

.phone-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.phone-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.phone {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(100%, 420px);
  height: min(88vh, 760px);
  height: min(88dvh, 760px);
  transform: translateX(-50%);
  border-radius: 28px 28px 0 0;
  background: var(--phone-bg);
  color: var(--phone-ink);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3);
  font-family: var(--sans);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.phone.animate {
  animation: slide-up 0.25s ease-out;
}

@media (min-width: 640px) {
  .phone {
    bottom: 24px;
    border-radius: 36px;
    border: 8px solid #1b1b1f;
  }
}

@keyframes slide-up {
  from {
    transform: translate(-50%, 100%);
  }
  to {
    transform: translate(-50%, 0);
  }
}

.phone-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px 4px;
  font-size: 14px;
  font-weight: 700;
}

.phone-day {
  color: var(--phone-muted);
  font-weight: 600;
}

.phone-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.signal {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}

.signal i {
  width: 3px;
  background: currentColor;
  border-radius: 1px;
}

.signal i:nth-child(1) {
  height: 4px;
}
.signal i:nth-child(2) {
  height: 6px;
}
.signal i:nth-child(3) {
  height: 8px;
}
.signal i:nth-child(4) {
  height: 11px;
}

.battery {
  position: relative;
  width: 22px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.battery::after {
  content: '';
  position: absolute;
  inset: 1px 6px 1px 1px;
  background: currentColor;
  border-radius: 1px;
}

.phone-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.phone-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--phone-line);
}

.phone-head .icon-btn:hover {
  background: var(--phone-line);
}

.phone-title {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.phone-title > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-sub {
  color: var(--phone-muted);
  font-size: 13px;
  font-weight: 500;
}

.phone-empty,
.phone-note {
  padding: 24px;
  color: var(--phone-muted);
  text-align: center;
  font-size: 15px;
}

.phone-note {
  padding: 0 16px 8px;
  margin: 0;
  font-size: 13px;
}

.thread-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.thread-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--phone-line);
  background: none;
  text-align: left;
}

.thread-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.thread-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.thread-name {
  font-weight: 600;
}

.thread-row.unread .thread-name {
  font-weight: 800;
}

.thread-time {
  color: var(--phone-muted);
  font-size: 13px;
  white-space: nowrap;
}

.thread-preview {
  color: var(--phone-muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--im-me);
  flex: none;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: hsl(var(--hue) 42% 46%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--sans);
}

.avatar.group {
  border-radius: 12px;
}

.avatar.img {
  background: var(--surface-2);
  overflow: hidden;
}

.avatar.img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.img.group {
  border-radius: 50%;
}

.avatar.sm {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

.avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

/* ---------- Speech bubbles in the narrative ---------- */

.say {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 12px 0;
}

.say-bubble {
  max-width: 82%;
  padding: 8px 14px 10px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface-2);
}

.say-name {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.say-text {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.45;
}

.say-text p {
  margin: 0;
}

.say.mine {
  justify-content: flex-end;
}

/* The player's own turn: actions as a quiet line, speech as bubbles. */
.you-turn {
  margin: 20px 0 10px;
}

.you-do {
  margin: 6px 0 6px auto;
  max-width: 85%;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  text-align: right;
}

.you-turn .say {
  margin: 6px 0;
}

.say.mine .say-bubble {
  border-radius: 18px 18px 6px 18px;
  background: var(--you-bg);
  color: var(--you-ink);
}

.say.mine .say-name {
  color: var(--muted);
}

.narrative.aside .say-bubble {
  background: rgba(255, 255, 255, 0.06);
}

.im-scroll {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  padding: 12px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.im {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.im.them {
  align-self: flex-start;
  background: var(--im-them);
  color: var(--im-them-ink);
  border-bottom-left-radius: 6px;
}

.im.me {
  align-self: flex-end;
  background: var(--im-me);
  color: var(--im-me-ink);
  border-bottom-right-radius: 6px;
}

.im.sending {
  opacity: 0.6;
}

.typing-bubble {
  padding: 12px 14px;
}

.im-stamp {
  align-self: center;
  margin: 10px 0 4px;
  color: var(--phone-muted);
  font-size: 12px;
  font-weight: 600;
}

.im-seen {
  align-self: flex-end;
  color: var(--phone-muted);
  font-size: 12px;
}

.im-meter {
  align-self: center;
  margin: 4px 0;
  font-size: 12px;
  color: var(--phone-muted);
  text-align: center;
}

.im-meter.up {
  color: var(--good);
}

.im-meter.down {
  color: var(--bad);
}

.im-error {
  align-self: center;
  margin: 8px 0;
  color: var(--bad);
  font-size: 14px;
  text-align: center;
}

.im-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--phone-line);
}

.im-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--phone-line);
  border-radius: 20px;
  background: var(--phone-bg);
  color: var(--phone-ink);
  font-size: 16px;
}

/* ---------- Characters ---------- */

.intro {
  margin: 16px 0;
}

.char {
  margin: 0 0 12px;
  padding: 16px;
}

.char-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.char-id {
  flex: 1;
  min-width: 0;
}

.char-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
}

.char-role {
  color: var(--muted);
  font-size: 14px;
}

.char-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.char-score .num {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.char-score .lbl {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.mbar {
  position: relative;
  height: 8px;
  margin: 12px 0 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.mbar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--muted);
}

.mbar.warm .mbar-fill {
  background: var(--good);
}

.mbar.cold .mbar-fill {
  background: var(--bad);
}

.mbar-mid {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--bg);
}

.char-note {
  margin: 8px 0;
  font-size: 15px;
}

.char-log summary {
  cursor: pointer;
  padding: 6px 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.log {
  margin: 4px 0 0;
  padding-left: 0;
  list-style: none;
  font-size: 14px;
}

.log li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.log-when {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* ---------- New story: "You" questions ---------- */

.you-q {
  margin: 14px 0 0;
}

.you-q-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.chips.small .chip {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

/* ---------- Dice checks ---------- */

.checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.dice {
  --deg: var(--muted);
  border: 1px solid var(--line);
  border-left: 3px solid var(--deg);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
}

.dice.deg-critical {
  --deg: #e8c15a;
}

.dice.deg-success {
  --deg: var(--good);
}

.dice.deg-mixed {
  --deg: var(--accent);
}

.dice.deg-fail,
.dice.deg-disaster {
  --deg: var(--bad);
}

.dice summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.dice summary::-webkit-details-marker {
  display: none;
}

.dice .icon {
  width: 18px;
  height: 18px;
  color: var(--deg);
  flex: none;
}

.dice-what {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-deg {
  color: var(--deg);
  font-weight: 800;
  white-space: nowrap;
}

.dice.deg-critical .dice-deg,
.dice.deg-disaster .dice-deg {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dice-detail {
  padding: 0 12px 10px 36px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.dice-flag {
  margin-top: 4px;
  color: var(--accent);
}

/* ---------- Conditions ---------- */

.cond-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.cond-note {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.cond-note strong {
  color: var(--ink);
}

.cond-note.you {
  background: var(--accent-soft);
}

.cond-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bad);
  color: #1c1c1e;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}

/* ---------- Character sheets ---------- */

.you-card {
  border-color: var(--accent);
}

.sheet {
  margin-top: 10px;
}

.sheet-body {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.sheet-missing {
  margin: 10px 0 0;
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
}

.pill.bad {
  background: rgba(236, 123, 107, 0.15);
  color: var(--bad);
}

.tag-skill {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.sheet-stats summary {
  padding: 6px 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.stats {
  display: grid;
  gap: 6px;
  margin: 4px 0 8px;
}

.stat {
  display: grid;
  grid-template-columns: 82px 1fr 24px 96px;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.stat-name {
  color: var(--muted);
}

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

.stat-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.stat-num {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-word {
  color: var(--muted);
  font-size: 13px;
}

.step-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}
