:root {
  color-scheme: dark;
  --black: #11100f;
  --ink: #191817;
  --panel: rgba(34, 32, 30, 0.96);
  --panel-solid: #24221f;
  --paper: #ebe2d3;
  --line: rgba(235, 226, 211, 0.14);
  --line-strong: rgba(235, 226, 211, 0.24);
  --text: #f1ece3;
  --muted: #a59e93;
  --soft: #d7cfc2;
  --green: #91a585;
  --cyan: #8aa6ad;
  --amber: #c0a16b;
  --rose: #b07572;
  --accent: #9faf91;
  --accent-dark: #252d24;
  --radius: 8px;
  --nav-h: 82px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    repeating-linear-gradient(0deg, rgba(235, 226, 211, 0.035) 0 1px, transparent 1px 28px),
    #151413;
  color: var(--text);
  overflow: hidden;
}

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

button {
  color: inherit;
}

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.phone-shell {
  position: relative;
  width: min(420px, 100vw);
  height: min(890px, 100dvh);
  max-height: 100dvh;
  overflow: hidden;
  border: 1px solid rgba(235, 226, 211, 0.18);
  border-radius: 30px;
  background: #171614;
  box-shadow: 0 26px 54px rgba(0, 0, 0, 0.38);
  touch-action: pan-y;
  isolation: isolate;
}

.wallpaper-strip {
  position: absolute;
  inset: 0;
  z-index: -3;
  display: grid;
  grid-template-columns: repeat(3, 100%);
  width: 300%;
  transform: translateX(-33.3333%);
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wallpaper {
  position: relative;
  overflow: hidden;
}

.wallpaper.custom-wallpaper {
  background-position: center;
  background-size: cover;
}

.wallpaper.custom-wallpaper::before {
  opacity: 0.22;
}

.wallpaper::before,
.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.wallpaper-left {
  background:
    linear-gradient(90deg, transparent 0 66%, rgba(176, 117, 114, 0.2) 66% 100%),
    linear-gradient(180deg, #181715 0 57%, #211f1b 57% 100%);
}

.wallpaper-left::before {
  background:
    linear-gradient(90deg, rgba(235, 226, 211, 0.1) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, transparent 0 78%, rgba(192, 161, 107, 0.18) 78% 80%, transparent 80% 100%);
  background-size: 48px 100%, 100% 100%;
}

.wallpaper-center {
  background:
    linear-gradient(90deg, rgba(145, 165, 133, 0.22) 0 28%, transparent 28% 100%),
    linear-gradient(180deg, #1a1917 0 48%, #20201d 48% 100%);
}

.wallpaper-center::before {
  background:
    linear-gradient(0deg, transparent 0 20%, rgba(235, 226, 211, 0.12) 20% 20.5%, transparent 20.5% 100%),
    linear-gradient(90deg, transparent 0 76%, rgba(138, 166, 173, 0.18) 76% 77%, transparent 77% 100%);
}

.wallpaper-right {
  background:
    linear-gradient(90deg, rgba(192, 161, 107, 0.18) 0 36%, transparent 36% 100%),
    linear-gradient(180deg, #171614 0 62%, #22201d 62% 100%);
}

.wallpaper-right::before {
  background:
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(235, 226, 211, 0.07) 26px 27px),
    linear-gradient(0deg, rgba(176, 117, 114, 0.14) 0 14%, transparent 14% 100%);
}

.screen-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    repeating-linear-gradient(90deg, rgba(235, 226, 211, 0.025) 0 1px, transparent 1px 18px),
    rgba(17, 16, 15, 0.2);
}

.system-bar {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 22px 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(241, 236, 227, 0.9);
}

.system-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signal {
  min-width: 22px;
  text-align: right;
}

.battery {
  position: relative;
  width: 25px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  padding: 2px;
}

.battery::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 3px;
  width: 2px;
  height: 5px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
}

.battery-fill {
  display: block;
  height: 100%;
  width: 86%;
  border-radius: 2px;
  background: currentColor;
}

.desktop-view,
.view-panel {
  position: absolute;
  inset: 42px 0 var(--nav-h);
  padding: 22px 20px 18px;
}

.desktop-view {
  z-index: 5;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  transition: opacity 240ms ease, transform 240ms ease;
}

.phone-shell:not([data-view="home"]) .desktop-view {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.desktop-widget {
  align-self: start;
  justify-self: start;
  display: grid;
  gap: 4px;
  min-width: 178px;
  border-left: 2px solid rgba(235, 226, 211, 0.38);
  padding-left: 12px;
}

.desktop-clock {
  font-size: clamp(44px, 16vw, 62px);
  line-height: 0.96;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-weight: 700;
}

.desktop-date {
  color: var(--soft);
  font-size: 14px;
}

.rp-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: 7px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(24, 23, 21, 0.72);
  color: var(--muted);
  font-size: 12px;
  text-transform: lowercase;
}

.rp-status[data-ready="true"] {
  color: var(--green);
}

.rp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.character-grid {
  align-self: start;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 13px;
  padding-top: 40px;
}

.character-app {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.app-icon {
  width: min(64px, 16vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(235, 226, 211, 0.18);
  border-radius: 8px;
  color: var(--paper);
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

.add-icon {
  background: #2c2a26;
  color: var(--muted);
}

.app-label {
  width: 100%;
  color: rgba(241, 236, 227, 0.9);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-bottom: 4px;
}

.page-dot {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 50%;
  background: rgba(235, 226, 211, 0.28);
  padding: 0;
}

.page-dot.active {
  width: 22px;
  border-radius: 999px;
  background: rgba(235, 226, 211, 0.78);
}

.view-panel {
  z-index: 10;
  display: none;
  grid-template-rows: auto 1fr;
  gap: 14px;
  min-height: 0;
  background: rgba(23, 22, 20, 0.97);
}

.phone-shell[data-view="story"] #view-story,
.phone-shell[data-view="photos"] #view-photos,
.phone-shell[data-view="chat"] #view-chat,
.phone-shell[data-view="settings"] #view-settings {
  display: grid;
}

#view-photos {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.panel-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.story-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-content: stretch;
}

#story-back {
  grid-column: 1;
}

.story-header > div:not(.story-header-actions) {
  grid-column: 2;
  min-width: 0;
}

.story-header-actions {
  grid-column: 3;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.story-menu {
  position: relative;
}

.story-menu-popover {
  position: absolute;
  z-index: 80;
  top: 46px;
  right: 0;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #24221f;
  padding: 6px;
}

.story-menu-popover button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--soft);
  text-align: left;
  cursor: pointer;
}

.story-menu-popover button:hover {
  background: rgba(235, 226, 211, 0.08);
}

.panel-header h1,
.chat-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-weight: 700;
}

.panel-header h2,
.settings-card h2,
.scene-card h2 {
  margin: 0;
  font-size: 15px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1d1c1a;
  color: var(--text);
  outline: 0;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(159, 175, 145, 0.72);
  box-shadow: 0 0 0 3px rgba(159, 175, 145, 0.13);
}

select {
  max-width: 168px;
  padding: 0 34px 0 12px;
}

input,
textarea {
  padding: 10px 12px;
}

textarea {
  resize: none;
}

.story-layout {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}

.story-card-list,
.story-room-panel,
.story-chat-panel {
  min-height: 0;
}

.story-card-list[hidden],
.story-room-panel[hidden],
.story-chat-panel[hidden] {
  display: none;
}

.story-card-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.story-room-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
}

.story-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.story-list-actions {
  display: grid;
}

.story-summary-card,
.story-room-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1b1a18;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.story-summary-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
  padding: 12px;
}

.story-card-avatar {
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(235, 226, 211, 0.16);
  border-radius: 8px;
  color: var(--paper);
  font-weight: 800;
}

.story-card-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.story-card-main strong,
.story-room-title {
  color: var(--text);
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 16px;
  line-height: 1.2;
}

.story-card-main span,
.story-card-date,
.story-room-count,
.story-room-date {
  color: var(--muted);
  font-size: 12px;
}

.story-card-date {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.story-room-card {
  display: grid;
  gap: 7px;
  padding: 13px;
}

.story-room-preview {
  min-height: 20px;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-card,
.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.scene-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.scene-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.scene-nav {
  display: flex;
  gap: 6px;
}

.scene-nav .icon-button {
  width: 34px;
  height: 34px;
}

.scene-nav .icon-button:disabled {
  opacity: 0.36;
  cursor: default;
}

.scene-card p {
  margin: 0;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.55;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.story-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #1b1a18;
}

.story-log,
.story-card-list,
.chat-stream,
.settings-stack {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}

.story-log {
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.story-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1b1a18;
  padding: 12px;
}

.story-entry.user {
  border-color: rgba(138, 166, 173, 0.28);
  background: #20282a;
}

.story-entry strong {
  display: block;
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 12px;
}

.story-entry p {
  margin: 0;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.56;
}

.story-entry.user p {
  color: #dce5e4;
}

.story-novel-card {
  background: #211f1c;
}

.story-novel-text {
  display: grid;
  gap: 10px;
}

.story-novel-card p {
  color: var(--text);
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 15px;
  line-height: 1.78;
}

.story-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.story-reply-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.story-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.text-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--soft);
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.icon-action {
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}

.share-icon,
.image-upload-icon {
  position: relative;
  display: block;
}

.share-icon {
  width: 18px;
  height: 18px;
}

.share-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 9px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 2px;
}

.share-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(-3deg);
}

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

.story-input-tools {
  display: flex;
  justify-content: flex-end;
}

.primary-action,
.secondary-action,
.icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.primary-action {
  min-height: 42px;
  background: var(--accent);
  color: #151413;
  font-weight: 800;
}

.secondary-action {
  min-height: 38px;
  background: #2b2925;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #2b2925;
  font-weight: 800;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-feature-strip {
  min-height: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.photo-feature {
  position: relative;
  scroll-snap-align: start;
  display: block;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.photo-feature-art {
  display: block;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-position: center;
  background-size: cover;
  background-color: #1b1a18;
}

.photo-feature-caption {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 2px;
  max-width: calc(100% - 28px);
  justify-items: end;
  color: #f5efe5;
  text-align: right;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 18px rgba(0, 0, 0, 0.78);
}

.photo-feature-caption strong {
  overflow: hidden;
  max-width: 100%;
  color: #f5efe5;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-section-header h2 {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-feature-caption span {
  max-width: 100%;
  overflow: hidden;
  color: rgba(245, 239, 229, 0.82);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.photo-sections {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.photo-section {
  display: grid;
  gap: 9px;
}

.photo-section-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.photo-section-header h2 {
  margin: 0;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}

.photo-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empty-art {
  background: linear-gradient(135deg, #1d1c1a 0 54%, #2f2c28 54% 100%);
}

.photo-tile {
  min-height: 154px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #1b1a18;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.photo-art {
  height: 114px;
  background-position: center;
  background-size: cover;
}

.photo-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px;
  color: var(--soft);
  font-size: 12px;
}

body.lightbox-open {
  overflow: hidden;
}

.photo-lightbox {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 6px;
  background: rgba(10, 10, 9, 0.94);
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  touch-action: pan-y;
}

.photo-lightbox-figure {
  position: relative;
  min-width: 0;
  margin: 0;
}

.photo-lightbox-art {
  width: 100%;
  height: min(78vh, 760px);
  border-radius: var(--radius);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.photo-lightbox-caption {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 3px;
  max-width: calc(100% - 36px);
  justify-items: end;
  color: #f5efe5;
  text-align: right;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 22px rgba(0, 0, 0, 0.8);
}

.photo-lightbox-caption strong,
.photo-lightbox-caption span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-lightbox-caption strong {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 18px;
}

.photo-lightbox-caption span {
  color: rgba(245, 239, 229, 0.82);
  font-size: 12px;
}

.photo-lightbox-close,
.photo-lightbox-nav {
  display: grid;
  place-items: center;
  border: 1px solid rgba(235, 226, 211, 0.2);
  border-radius: var(--radius);
  background: rgba(36, 34, 31, 0.78);
  color: var(--paper);
  cursor: pointer;
}

.photo-lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 42px;
  height: 42px;
  font-size: 20px;
}

.photo-lightbox-nav {
  width: 46px;
  height: 60px;
  font-size: 30px;
}

.chat-header {
  justify-content: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  font-weight: 800;
}

.chat-header h1 {
  font-size: 18px;
}

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

.chat-stream {
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 6px 2px 4px;
}

.chat-room-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.chat-room-list[hidden],
.chat-stream[hidden],
.chat-composer[hidden] {
  display: none;
}

.chat-room-card {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 10px 2px 12px;
  text-align: left;
  cursor: pointer;
}

.chat-room-avatar {
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  font-weight: 800;
}

.chat-room-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.chat-room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-room-top strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.chat-room-top time,
.chat-room-preview {
  color: var(--muted);
  font-size: 12px;
}

.chat-room-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-date-separator {
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #24221f;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 11px;
}

.bubble-row {
  display: flex;
}

.bubble-row.me {
  justify-content: flex-end;
}

.bubble {
  max-width: min(78%, 290px);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  background: #25231f;
  color: var(--text);
}

.bubble.has-attachment {
  display: grid;
  gap: 8px;
  padding: 6px;
}

.bubble-text {
  margin: 0;
  padding: 4px 5px;
  white-space: pre-wrap;
}

.chat-image-grid {
  display: grid;
  gap: 6px;
}

.chat-image-card {
  margin: 0;
  overflow: hidden;
  border-radius: 7px;
  background: #171614;
}

.chat-image-card img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
}

.bubble-stack {
  max-width: min(78%, 290px);
  display: grid;
  gap: 4px;
}

.bubble-stack .bubble {
  max-width: none;
}

.bubble-row.me .bubble {
  background: #314033;
  color: var(--paper);
}

.bubble-row.me .bubble-stack {
  justify-items: end;
}

.bubble-time {
  color: var(--muted);
  font-size: 10px;
}

.chat-composer {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.chat-tool-row {
  display: flex;
  justify-content: flex-end;
}

#chat-image-button {
  width: 38px;
  height: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  padding: 0;
}

.image-upload-icon {
  width: 20px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.image-upload-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.image-upload-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 11px;
  height: 7px;
  background: currentColor;
  clip-path: polygon(0 100%, 35% 35%, 55% 62%, 78% 18%, 100% 100%);
}

.chat-attachment-preview {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 74px;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.chat-attachment-chip {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #171614;
}

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

.chat-attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(235, 226, 211, 0.34);
  border-radius: 999px;
  background: rgba(17, 16, 15, 0.78);
  color: var(--paper);
  line-height: 1;
  cursor: pointer;
}

.chat-composer .primary-action {
  min-width: 64px;
  padding: 0 12px;
}

.settings-stack {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 2px;
}

.settings-menu {
  display: grid;
  gap: 10px;
}

.settings-category-main,
.settings-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1d1c1a;
  color: var(--soft);
  cursor: pointer;
}

.settings-category-main {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 13px 14px;
  text-align: left;
}

.settings-category-main strong {
  color: var(--text);
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 18px;
}

.settings-category-main > span:last-child {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.settings-category-kicker {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.settings-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.settings-tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 10px 8px;
  text-align: center;
}

.settings-tile strong {
  max-width: 100%;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.25;
}

.settings-tile-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(235, 226, 211, 0.18);
  border-radius: 8px;
  background: #24221f;
  color: var(--paper);
  font-weight: 800;
}

.settings-category-main.active,
.settings-tile.active {
  background: var(--accent-dark);
  border-color: rgba(159, 175, 145, 0.46);
}

.settings-panel {
  display: none;
  gap: 12px;
}

.settings-panel.active {
  display: grid;
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.settings-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-card label span {
  color: var(--soft);
}

.settings-card select {
  max-width: none;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.version-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.version-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.version-list dt {
  color: var(--muted);
}

.version-list dd {
  margin: 0;
  color: var(--soft);
}

.bottom-nav {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #181715;
}

.bottom-nav button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.bottom-nav button.active {
  color: var(--text);
  background: rgba(235, 226, 211, 0.08);
}

.bottom-nav .home-button {
  align-self: start;
  min-height: 58px;
  border: 1px solid rgba(235, 226, 211, 0.18);
  background: #24221f;
  color: var(--soft);
}

.bottom-nav .home-button.active {
  background: var(--paper);
  color: #151413;
}

.nav-icon {
  width: 22px;
  height: 22px;
  position: relative;
  display: block;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  border-color: currentColor;
}

.nav-story::before {
  inset: 3px 5px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-story::after {
  left: 8px;
  top: 8px;
  width: 6px;
  border-top: 2px solid currentColor;
  box-shadow: 0 5px 0 currentColor;
}

.nav-photos::before {
  inset: 4px 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.nav-photos::after {
  left: 6px;
  bottom: 5px;
  width: 10px;
  height: 7px;
  background: currentColor;
  clip-path: polygon(0 100%, 35% 35%, 55% 60%, 76% 20%, 100% 100%);
}

.nav-home::before {
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 10px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 2px;
}

.nav-home::after {
  left: 5px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.nav-chat::before {
  inset: 4px 3px 6px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.nav-chat::after {
  left: 8px;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-18deg);
}

.nav-settings::before {
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-settings::after {
  inset: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.is-loading {
  opacity: 0.66;
  pointer-events: none;
}

@media (max-width: 520px) {
  body {
    overflow: hidden;
  }

  .stage {
    padding: 0;
  }

  .phone-shell {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .desktop-view,
  .view-panel {
    padding-inline: 16px;
  }

  .character-grid {
    gap: 17px 10px;
  }
}

@media (max-height: 720px) {
  .desktop-clock {
    font-size: 42px;
  }

  .character-grid {
    padding-top: 12px;
  }

  .photo-tile {
    min-height: 132px;
  }

  .photo-art {
    height: 94px;
  }
}
