@font-face {
  font-family: "Blueaka";
  src: url("../assets/fonts/Blueaka.woff2?v=20261205f") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Czealo · local conversation
   Flat, quiet, DSH-like shell. No build step, no external assets.
   -------------------------------------------------------------------------- */

:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --sidebar: #fbfbfc;
  --line: #e8e8ea;
  --line-strong: #dcdce0;
  --text: #1f2023;
  --text-2: #5f6168;
  --muted: #8c8e95;
  --accent: #2f6fed;
  --accent-soft: #edf3ff;
  --danger: #b84848;
  --shadow: 0 12px 36px rgba(20, 20, 28, 0.08);
  --radius: 14px;
  --sans: "Blueaka";
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

::selection {
  background: #dce8ff;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100dvh;
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 12px 10px;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 14px;
}

.side-brand {
  display: flex;
  gap: 9px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  color: #fff;
  background: #232428;
  border-radius: 8px;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--sans);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.side-close {
  display: none !important;
}

.new-session {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  color: #303136;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02);
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.new-session:hover {
  background: #f4f4f6;
  border-color: var(--line-strong);
}

.new-session svg {
  color: #55575e;
}

.new-session span {
  flex: 1;
}

.new-session kbd {
  color: #a0a2a8;
  background: #f5f5f7;
  border: 1px solid #ececef;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: var(--sans);
  font-size: 9px;
}

.side-section {
  min-height: 0;
  margin-top: 18px;
}

.sessions-section {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 120px;
}

.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.side-label span:last-child {
  color: #b0b2b8;
  font-variant-numeric: tabular-nums;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: #dcdce1 transparent;
}

.session-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.14s;
}

.session-item:hover {
  background: #f0f0f3;
}

.session-item.is-active {
  background: #ececef;
}

.session-title {
  overflow: hidden;
  color: #37383d;
  font-size: 12.5px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item.is-active .session-title {
  color: #141518;
  font-weight: 500;
}

.session-time {
  color: #a4a6ac;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.session-sub {
  grid-column: 1 / -1;
  overflow: hidden;
  color: #9a9ca2;
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-delete {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 22px;
  height: 22px;
  color: #999ba1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  opacity: 0;
  place-items: center;
  transform: translateY(-50%);
  transition: opacity 0.12s;
}

.session-item:hover .session-delete,
.session-item:focus-within .session-delete {
  opacity: 1;
}

@media (hover: none) {
  .session-item.is-active .session-delete {
    opacity: 1;
  }
}

.session-delete:hover {
  color: var(--danger);
  border-color: #eccaca;
}

.session-empty {
  padding: 16px 10px;
  color: var(--muted);
  font-size: 12px;
}

.side-spacer {
  flex: 0 0 12px;
}

/* Character card */

.character-card {
  padding: 13px 11px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.character-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.portrait-stack {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  overflow: hidden;
  background: #f2f2f4;
  border: 1px solid #ececef;
  border-radius: 10px;
}

.portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.portrait.is-active {
  opacity: 1;
}

.character-name {
  min-width: 0;
  flex: 1;
}

.character-name strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #27282c;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.character-name p {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #b9bbc1;
  border-radius: 50%;
  transition: background 0.2s;
}

.online-dot.is-online {
  background: #3baa6a;
  box-shadow: 0 0 0 3px rgba(59, 170, 106, 0.1);
}

.online-dot.is-offline {
  background: #ce6a6a;
}

.sound-btn {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  color: #9b9da4;
  border-radius: 7px;
}

.sound-btn:hover {
  color: #3e4046;
  background: #f4f4f6;
}

.sound-btn.is-on {
  color: var(--accent);
  background: var(--accent-soft);
}

.inner-card {
  margin-top: 10px;
  padding: 8px 9px;
  background: #fafafa;
  border-radius: 8px;
  transition: opacity 0.18s;
}

.inner-card.is-changing {
  opacity: 0.3;
}

.inner-label {
  display: block;
  margin-bottom: 2px;
  color: #b1b3b9;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.inner-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #73757c;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 11px;
  line-height: 1.55;
}

.character-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}

.mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #66686f;
  font-size: 10.5px;
}

.mood-dot {
  width: 6px;
  height: 6px;
  background: #9eb5d8;
  border-radius: 50%;
}

.mood-dot[data-mood="happy"] { background: #e6ae72; }
.mood-dot[data-mood="shy"] { background: #e7a2b4; }
.mood-dot[data-mood="sad"] { background: #94a3bd; }
.mood-dot[data-mood="anxious"] { background: #c2a0cf; }
.mood-dot[data-mood="angry"] { background: #d48686; }
.mood-dot[data-mood="puzzled"] { background: #b1b58e; }
.mood-dot[data-mood="sleepy"] { background: #b6b0c6; }

.stage-time {
  color: #b0b2b8;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.affinity {
  margin-top: 7px;
}

.affinity-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #a3a5ab;
  font-size: 9.5px;
}

.affinity-stage {
  color: #82848b;
}

.affinity-track {
  height: 3px;
  overflow: hidden;
  background: #efeff1;
  border-radius: 99px;
}

.affinity-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #caa4ae;
  border-radius: inherit;
  transition: width 0.5s ease;
}

.stage-quote {
  margin: 8px 0 0;
  color: #9b9da3;
  font-family: var(--sans);
  font-size: 10.5px;
}

.side-age {
  margin: 6px 0 0;
  color: #b0b2b8;
  font-size: 9.5px;
}

.side-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 6px 2px;
}

.side-link {
  padding: 0;
  color: #9b9da3;
  font-size: 10.5px;
  text-align: left;
}

.side-link:hover {
  color: #3f4046;
}

.side-link.danger:hover {
  color: var(--danger);
}

.sidebar-scrim {
  display: none;
}

/* --------------------------------------------------------------------------
   Main
   -------------------------------------------------------------------------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.main-head {
  z-index: 5;
  display: flex;
  flex: 0 0 64px;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.menu-btn {
  display: none !important;
}

.head-title {
  min-width: 0;
  flex: 1;
}

.crumb {
  margin: 0 0 1px;
  color: #a2a4aa;
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

.crumb span {
  margin: 0 5px;
  color: #c5c7cc;
}

.head-title h1 {
  overflow: hidden;
  margin: 0;
  color: #26272b;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.age-badge {
  padding: 3px 8px;
  color: #777980;
  background: #f7f7f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10.5px;
  white-space: nowrap;
}

.age-badge:hover {
  color: #4c4e54;
  border-color: var(--line-strong);
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  color: #8d8f96;
  font-size: 10.5px;
  white-space: nowrap;
}

.text-btn {
  padding: 5px 7px;
  color: #66686f;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.text-btn:hover {
  color: #202126;
  background: #f4f4f6;
}

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  color: #66686f;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10.5px;
  white-space: nowrap;
}

.view-toggle:hover {
  color: #202126;
  border-color: var(--line-strong);
}

.view-toggle svg {
  color: #8b8d94;
}

/* Large, always-visible portrait: the stage follows her current mood. */
.avatar-stage {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px 10px;
  background: linear-gradient(180deg, #fbfbfc 0%, #fff 100%);
  border-bottom: 1px solid var(--line);
}

.avatar-frame {
  position: relative;
  width: clamp(168px, 23vh, 224px);
  aspect-ratio: 1;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e3e3e6;
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(30, 31, 36, 0.08);
}

.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.32s ease;
}

.avatar-img.is-active {
  opacity: 1;
}

.avatar-caption {
  margin-top: 7px;
  text-align: center;
}

.avatar-name {
  margin: 0;
  color: #2b2c31;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.avatar-face {
  margin-left: 5px;
  color: #9a9ca2;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0;
}

.avatar-mood {
  margin: 1px 0 0;
  color: #989aa1;
  font-size: 10px;
}

.avatar-quote {
  margin: 3px 0 0;
  color: #777980;
  font-size: 11px;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #dedee2 transparent;
}

.chat-inner {
  width: 100%;
  max-width: 788px;
  margin: 0 auto;
  padding: 30px 28px 8px;
}

/* --------------------------------------------------------------------------
   Welcome / age gate
   -------------------------------------------------------------------------- */

.cover {
  max-width: 660px;
  margin: 4vh auto 30px;
  padding: 24px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.cover.is-leaving {
  opacity: 0;
  transform: translateY(-5px);
}

.welcome-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.welcome-portrait {
  flex: 0 0 72px;
  width: 72px;
  height: 88px;
  overflow: hidden;
  border: 1px solid #ececef;
  border-radius: 10px;
}

.welcome-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 5px;
  color: #a6a8ae;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.welcome-head h2 {
  margin: 0 0 7px;
  color: #25262a;
  font-family: var(--sans);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.cover-sub {
  margin: 0;
  color: #777980;
  font-size: 12.5px;
  line-height: 1.75;
}

.age-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #ececef;
}

.age-title {
  margin: 0 0 9px;
  color: #55575e;
  font-size: 12px;
  font-weight: 500;
}

.age-title span {
  margin-left: 4px;
  color: #a3a5ab;
  font-size: 10.5px;
  font-weight: 400;
}

.age-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.age-chip {
  padding: 5px 10px;
  color: #6f7178;
  background: #fff;
  border: 1px solid #e2e2e6;
  border-radius: 7px;
  font-size: 11.5px;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}

.age-chip:hover {
  color: #34353a;
  border-color: #c9cad0;
}

.age-chip.is-selected {
  color: #fff;
  background: #2c2d32;
  border-color: #2c2d32;
}

.age-chip:focus-visible {
  outline: 2px solid #b9cdf6;
  outline-offset: 2px;
}

.age-hint {
  min-height: 16px;
  margin: 9px 0 0;
  color: #a1a3a9;
  font-size: 10.5px;
  line-height: 1.55;
}

.enter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 8px 13px;
  color: #fff;
  background: #26272b;
  border-radius: 8px;
  font-size: 12px;
  transition: background 0.15s, opacity 0.15s;
}

.enter-btn:hover {
  background: #3b3c42;
}

.enter-btn:disabled {
  color: #a8aab0;
  background: #ededf0;
}

.cover-note {
  margin: 14px 0 0;
  color: #b0b2b8;
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */

.messages-wrap {
  padding-bottom: 6px;
}

.date-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 24px;
  color: #b2b4ba;
  font-size: 10px;
}

.date-rule::before,
.date-rule::after {
  flex: 1;
  height: 1px;
  background: #f0f0f2;
  content: "";
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 0;
  animation: row-in 0.22s ease both;
}

.msg-row.is-restored {
  animation: none;
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.msg-avatar {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  overflow: hidden;
  margin-top: 1px;
  background: #f1f1f3;
  border: 1px solid #ececef;
  border-radius: 7px;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-body {
  min-width: 0;
  max-width: 100%;
}

.msg-name {
  margin: 0 0 3px;
  color: #9a9ca2;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.bubble {
  color: #2b2c31;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant .bubble {
  background: transparent;
  border: 0;
  padding: 0;
}

.msg-time {
  margin: 5px 0 0;
  color: #c0c2c7;
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}

.msg-row.user {
  justify-content: flex-end;
  margin: 17px 0;
}

.msg-row.user .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 82%;
}

.msg-row.user .bubble {
  padding: 9px 13px;
  background: #f1f1f4;
  border-radius: 14px 14px 3px 14px;
  font-size: 13.5px;
  line-height: 1.65;
}

.msg-row.user .msg-time {
  padding-right: 3px;
}

.thought-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 17px 0 17px 36px;
  padding: 7px 0 7px 11px;
  color: #999ba2;
  border-left: 2px solid #ececef;
  font-size: 11.5px;
  line-height: 1.65;
}

.thought-mark {
  flex: 0 0 14px;
  color: #b7b9bf;
}

.thought-mark svg {
  display: block;
}

.thought-body span {
  margin-right: 5px;
  color: #b3b5bb;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.event-row {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.event-card {
  padding: 5px 10px;
  color: #8f9198;
  background: #fafafa;
  border: 1px solid #efeff1;
  border-radius: 6px;
  font-size: 10px;
  text-align: center;
}

.event-title {
  margin: 0 0 1px;
  color: #85878e;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.event-text {
  margin: 0;
}

.system-row {
  display: flex;
  justify-content: center;
  margin: 18px 0;
  color: #a4a6ac;
  font-size: 11px;
  text-align: center;
  white-space: pre-wrap;
}

/* Typing */

.typing-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 20px 0;
}

.typing-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 22px;
}

.typing-bubble i {
  width: 4px;
  height: 4px;
  background: #b7b9bf;
  border-radius: 50%;
  animation: typing 1s ease-in-out infinite;
}

.typing-bubble i:nth-child(2) { animation-delay: 0.14s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.28s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */

.composer {
  flex: 0 0 auto;
  padding: 0 24px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), #fff 22%);
}

.composer-inner {
  width: 100%;
  max-width: 788px;
  margin: 0 auto;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  padding: 7px 2px 8px;
}

.suggest-label {
  align-self: center;
  margin-right: 2px;
  color: #b1b3b9;
  font-size: 10px;
}

.chip {
  padding: 4px 9px;
  color: #707279;
  background: #fff;
  border: 1px solid #e7e7ea;
  border-radius: 7px;
  font-size: 10.5px;
  white-space: nowrap;
}

.chip:hover {
  color: #37383d;
  border-color: #cfd0d5;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 7px 8px 7px 11px;
  background: #fff;
  border: 1px solid #e3e3e7;
  border-radius: 17px;
  box-shadow: 0 1px 3px rgba(20, 20, 28, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-box:focus-within {
  border-color: #cdd7ea;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.06), 0 2px 5px rgba(20, 20, 28, 0.04);
}

.composer-plus {
  display: grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  margin-bottom: 2px;
  color: #a3a5ab;
  background: #f7f7f8;
  border-radius: 50%;
  place-items: center;
}

.composer-box textarea {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 5px 3px;
  overflow-y: auto;
  color: #2a2b30;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  font-size: 13.5px;
  line-height: 1.55;
}

.composer-box textarea::placeholder {
  color: #b4b6bc;
}

.send-btn {
  display: grid;
  flex: 0 0 33px;
  width: 33px;
  height: 33px;
  margin-bottom: 1px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  place-items: center;
  transition: background 0.15s, opacity 0.15s;
}

.send-btn:hover {
  background: #235fd4;
}

.send-btn:disabled {
  color: #fff;
  background: #d3d5da;
}

.composer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 3px 0;
  color: #b3b5bb;
  font-size: 9.5px;
}

kbd {
  padding: 0 3px;
  color: #96989f;
  background: #f5f5f7;
  border: 1px solid #ececef;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 9px;
}

.local-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.pulse {
  width: 5px;
  height: 5px;
  background: #4aa974;
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 28, 34, 0.32);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: min(100%, 560px);
  max-height: min(86dvh, 760px);
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(5px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  display: grid;
  width: 28px;
  height: 28px;
  color: #8f9198;
  background: #f7f7f8;
  border-radius: 7px;
  place-items: center;
}

.modal-close:focus-visible,
.side-close:focus-visible {
  outline: 2px solid #c9cdd5;
  outline-offset: 2px;
}

.modal-close:hover {
  color: #2c2d32;
  background: #efeff1;
}

.modal-scroll {
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  padding: 28px 30px 30px;
}

.profile-card {
  width: min(100%, 740px);
}

.profile-loading {
  padding: 80px 20px;
  color: #9c9ea5;
  text-align: center;
  font-size: 12px;
}

.kicker {
  margin: 0 0 7px;
  color: #a4a6ac;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.modal-card h2 {
  margin: 0 0 8px;
  color: #25262a;
  font-family: var(--sans);
  font-size: 21px;
  font-weight: 500;
}

/* Profile */

.profile-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 8px;
}

.profile-portrait {
  flex: 0 0 94px;
  width: 94px;
  height: 112px;
  overflow: hidden;
  border: 1px solid #ececef;
  border-radius: 10px;
}

.profile-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-hero h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 22px;
}

.profile-hero h2 span {
  color: #85878e;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
}

.profile-kana {
  margin: 3px 0 0;
  color: #a2a4aa;
  font-size: 10px;
}

.profile-quote {
  margin: 7px 0 0;
  color: #7e8087;
  font-family: var(--sans);
  font-size: 12px;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 18px 0 0;
  padding: 12px 0;
  border-top: 1px solid #efeff1;
  border-bottom: 1px solid #efeff1;
}

.profile-facts div {
  padding: 0 12px;
  border-left: 1px solid #f0f0f2;
}

.profile-facts div:first-child {
  padding-left: 0;
  border-left: 0;
}

.profile-facts span {
  display: block;
  margin-bottom: 2px;
  color: #a4a6ac;
  font-size: 9px;
}

.profile-facts strong {
  color: #3b3c41;
  font-size: 12px;
  font-weight: 500;
}

.profile-section {
  margin-top: 22px;
}

.profile-section h3 {
  margin: 0 0 8px;
  color: #3c3d42;
  font-size: 12px;
  font-weight: 600;
}

.profile-section p {
  margin: 0 0 6px;
  color: #6c6e75;
  font-size: 12px;
  line-height: 1.75;
}

.profile-age-note {
  margin: -3px 0 8px !important;
  color: #a4a6ac !important;
  font-size: 10.5px !important;
}

.trait-list,
.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trait-list li {
  width: 100%;
  color: #6c6e75;
  font-size: 12px;
  line-height: 1.65;
}

.trait-list li::before {
  margin-right: 6px;
  color: #c2c4c9;
  content: "—";
}

.profile-list li {
  padding: 3px 8px;
  color: #707279;
  background: #f7f7f8;
  border-radius: 5px;
  font-size: 10.5px;
}

.appearance-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

.appearance-line {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f2f2f4;
}

.appearance-line span {
  color: #a4a6ac;
  font-size: 10px;
}

.appearance-line p {
  margin: 0;
  color: #6c6e75;
  font-size: 10.5px;
  line-height: 1.55;
}

.profile-note {
  margin: 24px 0 0;
  padding: 10px 12px;
  color: #8b8d94 !important;
  background: #fafafa;
  border-left: 2px solid #ededf0;
  font-size: 11px !important;
}

.profile-foot {
  margin: 20px 0 0;
  padding-top: 12px;
  color: #b0b2b8 !important;
  border-top: 1px solid #f0f0f2;
  font-size: 9.5px !important;
  text-align: center;
}

/* Reset */

.reset-card {
  width: min(100%, 430px);
  padding: 26px 28px 24px;
}

.reset-copy {
  margin: 0;
  color: #7a7c83;
  font-size: 12px;
  line-height: 1.8;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.ghost-btn,
.primary-btn,
.danger-btn {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 11.5px;
}

.ghost-btn {
  color: #686a71;
  background: #f7f7f8;
  border: 1px solid #ededf0;
}

.ghost-btn:hover {
  color: #333439;
  border-color: #dcdce1;
}

.primary-btn {
  color: #fff;
  background: #26272b;
}

.primary-btn:hover {
  background: #3a3b41;
}

.primary-btn:disabled {
  background: #b9bbc1;
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

.danger-btn:hover {
  background: #a23c3c;
}

/* Export */

.export-card {
  width: min(100%, 480px);
  padding: 26px 28px 22px;
}

.export-copy {
  margin: 0 0 18px;
  color: #7a7c83;
  font-size: 11.5px;
  line-height: 1.75;
}

.export-copy code {
  padding: 1px 4px;
  color: #55575e;
  background: #f5f5f7;
  border-radius: 3px;
  font-size: 10px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  margin-bottom: 4px;
  color: #777980;
  font-size: 10.5px;
}

.field input {
  width: 100%;
  padding: 8px 10px;
  color: #2c2d32;
  background: #fbfbfc;
  border: 1px solid #e5e5e9;
  border-radius: 7px;
  outline: none;
  font-size: 12px;
}

.field input:focus {
  background: #fff;
  border-color: #a9bde0;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.06);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 0 0;
  color: #6f7178;
  font-size: 11px;
  cursor: pointer;
}

.check-field input {
  width: 13px;
  height: 13px;
  accent-color: #2c2d32;
}

.export-status {
  min-height: 17px;
  margin: 8px 0 0;
  color: #b05b5b;
  font-size: 10.5px;
}

.export-status.is-error {
  color: #b42318;
}

.export-actions {
  justify-content: space-between;
  margin-top: 8px;
}

.export-note {
  margin: 12px 0 0;
  color: #b0b2b8;
  font-size: 9.5px;
  line-height: 1.5;
}

/* API settings */

.api-btn.is-on {
  color: #2f6fed;
  background: #edf3ff;
}

.api-status {
  min-height: 17px;
  margin: 8px 0 10px;
  color: #777980;
  font-size: 10.5px;
  line-height: 1.5;
}

.api-status.is-ok {
  color: #237a4b;
}

.api-status.is-error {
  color: #b42318;
}

.api-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

/* Toast */

.toast {
  position: fixed;
  z-index: 200;
  bottom: 24px;
  left: 50%;
  max-width: min(88vw, 460px);
  padding: 8px 12px;
  color: #f5f5f7;
  background: #2b2c31;
  border-radius: 7px;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s, transform 0.18s;
  font-size: 11.5px;
  line-height: 1.5;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 86vw;
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 32px rgba(20, 20, 28, 0.12);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .sidebar.is-open {
    transform: none;
  }

  .sidebar-scrim {
    position: fixed;
    z-index: 55;
    inset: 0;
    display: block;
    background: rgba(20, 20, 28, 0.28);
  }

  .side-close,
  .menu-btn {
    display: grid !important;
  }

  .side-close {
    width: 28px;
    height: 28px;
    color: #91939a;
    border-radius: 6px;
    place-items: center;
  }

  .menu-btn {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    color: #73757c;
    border-radius: 7px;
    place-items: center;
  }

  .menu-btn:hover {
    background: #f4f4f6;
  }

  .main-head {
    padding: 0 14px;
  }

  .engine-badge {
    display: none;
  }

  .chat-inner {
    padding: 22px 20px 6px;
  }

  .cover {
    margin-top: 0;
  }

  .composer {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-width: 620px) {
  .main-head {
    flex-basis: 58px;
    min-height: 58px;
    padding: 0 10px;
  }

  .crumb {
    display: none;
  }

  .head-title h1 {
    font-size: 13px;
  }

  .head-actions {
    gap: 2px;
  }

  .age-badge {
    padding: 3px 6px;
    font-size: 9.5px;
  }

  .text-btn {
    padding: 5px 6px;
    font-size: 10.5px;
  }

  .head-actions .text-btn:last-child {
    display: none;
  }

  .chat-inner {
    padding: 18px 14px 4px;
  }

  .cover {
    padding: 17px;
    border-radius: 13px;
  }

  .welcome-head {
    gap: 12px;
  }

  .welcome-portrait {
    flex-basis: 54px;
    width: 54px;
    height: 68px;
  }

  .welcome-head h2 {
    font-size: 19px;
  }

  .cover-sub {
    font-size: 11.5px;
  }

  .age-block {
    margin-top: 17px;
    padding-top: 15px;
  }

  .age-title span {
    display: block;
    margin: 2px 0 0;
  }

  .age-chip {
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .enter-btn {
    width: 100%;
    justify-content: center;
  }

  .msg-row {
    gap: 8px;
    margin: 9px 0;
  }

  .msg-row.user .msg-body {
    max-width: 88%;
  }

  .bubble {
    font-size: 13.5px;
  }

  .thought-row {
    margin-left: 34px;
  }

  .composer {
    padding: 0 10px calc(9px + env(safe-area-inset-bottom));
  }

  .composer-hint {
    padding-top: 5px;
    font-size: 9px;
  }

  .composer-hint kbd {
    display: none;
  }

  .suggestions {
    gap: 5px;
    padding: 5px 1px 7px;
  }

  .chip {
    padding: 4px 8px;
    font-size: 10px;
  }

  .modal {
    padding: 12px;
    place-items: end center;
  }

  .modal-card {
    max-height: 92dvh;
    border-radius: 15px;
  }

  .modal-scroll {
    max-height: 92dvh;
    padding: 24px 18px;
  }

  .profile-facts {
    grid-template-columns: 1fr 1fr;
    gap: 10px 0;
  }

  .profile-facts div:nth-child(3) {
    padding-left: 0;
    border-left: 0;
  }

  .appearance-list {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    align-items: flex-start;
  }

  .profile-portrait {
    flex-basis: 72px;
    width: 72px;
    height: 88px;
  }

  .profile-hero h2 {
    font-size: 19px;
  }

  .export-card,
  .reset-card {
    padding: 22px 18px 18px;
  }

  .export-actions {
    flex-direction: column-reverse;
  }

  .export-actions button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .avatar-stage {
    padding: 9px 12px 7px;
  }

  .avatar-frame {
    width: 126px;
    border-radius: 12px;
  }

  .avatar-caption {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin-top: 5px;
  }

  .avatar-name {
    font-size: 12px;
  }

  .avatar-mood {
    font-size: 9.5px;
  }

  .avatar-quote {
    display: none;
  }

  .view-toggle {
    padding: 5px 6px;
  }

  .view-toggle span {
    display: none;
  }
}

@media (max-height: 760px) and (min-width: 621px) {
  .avatar-frame {
    width: 154px;
  }

  .avatar-stage {
    padding-top: 8px;
  }

  .avatar-quote {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   Left character panel + session drawer
   -------------------------------------------------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.sidebar {
  position: fixed;
  z-index: 60;
  top: 0;
  bottom: 0;
  left: 0;
  width: 300px;
  max-width: 86vw;
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 44px rgba(20, 20, 28, 0.14);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
}

.sidebar.is-open {
  transform: none;
}

.sidebar-scrim {
  position: fixed;
  z-index: 55;
  inset: 0;
  display: block;
  background: rgba(20, 20, 28, 0.26);
}

.side-close,
.menu-btn {
  display: grid !important;
}

.side-close {
  width: 28px;
  height: 28px;
  color: #91939a;
  border-radius: 6px;
  place-items: center;
}

.menu-btn {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  color: #73757c;
  border-radius: 7px;
  place-items: center;
}

.menu-btn:hover {
  background: #f4f4f6;
}

.side-note {
  margin: 0;
  padding: 4px 8px 2px;
  color: #b0b2b8;
  font-size: 9.5px;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workspace {
  display: grid;
  flex: 1;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}

.app[data-view="list"] .workspace {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.character-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 20px 20px 12px;
  overflow-x: hidden;
  overflow-y: auto;
  background: linear-gradient(180deg, #fbfbfc 0%, #f7f7f8 100%);
  border-right: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-identity {
  min-width: 0;
}

.panel-kicker {
  margin: 0 0 4px;
  color: #a2a4aa;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.panel-name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #24252a;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.panel-identity > p:last-child {
  margin: 2px 0 0;
  color: #95979e;
  font-size: 10.5px;
}

.avatar-stage {
  display: block;
  flex: 0 0 auto;
  padding: 0;
  background: none;
  border: 0;
}

.avatar-frame {
  width: 100%;
  max-width: 238px;
  margin: 0 auto;
  border-radius: 18px;
}

.avatar-caption {
  margin-top: 9px;
  text-align: left;
}

.avatar-face-line {
  margin: 0;
  line-height: 1.2;
}

.avatar-face {
  color: #8f9198;
  font-size: 12px;
}

.avatar-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 3px;
}

.avatar-caption .stage-quote {
  margin-top: 6px;
  color: #777980;
  font-size: 11px;
  line-height: 1.6;
}

.character-panel .character-card {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

.character-panel .inner-card {
  margin-top: 0;
}

.character-panel .side-age {
  margin-top: 9px;
}

.panel-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 268px minmax(0, 1fr);
  }

  .character-panel {
    padding: 16px 16px 10px;
  }

  .avatar-frame {
    max-width: 208px;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .character-panel {
    display: grid;
    grid-template-areas:
      "head head"
      "avatar card"
      "footer footer";
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 8px 14px;
    max-height: 42dvh;
    padding: 11px 14px 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-head {
    grid-area: head;
    align-items: center;
  }

  .panel-kicker {
    display: none;
  }

  .panel-name {
    font-size: 15px;
  }

  .avatar-stage {
    grid-area: avatar;
  }

  .avatar-frame {
    width: 128px;
    max-width: none;
    border-radius: 13px;
  }

  .avatar-caption {
    margin-top: 5px;
  }

  .avatar-face-line,
  .avatar-caption .stage-quote {
    display: none;
  }

  .avatar-meta-row {
    justify-content: flex-start;
    gap: 6px;
    margin-top: 0;
  }

  .avatar-meta-row .stage-time {
    font-size: 9px;
  }

  .character-card {
    grid-area: card;
    min-width: 0;
  }

  .panel-footer {
    grid-area: footer;
    margin-top: 0;
    padding-top: 7px;
  }

  .panel-footer .side-link {
    font-size: 10px;
  }

  .main-head {
    padding: 0 14px;
  }

  .chat-inner {
    padding: 22px 20px 6px;
  }

  .composer {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-width: 620px) {
  .character-panel {
    grid-template-columns: 112px minmax(0, 1fr);
    max-height: 44dvh;
    padding: 9px 10px 7px;
  }

  .avatar-frame {
    width: 112px;
  }

  .character-panel .inner-card {
    padding: 6px 7px;
  }

  .character-panel .inner-card p {
    -webkit-line-clamp: 2;
    font-size: 10px;
  }

  .character-panel .affinity {
    margin-top: 5px;
  }

  .character-panel .side-age {
    margin-top: 5px;
  }

  .panel-footer .side-link {
    font-size: 9.5px;
  }

  .main-head {
    flex-basis: 58px;
    min-height: 58px;
    padding: 0 10px;
  }

  .chat-inner {
    padding: 18px 14px 4px;
  }

  .composer {
    padding: 0 10px calc(9px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 760px) and (min-width: 621px) {
  .avatar-frame {
    max-width: 168px;
  }

  .avatar-caption .stage-quote {
    display: none;
  }

  .character-panel {
    gap: 10px;
    padding-top: 12px;
  }
}

/* API: forced online mode, key source picker, unlock. */
.api-card {
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  padding: 28px 30px 30px;
}

.api-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 12px;
}

.api-mode {
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
}

.api-mode strong { font-weight: 600; }
.api-mode span { color: var(--muted); font-size: 11px; }
.api-mode:hover { border-color: #d3d3d7; background: #f5f5f7; }
.api-mode.is-selected {
  border-color: var(--accent);
  background: #f2f6ff;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.api-pane {
  display: grid;
  gap: 10px;
  margin: 10px 0 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfc;
}

.api-unlock-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-unlock-note { color: var(--muted); font-size: 11px; }

@media (max-width: 620px) {
  .api-modes { grid-template-columns: 1fr; }
  .api-card { max-height: 88dvh; padding: 24px 20px 22px; }
}

