/* 陈湘 · 302 — 暮色纸与玫瑰
   paper  #FAF3F4   card #FFFCFB   ink #3D2E39   muted #9B8794
   rose   #D4809B   lilac #A695C7  line #EFDFE6
*/

:root {
  --paper: #faf3f4;
  --card: #fffcfb;
  --ink: #3d2e39;
  --ink-soft: #6b5a66;
  --muted: #9b8794;
  --rose: #d4809b;
  --rose-deep: #b9637f;
  --rose-wash: #f9e8ee;
  --lilac: #a695c7;
  --line: #efdfe6;
  --line-soft: #f5ebef;
  --serif: Georgia, "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
  border-radius: 6px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-x: hidden;
}

.only-mobile { display: none; }
.actions-mobile { display: none; }
.action-row { display: flex; gap: 8px; }
.action-row button { flex: 1; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 46, 57, .34);
  z-index: 39;
}
body.status-open .scrim { display: block; }

/* ---------- 名牌 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 30px 14px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 19px;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #e6a5b8, var(--rose-deep));
}

.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.brand-text span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.top-actions { display: flex; gap: 4px; flex: 0 0 auto; }

/* ---------- 按钮 ---------- */

button {
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}

button:hover { background: var(--rose-wash); color: var(--rose-deep); }

button.primary {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
  font-weight: 600;
  padding: 10px 22px;
}

button.primary:hover { background: var(--rose-deep); border-color: var(--rose-deep); color: #fff; }

button.ghost { border-color: var(--line); }

button.on {
  color: var(--rose-deep);
  background: var(--rose-wash);
  border-color: #ecc7d5;
}

/* ---------- 布局 ---------- */

.layout {
  flex: 1;
  display: flex;
  gap: 26px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 30px 18px;
  min-height: 0;
  overflow: hidden;
}

.chat-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- 对话：她的信纸 ---------- */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px max(8px, calc(50% - 280px)) 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #e7d2da transparent;
}

.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: #e7d2da; border-radius: 999px; }

.bubble {
  align-self: flex-start;
  max-width: min(540px, 92%);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.74;
  letter-spacing: .012em;
  padding: 11px 16px 11px 15px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-left: 3px solid #ecc8d6;
  border-radius: 4px 15px 15px 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise .22s ease-out;
}

.bubble.me {
  align-self: flex-end;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.65;
  max-width: min(500px, 84%);
  background: #f7e5ec;
  border: 1px solid #efd3de;
  border-left: 1px solid #efd3de;
  border-radius: 15px 4px 15px 15px;
  color: #4a3541;
  animation: none;
}

.bubble.narration {
  align-self: flex-start;
  background: transparent;
  border: none;
  border-left: none;
  padding: 0 4px 0 2px;
  font-style: italic;
  font-size: 14px;
  line-height: 1.7;
  color: #8d7a87;
  animation: none;
}

.bubble .meta {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: #a6939f;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .18s ease;
}

.bubble:hover .meta { opacity: 1; }

.bubble img {
  display: block;
  width: 100%;
  max-width: 260px;
  border-radius: 10px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rose);
  animation: breathe 1.4s ease-in-out infinite;
}

.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }

@keyframes breathe {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}

/* ---------- 输入 ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 0 4px;
  width: min(560px, 100%);
  margin: 0 auto;
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 150px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  transition: border-color .16s ease;
}

.composer textarea::placeholder { color: #bdaeba; }

.composer textarea:focus {
  outline: none;
  border-color: #e3b4c6;
}

/* ---------- 相册：拍立得条 ---------- */

.gallery-wrap {
  width: min(560px, 100%);
  margin: 0 auto;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.gallery-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--muted);
}

.gallery-head > span:first-child {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.gallery {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: thin;
  scrollbar-color: #e7d2da transparent;
}

.gallery::-webkit-scrollbar { height: 6px; }
.gallery::-webkit-scrollbar-thumb { background: #e7d2da; border-radius: 999px; }

.gallery:empty::after {
  content: "还没有照片。点上面的「拍一张」，她会拍给你。";
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: #a6939f;
  padding: 18px 2px;
}

.gallery figure {
  margin: 0;
  flex: 0 0 96px;
  cursor: zoom-in;
  transition: transform .18s ease;
}

.gallery figure:hover { transform: translateY(-2px); }

.gallery figure:hover img { border-color: #fff; box-shadow: 0 4px 10px rgba(61, 46, 57, .14); }

.gallery img {
  width: 96px;
  height: 128px;
  object-fit: cover;
  background: #f3e6ea;
  border: 5px solid #fff;
  border-bottom-width: 18px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(61, 46, 57, .08);
}

.gallery figcaption {
  font-size: 10.5px;
  color: #a6939f;
  text-align: center;
  margin-top: -12px;
}

/* ---------- 右侧：她此刻 ---------- */

.sidebar {
  flex: 0 0 280px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--line-soft);
  overflow-y: auto;
  padding: 22px 2px 10px 24px;
  scrollbar-width: thin;
  scrollbar-color: #e7d2da transparent;
}

.card {
  padding: 14px 4px 16px;
  border-top: 1px solid var(--line);
}

.card:first-child {
  border-top: none;
  padding-top: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--muted);
}

.card-head > span:first-child {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.pill {
  font-size: 11px;
  color: var(--rose-deep);
  background: var(--rose-wash);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  font-size: 13px;
  min-width: 0;
}

.kv label {
  flex: 0 0 auto;
  font-size: 12px;
  color: #9d8b96;
  letter-spacing: 0.02em;
}

.kv b {
  font-weight: 500;
  font-family: var(--serif);
  font-size: 13.5px;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kv b.wrap {
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.5;
  hyphens: auto;
  color: var(--ink-soft);
  word-break: break-all;
}

.note {
  margin: 9px 0 0;
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.65;
  color: #9d8b96;
}

.next {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: #b7a5b0;
  letter-spacing: 0.01em;
}

.next:empty { display: none; }

.warn {
  margin: 9px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: #b07a55;
}

/* 关系数值 */

.meters { display: flex; flex-direction: column; gap: 9px; }

.meter {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
}

.meter > span:first-child {
  flex: 0 0 34px;
  font-size: 12px;
  color: #9d8b96;
}

.meter .bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: #f2e4ea;
  overflow: hidden;
}

.meter .bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #e7b3c6, var(--rose) 55%, var(--lilac));
}

.meter > b {
  flex: 0 0 26px;
  text-align: right;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* 待兑现 */

.commitments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

.commitments li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  line-height: 1.5;
}

.commitments li span:last-child { color: #b7a5b0; font-size: 11px; font-family: var(--sans); }
.commitments .muted { color: #b7a5b0; font-style: italic; }

/* ---------- 弹窗 ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 18px 50px rgba(61, 46, 57, .16);
}

dialog::backdrop { background: rgba(61, 46, 57, .28); }

.settings { padding: 24px 26px 20px; width: min(720px, 92vw); }

.settings h2 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.settings .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 15px 18px;
}

.settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.settings input,
.settings select {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fdf8f9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
}

.settings input:focus,
.settings select:focus {
  outline: none;
  border-color: #e3b4c6;
}

.settings input[type=range] {
  padding: 0;
  background: transparent;
  border: none;
  accent-color: var(--rose);
}

.settings label.check {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--ink-soft);
}

.settings label.check input { accent-color: var(--rose); }

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

/* ---------- 看图 ---------- */

#viewer {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  max-width: 94vw;
}

#viewer img {
  display: block;
  max-height: 78vh;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(61, 46, 57, .3);
}

.viewer-bar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.viewer-bar span {
  flex: 1;
  max-height: 64px;
  overflow-y: auto;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.6;
  color: #cbbac4;
}

.viewer-bar button { color: #e7d2da; border-color: #6b5a66; }
.viewer-bar button:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- 窄屏 ---------- */

@media (max-width: 900px) {
  /* 顶栏固定在顶部，别和内容抢位置 */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    flex-wrap: nowrap;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 17px; white-space: nowrap; }
  .brand-text span { display: none; }
  .avatar { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; }
  .top-actions { margin-left: auto; gap: 2px; flex: 0 0 auto; }
  .top-actions button { padding: 7px 9px; font-size: 12.5px; }
  .top-actions #btn-intimate,
  .top-actions #btn-photo { display: none; }
  .actions-mobile { display: block; }
  .layout, .chat-wrap, .chat, .composer, .gallery-wrap { max-width: 100%; }
  .only-mobile { display: inline-block; }

  /* 主体只放对话，占满剩余高度 */
  .layout {
    flex: 1;
    min-height: 0;
    flex-direction: row;
    padding: 0 12px calc(8px + env(safe-area-inset-bottom));
    gap: 0;
    overflow: hidden;
  }
  .chat-wrap { flex: 1; min-width: 0; min-height: 0; }
  .chat {
    padding: 10px 0 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .bubble { font-size: 15px; max-width: 100%; }
  .bubble.me { max-width: 88%; }

  /* 侧栏变成右侧抽屉，不再压住对话 */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(330px, 86vw);
    z-index: 40;
    padding: calc(16px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
    background: var(--paper);
    border-left: 1px solid var(--line);
    border-bottom: none;
    overflow-y: auto;
    transform: translateX(102%);
    transition: transform .22s ease;
    box-shadow: -8px 0 30px rgba(61, 46, 57, .08);
  }
  body.status-open .sidebar { transform: none; }
  .sidebar .card:nth-last-child(-n+2) { display: block; }
  .card { padding: 12px 0 14px; }

  /* 输入区：16px 防止 iOS 自动放大 */
  .composer { width: 100%; gap: 8px; padding: 8px 0 2px; }
  .composer textarea { font-size: 16px; padding: 11px 14px; min-width: 0; width: 100%; }
  .composer button { padding: 10px 16px; }

  /* 相册收成一条矮带 */
  .gallery-wrap { width: 100%; padding-top: 6px; }
  .gallery { max-height: 104px; padding-bottom: 4px; }
  .gallery figure { flex: 0 0 74px; }
  .gallery img { width: 74px; height: 96px; border-bottom-width: 14px; }
  .gallery figcaption { margin-top: -9px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .bubble.me { animation: none; }
  .typing i { animation: none; opacity: .6; }
  * { transition: none !important; }
}









