:root {
  color-scheme: light;
  --paper: #f7f3ed;
  --ink: #1d1c1a;
  --muted: #6c665f;
  --line: rgba(29, 28, 26, 0.14);
  --accent: #d74d2f;
  --accent-dark: #b83d24;
  --placeholder: #746e68;
  font-family:
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic",
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 0, rgba(236, 170, 144, 0.2), transparent 34rem),
    var(--paper);
}

a {
  color: inherit;
}

button,
a,
input,
textarea,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(215, 77, 47, 0.26);
  outline-offset: 3px;
}

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

.write-header,
.write-main,
.write-footer {
  width: min(1080px, calc(100% - 40px));
  margin-inline: auto;
}

.write-header {
  padding: 24px 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
}

.brand-variant {
  color: var(--accent);
}

.audience-badge {
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

body.adult-surface {
  color-scheme: dark;
  --paper: #171319;
  --ink: #f5edf2;
  --muted: #b5a8b1;
  --line: rgba(245, 237, 242, 0.16);
  --accent: #e16a62;
  --accent-dark: #f39991;
  --gold: #caa26c;
  --placeholder: #c9bdc5;
  background:
    radial-gradient(circle at 85% 0, rgba(154, 43, 90, 0.3), transparent 34rem),
    var(--paper);
}

body.adult-surface .brand {
  gap: 8px;
}

body.adult-surface .brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--gold);
  border-radius: 50% 50% 50% 10%;
  color: var(--gold);
  background: transparent;
  font-family: Georgia, serif;
  font-style: italic;
}

body.adult-surface .brand-variant {
  color: var(--accent);
}

body.adult-surface .story-form,
body.adult-surface select,
body.adult-surface input,
body.adult-surface textarea,
body.adult-surface .account-button,
body.adult-surface .thread-list button,
body.adult-surface .advanced-controls,
body.adult-surface .writing-controls,
body.adult-surface .type-card {
  background-color: rgba(255, 255, 255, 0.06);
}

.mode-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-button {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.settings-assistant {
  margin-bottom: 15px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(215, 77, 47, 0.15);
  border-radius: 13px;
  background: rgba(215, 77, 47, 0.045);
}

.settings-assistant strong,
.settings-assistant small {
  display: block;
}

.settings-assistant strong {
  font-size: 12px;
}

.settings-assistant small {
  margin-top: 3px;
  line-height: 1.5;
}

.settings-assistant button {
  flex: 0 0 auto;
  padding: 9px 11px;
  border: 1px solid rgba(215, 77, 47, 0.2);
  border-radius: 10px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.62);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.settings-assistant button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.settings-draft-status {
  min-height: 1.5em;
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 10px;
}

.reference-framing {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.34);
}

.reference-framing strong,
.reference-framing small {
  display: block;
}

.reference-framing strong {
  font-size: 12px;
}

.reference-framing small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.reference-pattern {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-pattern-part {
  min-width: min(100%, 220px);
  flex: 1 1 240px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  white-space: nowrap;
}

.reference-pattern-part input {
  min-width: 0;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  background: transparent;
}

.reference-pattern-part:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px rgba(215, 77, 47, 0.08);
}

select,
input,
textarea {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

select {
  padding: 9px 34px 9px 11px;
  border-radius: 10px;
}

.write-main {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 74px;
  align-items: start;
  padding-bottom: 100px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

h1 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(46px, 6vw, 78px);
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -0.08em;
}

.write-intro > p:last-child {
  margin: 28px 0 0;
  color: var(--muted);
  line-height: 1.9;
}

.thread-panel {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.thread-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.thread-heading p,
.thread-heading h2 {
  margin: 0;
}

.thread-heading p {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.thread-heading h2 {
  margin-top: 4px;
  font-size: 18px;
}

.thread-heading button,
.output-header button {
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.thread-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.thread-search {
  margin-top: 14px;
}

.thread-search input {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 12px;
}

.thread-list button {
  width: 100%;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.4);
  text-align: left;
  cursor: pointer;
}

.thread-list button.active {
  border-color: var(--accent);
  background: rgba(215, 77, 47, 0.07);
}

.thread-list button strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-list button small,
.thread-empty {
  color: var(--muted);
  font-size: 9px;
}

.thread-empty {
  margin: 0;
  padding: 12px 0;
}

.story-form {
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 24px 70px rgba(58, 42, 28, 0.11);
  backdrop-filter: blur(16px);
}

.form-map {
  margin: 0 0 24px;
  padding: 0 0 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.form-map li {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.form-map li span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--accent);
  background: rgba(215, 77, 47, 0.09);
}

fieldset {
  min-width: 0;
  margin: 0 0 22px;
  padding: 0 0 22px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.creation-type legend {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 850;
}

.creation-type {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.creation-type legend {
  grid-column: 1 / -1;
}

.type-card {
  position: relative;
  min-height: 98px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.48);
  cursor: pointer;
}

.type-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(215, 77, 47, 0.07);
  box-shadow: 0 0 0 3px rgba(215, 77, 47, 0.08);
}

.type-card input {
  width: 17px;
  height: 17px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.type-card > span {
  margin: 0;
}

.type-card strong,
.type-card small {
  display: block;
}

.type-card strong {
  font-size: 14px;
}

.type-card small {
  margin-top: 6px;
  line-height: 1.5;
}

.generation-route {
  margin: 0 0 22px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(215, 77, 47, 0.18);
  border-radius: 15px;
  background: rgba(215, 77, 47, 0.055);
}

.generation-route.own {
  border-color: rgba(48, 91, 148, 0.2);
  background: rgba(48, 91, 148, 0.055);
}

.generation-route strong,
.generation-route small {
  display: block;
}

.generation-route strong {
  font-size: 13px;
}

.generation-route small {
  margin-top: 3px;
  line-height: 1.5;
}

.route-kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

#route-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(215, 77, 47, 0.1);
  font-size: 9px;
  font-weight: 900;
}

.route-actions {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  gap: 7px;
}

#own-api-recommendation {
  padding: 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  font: inherit;
  font-size: 10px;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.generation-route.own #own-api-recommendation {
  display: none;
}

.subscription-card {
  margin: -10px 0 22px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 15px;
  background: color-mix(in srgb, var(--accent) 4%, var(--paper));
}

.subscription-card strong,
.subscription-card small {
  display: block;
}

.subscription-card strong {
  font-size: 13px;
}

.subscription-card small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.5;
}

.subscription-card a {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.subscription-card a[aria-disabled="true"] {
  color: var(--muted);
  background: var(--line);
  cursor: default;
}

.own-api-settings {
  margin: -8px 0 22px;
  padding: 18px;
  border: 1px solid rgba(48, 91, 148, 0.18);
  border-radius: 18px;
  background: rgba(241, 246, 251, 0.72);
}

.own-api-settings[hidden] {
  display: none;
}

.own-api-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.own-api-heading h2 {
  margin: 0;
  font-size: 16px;
}

.own-api-heading a {
  color: #305b94;
  font-size: 10px;
  font-weight: 850;
  text-decoration: none;
}

.own-api-grid {
  margin-top: 15px;
}

.own-api-settings select {
  width: 100%;
}

.api-key-field {
  margin-top: 14px;
}

.api-privacy-note {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

label {
  display: block;
}

label > span,
.prompt-field > span {
  display: block;
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 850;
}

small {
  color: var(--muted);
  font-weight: 500;
}

textarea,
input {
  width: 100%;
  padding: 14px 15px;
  border-radius: 13px;
  outline: none;
  line-height: 1.7;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 77, 47, 0.12);
}

.prompt-field textarea {
  min-height: 220px;
  font-size: 16px;
}

.field-help {
  display: block;
  margin: 7px 2px 0;
  font-size: 10px;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.route-technical {
  margin-top: 7px;
  padding: 0;
  border: 0;
}

.route-technical summary {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
}

.route-technical span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.writing-controls {
  margin-top: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(247, 243, 237, 0.72);
}

.controls-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.controls-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.controls-heading h2 {
  margin: 0;
  font-size: 19px;
}

.controls-heading button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.controls-help {
  margin: 9px 0 19px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.controls-loading,
.controls-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  font-size: 12px;
}

.controls-error {
  color: #8a3727;
  background: rgba(183, 68, 44, 0.08);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
}

.range-control > span,
.range-control small {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.range-control > span {
  margin-bottom: 7px;
  font-size: 12px;
}

.range-control output {
  min-width: 24px;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(215, 77, 47, 0.09);
  text-align: center;
  font-weight: 900;
}

.range-control input {
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}

.range-control small {
  margin-top: 2px;
  font-size: 9px;
}

details {
  margin-top: 18px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

summary {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.advanced-controls {
  margin-top: 18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.24);
}

.advanced-controls > summary {
  min-height: 52px;
  margin: 0;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  list-style: none;
}

.advanced-controls > summary::-webkit-details-marker {
  display: none;
}

.advanced-controls > summary::after {
  margin-left: auto;
  color: var(--accent);
  content: "＋";
  font-size: 18px;
}

.advanced-controls[open] > summary::after {
  content: "−";
}

.advanced-controls > summary strong,
.advanced-controls > summary small {
  display: block;
}

.advanced-controls > summary strong {
  color: var(--ink);
  font-size: 13px;
}

.advanced-controls > summary small {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.5;
}

.advanced-controls .writing-controls {
  margin: 0 12px 12px;
}

.submit-row {
  margin-top: 22px;
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-top: 1px solid var(--line);
}

.primary-submit {
  margin-top: 20px;
  padding: 18px;
  border: 0;
  border-radius: 16px;
  background: rgba(215, 77, 47, 0.06);
}

.submit-row p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.submit-row button,
.dialog-actions a,
.dialog-actions button {
  flex: 0 0 auto;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.submit-row button:hover,
.dialog-actions a:hover,
.dialog-actions button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
  box-shadow: 0 8px 24px rgba(184, 61, 36, 0.18);
}

.submit-row button:disabled,
.continue-form button:disabled,
.dialog-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.submit-row button span {
  margin-left: 26px;
}

.writer-output {
  grid-column: 1 / -1;
  scroll-margin-top: 22px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 24px 70px rgba(58, 42, 28, 0.09);
}

.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.output-header h2 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 500;
}

.memory-status {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.memory-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #5f8a6c;
  content: "";
}

.memory-status[data-state="attention"]::before {
  background: #b77a35;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.output-header button {
  min-height: 40px;
  padding: 7px 4px;
}

.output-header .danger-action {
  color: #9c3e2c;
}

.transcript {
  display: grid;
  gap: 20px;
  margin-top: 26px;
}

.message {
  max-width: 88%;
  padding: 18px 20px;
  border-radius: 18px;
}

.message.user {
  margin-left: auto;
  background: rgba(215, 77, 47, 0.09);
  border-bottom-right-radius: 5px;
}

.message.assistant {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  border-bottom-left-radius: 5px;
}

.message-role {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.message-content {
  line-height: 1.95;
  white-space: pre-wrap;
}

.continue-form {
  margin-top: 28px;
  padding-top: 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
}

.continue-form button {
  min-height: 54px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.continue-form button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

.support-strip {
  margin-top: 20px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.support-strip p {
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
}

.support-strip strong,
.support-strip span {
  display: block;
}

.support-strip strong {
  color: var(--ink);
  font-size: 11px;
}

.support-strip a {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  text-decoration: none;
}

.affiliate-shelf {
  margin-top: 18px;
  border: 1px solid rgba(29, 28, 26, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.32);
}

.draft-affiliate-shelf {
  margin-top: 16px;
  background: transparent;
}

.draft-affiliate-shelf summary {
  min-height: 48px;
}

.affiliate-shelf details {
  padding: 0;
}

.affiliate-shelf summary {
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}

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

.affiliate-shelf summary::after {
  margin-left: auto;
  color: var(--muted);
  content: "＋";
  font-size: 14px;
}

.affiliate-shelf details[open] summary::after {
  content: "−";
}

.affiliate-label {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.affiliate-shelf summary strong,
.affiliate-shelf summary small {
  display: block;
}

.affiliate-shelf summary strong {
  color: var(--ink);
  font-size: 11px;
}

.affiliate-shelf summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.affiliate-note,
.affiliate-disclosure {
  margin: 0;
  padding: 0 15px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.affiliate-items {
  padding: 10px 15px;
  display: grid;
  gap: 7px;
}

.affiliate-items a,
.affiliate-items .affiliate-preview {
  position: relative;
  padding: 10px 34px 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  text-decoration: none;
}

.affiliate-items a:hover {
  border-color: rgba(177, 77, 48, 0.35);
}

.affiliate-items .affiliate-preview {
  padding-right: 11px;
  opacity: 0.78;
}

.affiliate-items strong,
.affiliate-items span:not(.affiliate-arrow) {
  display: block;
}

.affiliate-items strong {
  font-size: 10px;
}

.affiliate-items span:not(.affiliate-arrow) {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.affiliate-arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--accent);
  transform: translateY(-50%);
}

.affiliate-disclosure {
  padding-bottom: 13px;
  font-size: 8px;
}

.sponsor-card {
  grid-column: 1 / -1;
  min-height: 72px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(29, 28, 26, 0.09);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.3);
}

.sponsor-label {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.sponsor-copy strong {
  display: block;
  color: var(--ink);
  font-size: 11px;
}

.sponsor-copy p {
  margin: 3px 0 0;
  font-size: 9px;
  line-height: 1.55;
}

.sponsor-card a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-decoration: none;
}

.sponsor-card a:hover {
  color: var(--accent);
}

dialog {
  width: min(540px, calc(100% - 30px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(29, 28, 26, 0.5);
  backdrop-filter: blur(5px);
}

.dialog-shell {
  position: relative;
  padding: 38px;
}

.dialog-shell h2 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 36px;
}

.dialog-shell > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.8;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.dialog-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog-actions button {
  color: var(--ink);
  background: rgba(29, 28, 26, 0.08);
}

.auth-message {
  min-height: 1.6em;
  margin: 14px 0 0;
  color: #9c3e2c;
  font-size: 12px;
}

.demo-login-button {
  width: 100%;
  min-height: 60px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.demo-login-button small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 650;
  opacity: 0.82;
}

.demo-login-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.password-login-section {
  margin-top: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 5%, var(--paper));
}

.password-login-section[hidden] {
  display: none;
}

.password-login-heading h3,
.password-login-heading p {
  margin: 0;
}

.password-login-heading p,
.password-auth-step > small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.password-auth-step {
  display: grid;
  gap: 12px;
}

.password-auth-step[hidden],
.password-credential-fields[hidden] {
  display: none;
}

.password-auth-step label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.password-login-section input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
}

.password-login-section button {
  min-height: 42px;
  padding-inline: 14px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.password-selected-address {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.48);
}

.password-selected-address > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.password-selected-address > strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.password-selected-address .text-action {
  min-height: 32px;
  padding: 4px 10px;
  color: var(--accent);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
}

.password-auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--ink) 4%, var(--paper));
}

.password-auth-mode button {
  min-height: 36px;
  color: var(--ink);
  background: transparent;
}

.password-auth-mode button.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.12);
}

.password-credential-fields {
  display: grid;
  gap: 12px;
}

.password-login-section button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.trial-callout {
  display: grid;
  gap: 3px;
  margin: 20px 0;
  padding: 15px 17px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 7%, var(--paper));
}

.trial-callout span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.social-login-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.provider-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.provider-button:hover {
  border-color: var(--ink);
}

.provider-button[aria-disabled="true"] {
  border-style: dashed;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.provider-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 16px;
  font-weight: 800;
}

.google-mark {
  color: #4285f4;
}

.apple-mark {
  color: #111;
  font-size: 12px;
}

#google-button-host {
  min-height: 44px;
}

#google-button-host > div {
  margin-inline: auto;
}

.text-action {
  border: 0;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-actions button {
  color: #fff;
  background: var(--accent);
}

.auth-actions .secondary-action {
  color: var(--ink);
  background: rgba(29, 28, 26, 0.08);
}

.auth-primary button {
  width: 100%;
  padding-block: 15px;
}

.auth-divider {
  margin: 22px 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.auth-register {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.38);
}

.auth-register h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.auth-register button {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(29, 28, 26, 0.06);
  font-weight: 850;
  cursor: pointer;
}

.auth-fine {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.provider-status-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(29, 28, 26, 0.045);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

/*
 * The night theme uses light text. Keep every nested surface dark as well;
 * otherwise the light-theme translucent whites become white-on-white cards.
 */
body.adult-surface .settings-assistant button,
body.adult-surface .reference-framing,
body.adult-surface .advanced-controls,
body.adult-surface .writing-controls,
body.adult-surface .controls-loading,
body.adult-surface .writer-output,
body.adult-surface .message.assistant,
body.adult-surface .affiliate-shelf,
body.adult-surface .sponsor-card,
body.adult-surface .password-selected-address,
body.adult-surface .auth-register,
body.adult-surface .provider-status-note {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

body.adult-surface .reference-pattern-part,
body.adult-surface .controls-heading button,
body.adult-surface .affiliate-items a,
body.adult-surface .affiliate-items .affiliate-preview,
body.adult-surface .password-login-section input,
body.adult-surface .provider-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.075);
}

body.adult-surface .provider-button[aria-disabled="true"] {
  color: #d0c4cc;
  background: #252027;
}

body.adult-surface .apple-mark {
  color: var(--ink);
}

body.adult-surface .auth-actions .secondary-action,
body.adult-surface .auth-register button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.085);
}

body.adult-surface .auth-message,
body.adult-surface .output-header .danger-action {
  color: #ff9fba;
}

body.adult-surface .story-form {
  border-color: var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.write-footer {
  padding: 28px 0 45px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.write-footer a {
  text-decoration: none;
}

@media (max-width: 820px) {
  .write-main {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .write-intro h1 br {
    display: none;
  }
}

@media (max-width: 620px) {
  .write-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 0 32px;
  }

  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
  }

  .mode-picker {
    min-width: 0;
    display: grid;
    gap: 5px;
  }

  .mode-picker select {
    width: 100%;
  }

  .account-button {
    width: auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .generation-route {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-actions {
    width: 100%;
    justify-items: start;
  }

  .field-grid,
  .creation-type,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .story-form {
    padding: 20px;
  }

  .submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .submit-row button {
    width: 100%;
  }

  .writer-output {
    padding: 22px 18px;
  }

  .output-header {
    align-items: stretch;
    flex-direction: column;
  }

  .output-actions {
    justify-content: flex-start;
  }

  .message {
    max-width: 96%;
  }

  .continue-form {
    grid-template-columns: 1fr;
  }

  .continue-form button {
    width: 100%;
  }

  .support-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .subscription-card {
    align-items: stretch;
    flex-direction: column;
  }

  .subscription-card a {
    text-align: center;
  }

  .sponsor-card {
    grid-template-columns: auto 1fr;
  }

  .sponsor-card a {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
