:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --ink: #171717;
  --muted: #627076;
  --surface: #ffffff;
  --soft: #edf3f5;
  --line: #d7e0e4;
  --black: #111111;
  --coral: #e86f5a;
  --teal: #1b8d84;
  --gold: #c99b37;
  --danger: #b84636;
  --shadow: 0 24px 70px rgba(28, 21, 16, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(23, 23, 23, 0.08);
  background: #fffff7;
  color: #ffffff;
  font-weight: 900;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.eyebrow,
.rail-card p,
.memory-bar p,
.episode-cta span,
.drop-zone span,
.price-card p,
.value-grid p {
  color: var(--muted);
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item span {
  color: var(--ink);
  font-weight: 900;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--line);
  background: var(--soft);
}

.rail-card,
.panel,
.chat-panel,
.phone-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(28, 21, 16, 0.05);
}

.rail-card {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.rail-card h2,
.topbar h1,
.character-card h2,
.section-head h2,
.panel h2 {
  margin: 0;
  line-height: 1.15;
}

.rail-card p,
.price-card p,
.value-grid p {
  margin: 0;
  line-height: 1.7;
}

.intake-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.intake-list li {
  min-height: 30px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.rail-link,
.primary-button,
.ghost-button,
.mini-button,
.voice-button {
  border: 0;
  border-radius: var(--radius);
  text-decoration: none;
}

.rail-link,
.primary-button,
.ghost-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-button,
.rail-link {
  background: var(--black);
  color: #ffffff;
}

.ghost-button,
.mini-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.primary-button,
.ghost-button,
.mini-button,
.rail-link,
.voice-button {
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.mini-button:hover,
.rail-link:hover,
.voice-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(28, 21, 16, 0.08);
}

.workspace {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 36px) 36px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(500px, 1.05fr);
  gap: clamp(22px, 4vw, 58px);
  align-items: center;
  min-height: min(620px, calc(100vh - 34px));
  margin: -24px calc(clamp(16px, 3vw, 36px) * -1) 28px;
  padding: clamp(28px, 5vw, 58px) clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 18% 22%, rgba(250, 111, 97, 0.12), transparent 28%),
    linear-gradient(135deg, #fffaf0 0%, #f2fbfa 100%);
  overflow: hidden;
}

.topbar h1 {
  max-width: 760px;
  margin-top: 6px;
  font-size: clamp(36px, 4.2vw, 62px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
}

.proof-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 640px;
}

.proof-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.top-actions {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.top-actions .primary-button,
.top-actions .ghost-button {
  min-width: 148px;
  min-height: 52px;
  padding: 0 18px;
}

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

.brand-visual {
  display: block;
  width: 100%;
  min-height: 360px;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8ec;
  box-shadow: 0 24px 60px rgba(28, 21, 16, 0.12);
}

.brand-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

body.public-reader-mode [data-creator-only] {
  display: none !important;
}

body.public-reader-mode {
  background: #111111;
}

body.public-reader-mode .app-shell {
  display: block;
  min-height: 100vh;
}

body.public-reader-mode .rail,
body.public-reader-mode .topbar {
  display: none;
}

body.public-reader-mode .workspace {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px;
}

body.public-reader-mode .reader-layout {
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
  gap: 14px;
}

body.public-reader-mode .phone-frame,
body.public-reader-mode .chat-panel {
  box-shadow: none;
}

body.public-reader-mode .chat-panel {
  min-height: calc(100vh - 28px);
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.phone-frame {
  overflow: hidden;
  background: #151515;
  color: #ffffff;
}

.phone-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #151515;
  font-weight: 900;
}

.reader-meta {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #202020;
  scrollbar-width: none;
}

.reader-meta span {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 900;
}

.comic-strip {
  display: grid;
  gap: 0;
  max-height: calc(100vh - 248px);
  overflow: auto;
  scrollbar-width: thin;
}

.comic-page {
  position: relative;
  min-height: 680px;
  display: grid;
  align-content: end;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.55)),
    var(--page-bg, #312a25);
  background-size: cover;
  background-position: center;
}

.comic-page strong {
  width: fit-content;
  max-width: 90%;
  padding: 8px 10px;
  border: 2px solid #111;
  background: #ffffff;
  color: #111;
  font-size: 18px;
  line-height: 1.35;
}

.episode-cta {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #ffffff;
  color: var(--ink);
}

.episode-cta strong,
.episode-cta span {
  display: block;
}

.episode-cta span {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.6;
}

.reader-dock {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: #151515;
}

.reader-dock button {
  display: grid;
  gap: 2px;
  min-height: 58px;
  border: 0;
  background: #ffffff;
  color: var(--ink);
}

.reader-dock b,
.reader-dock span {
  display: block;
}

.reader-dock b {
  font-size: 14px;
}

.reader-dock span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.chat-panel {
  display: grid;
  gap: 14px;
  min-height: min(760px, calc(100vh - 130px));
  padding: 16px;
}

.character-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.character-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--coral), var(--teal));
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

.character-card p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.coin-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f5e6c1;
  color: #75530c;
  font-weight: 900;
  white-space: nowrap;
}

.memory-bar {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--soft);
}

.memory-bar span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.memory-bar p {
  margin: 0;
  line-height: 1.6;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 320px;
  max-height: 420px;
  overflow: auto;
  padding: 8px 4px;
}

.bubble {
  max-width: min(78%, 620px);
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.7;
}

.bubble.character {
  justify-self: start;
  background: var(--soft);
}

.bubble.reader {
  justify-self: end;
  background: var(--black);
  color: #ffffff;
}

.quick-prompts,
.voice-upsell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.reader-offers button {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(27, 141, 132, 0.2);
  border-radius: var(--radius);
  background: #eef8f6;
  color: var(--ink);
  text-align: left;
}

.reader-offers span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.reader-offers b {
  color: var(--teal);
}

.reader-name {
  display: grid;
  grid-template-columns: auto minmax(120px, 180px);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--muted);
  font-weight: 900;
}

.reader-name input {
  min-height: 32px;
  padding: 0 8px;
}

.quick-prompts button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--ink);
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.voice-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.studio-grid,
.billing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.studio-form {
  display: grid;
  gap: 12px;
}

.studio-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 900;
}

.form-actions,
.publish-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.share-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.share-tools a {
  min-width: 0;
}

.share-tools [aria-disabled="true"] {
  opacity: 0.48;
  pointer-events: none;
}

.publish-box,
.readiness-box,
.analytics-box {
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.publish-box span {
  color: var(--muted);
  font-weight: 900;
}

.readiness-box {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 10px;
}

.readiness-box span {
  color: var(--muted);
  font-weight: 900;
}

.readiness-box p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.readiness-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.readiness-box li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.readiness-box li.done {
  border-color: rgba(39, 128, 119, 0.35);
  background: #e4f4f2;
}

.readiness-box b {
  color: var(--muted);
  font-size: 12px;
}

.analytics-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.analytics-box span {
  color: var(--muted);
  font-weight: 900;
}

.analytics-box p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.analytics-box pre {
  grid-column: 1 / -1;
  min-height: 88px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  color: var(--ink);
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 18px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone.dragging {
  border-color: var(--teal);
  background: #e4f4f2;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.page-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.page-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.page-row img {
  width: 52px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
}

.value-grid,
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.value-grid article,
.price-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.price-card strong {
  font-size: 28px;
}

.price-card.featured {
  border-color: rgba(232, 111, 90, 0.55);
  box-shadow: var(--shadow);
}

.unlock-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.unlock-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.unlock-list span {
  color: var(--teal);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  transform: translateY(18px);
  opacity: 0;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--black);
  color: #ffffff;
  box-shadow: var(--shadow);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .brand-visual {
    order: -1;
    width: 100%;
    min-height: 260px;
    aspect-ratio: 2.65 / 1;
  }

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

  .topbar .proof-strip {
    display: none;
  }

  .rail {
    position: static;
    height: auto;
  }

  .rail-card {
    display: none;
  }

  .nav-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .reader-layout,
  .studio-grid,
  .billing-layout {
    grid-template-columns: 1fr;
  }

  .comic-strip {
    max-height: none;
  }

  body.public-reader-mode .reader-layout {
    grid-template-columns: 1fr;
  }

  body.public-reader-mode .chat-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .workspace,
  .rail {
    padding: 14px;
  }

  .topbar,
  .character-card,
  .section-head {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    margin: -14px -14px 20px;
    padding: 24px 14px;
  }

  .top-actions,
  .chat-composer,
  .form-actions,
  .publish-box,
  .share-tools,
  .analytics-box,
  .reader-offers,
  .value-grid,
  .price-grid {
    grid-template-columns: 1fr;
  }

  .nav-stack,
  .value-grid,
  .price-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button,
  .voice-button {
    width: 100%;
  }

  .topbar h1 {
    font-size: 34px;
  }

  .brand-visual {
    min-height: 240px;
    aspect-ratio: 4 / 3;
  }
  }

  body.public-reader-mode .workspace {
    padding: 0;
  }

  body.public-reader-mode .phone-frame,
  body.public-reader-mode .chat-panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  body.public-reader-mode .comic-page {
    min-height: 620px;
  }

  body.public-reader-mode .chat-panel {
    border-top: 0;
  }
}
