@import url("/futureaya-palette.css");
:root {
  color-scheme: light;
  --muted: #715d54;
  --line: #dfd1c6;
  --body: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --display: "Songti SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  font-family: var(--body);
  color: var(--ink);
  background: var(--oat);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, textarea, input { font: inherit; color: inherit; }
button, a, textarea, input { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, [tabindex="0"]:focus-visible {
  outline: 2px solid #965d62;
  outline-offset: 3px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1080px, calc(100% - 72px));
  margin: auto;
  height: 89px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-family: Georgia, serif; font-size: 31px; letter-spacing: -.065em; font-weight: bold; }
.wordmark span { color: #9c686b; }
.mode { color: var(--muted); font-size: 12px; letter-spacing: .08em; }

.home { width: min(1020px, calc(100% - 72px)); margin: clamp(32px, 6.2vh, 88px) auto 0; }
.character {
  min-height: 500px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
  border-radius: 26px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px #42230d0c;
}
.character-copy {
  padding: 52px clamp(28px, 6vw, 86px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
}
.identity {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .12em;
}
.identity span { color: #9a7370; margin: 0 .65em; }
.character h1 {
  font-family: var(--display);
  font-size: clamp(65px, 8vw, 108px);
  font-weight: 600;
  letter-spacing: -.075em;
  line-height: 1.08;
  margin: 0;
  overflow-wrap: anywhere;
}
.character-nickname {
  font-size: 14px;
  color: var(--muted);
  margin: 10px 0 0;
  overflow-wrap: anywhere;
}
.character blockquote {
  border-left: 2px solid #cfa8a5;
  margin: 30px 0 34px;
  padding-left: 17px;
  color: var(--cocoa);
  font-size: clamp(15px, 1.9vw, 20px);
  line-height: 1.75;
}
.portrait { position: relative; min-height: 100%; background: #292e38; }
.portrait img { position: absolute; width: 100%; height: 100%; object-fit: cover; object-position: 50% 34%; }
.primary, .secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid transparent;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 11px;
  font-size: 14px;
  white-space: nowrap;
}
.primary { background: var(--cocoa); color: white; }
.primary:not(:disabled):hover { background: #6e4740; }
.primary:disabled { opacity: .55; cursor: wait; }
.secondary { background: var(--paper); border-color: var(--line); }
.secondary:hover { background: #f1e8df; }
.enter { gap: 27px; padding: 12px 18px; }
.enter span { color: #ead6cf; font-size: 16px; }
.page-note {
  padding: 23px 0 29px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  letter-spacing: .07em;
}

.room {
  width: min(820px, calc(100% - 72px));
  height: calc(100dvh - 132px);
  min-height: 460px;
  margin: 20px auto 23px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 12px 36px #42230d0a;
}
.room-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
}
.back { display: grid; place-items: center; border-radius: 9px; width: 36px; height: 44px; font-size: 34px; line-height: 1; }
.back:hover { background: var(--oat); }
.headshot, .message-avatar { object-fit: cover; object-position: 50% 27%; border-radius: 9px; background: #38333a; }
.headshot { width: 46px; height: 46px; }
.room-identity h1 { font-size: 18px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-identity p { margin: 3px 0 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory { padding: 15px 24px; border-bottom: 1px solid var(--line); }
.memory-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.memory-heading h2 { font-size: 14px; margin: 0; }
.memory-heading h2 span { color: #9c6267; margin-right: 5px; }
.memory-heading > span { font-size: 12px; color: var(--muted); }
.memory-list { display: flex; gap: 8px; overflow-x: auto; padding: 3px; margin: -3px; }
.memory-card {
  min-height: 42px;
  padding: 8px 11px;
  background: #f4e9e4;
  border: 1px solid #e6d4ce;
  border-radius: 9px;
  text-align: left;
  font-size: 13px;
  flex: 0 0 auto;
  max-width: 260px;
  overflow-wrap: anywhere;
}
.memory-card:hover { border-color: #ae807d; }
.memory-empty { margin: 0; font-size: 13px; color: var(--muted); }
.conversation { overflow-y: auto; min-height: 0; background: #f4ede4; }
.messages { list-style: none; margin: 0; padding: 24px; display: grid; gap: 18px; }
.message { display: flex; align-items: flex-start; gap: 9px; }
.message.mine { justify-content: flex-end; }
.message-avatar { width: 34px; height: 34px; }
.bubble {
  max-width: min(82%, 420px);
  margin: 0;
  border-radius: 4px 13px 13px 13px;
  background: var(--paper);
  border: 1px solid #e5d8cc;
  padding: 8px 13px;
  font-size: 15px;
  line-height: 1.58;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.mine .bubble { background: var(--rose); border-color: #e1cbc4; border-radius: 13px 4px 13px 13px; }
.compose { padding: 13px 24px; border-top: 1px solid var(--line); }
.compose-row { display: flex; align-items: flex-end; gap: 10px; }
textarea, input { width: 100%; background: #fffdf9; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.compose textarea { min-height: 44px; height: 44px; max-height: 116px; resize: vertical; line-height: 22px; }
.chat-status, .form-error { color: #835050; font-size: 13px; margin: 0 0 8px; }
dialog {
  width: min(410px, calc(100% - 30px));
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 19px;
}
dialog::backdrop { background: #30231f66; }
dialog h2 { margin: 0 0 20px; font-size: 20px; }
dialog form { display: grid; gap: 14px; }
dialog label { display: grid; gap: 6px; font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.delete { margin-right: auto; color: #835050; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 650px) {
  .masthead { height: 65px; width: calc(100% - 36px); }
  .wordmark { font-size: 27px; }
  .home { width: calc(100% - 36px); margin-top: 21px; }
  .character { grid-template-columns: 1fr; min-height: 0; border-radius: 19px; }
  .portrait { grid-row: 1; min-height: clamp(220px, 62vw, 370px); }
  .portrait img { object-position: 50% 28%; }
  .character-copy { padding: 24px; }
  .identity { margin-bottom: 10px; }
  .character h1 { font-size: clamp(49px, 13vw, 68px); }
  .character blockquote { margin: 19px 0; }
  .room { width: 100%; margin: 0; height: calc(100dvh - 65px); border: 0; border-radius: 0; min-height: 368px; }
  .room-header { padding: 10px 12px; gap: 8px; }
  .memory { padding: 13px 16px; }
  .messages { padding: 18px 16px; }
  .compose { padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
}

.privacy-note { margin: 0 0 7px; color: var(--muted); font-size: 11px; }
