:root {
  color-scheme: light;
  --paper: #fffaf4;
  --surface: #fffcf8;
  --ink: #422a30;
  --subtle: #795962;
  --accent: #a93f61;
  --accent-hover: #8f3150;
  --blush: #f9e3e8;
  --peach: #faeee5;
  --line: #eed4dc;
  --green: #3d654b;
  --shadow: 0 18px 58px #94636a16;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 0 2%, #f9dce4 0, transparent 54%),
    radial-gradient(ellipse at 95% 90%, #fae2d4 0, transparent 53%),
    var(--paper);
  font: 16px/1.6 "DM Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; }
[hidden] { display: none !important; }
main { max-width: 70rem; margin-inline: auto; padding: 1.75rem clamp(1rem, 4vw, 2.5rem) 3rem; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: clamp(1.5rem, 4vw, 2.15rem); line-height: 1.35; letter-spacing: .015em; }
h3 { font-size: 1.2rem; line-height: 1.5; }
.masthead, .masthead-brand { display: flex; align-items: center; }
.masthead { justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.masthead-brand { gap: .7rem; }
.masthead h1 { font-size: clamp(.98rem, 2.4vw, 1.25rem); font-weight: 700; letter-spacing: .035em; }
.mark {
  display: grid;
  place-items: center;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid #f0b7c6;
  background: var(--blush);
  color: var(--accent);
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.2rem;
}
.masthead-detail { color: var(--subtle); font-size: .8rem; letter-spacing: .12em; white-space: nowrap; }
#gate {
  display: grid;
  grid-template-columns: 1fr .93fr;
  min-height: clamp(27rem, 55vw, 35rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.cover { display: block; width: 100%; height: 100%; object-fit: cover; min-height: 0; object-position: center 57%; }
.gate-panel { display: grid; align-items: center; padding: clamp(1.4rem, 6vw, 4.2rem); }
.gate-content { max-width: 24rem; }
#unlock { margin-top: 1.65rem; }
label { display: block; margin-bottom: .35rem; font-size: .88rem; font-weight: 600; }
input, textarea, button { font: inherit; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .9rem;
  padding: .65rem .85rem;
  background: #fffdfc;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 4rem; }
button {
  min-height: 44px;
  padding: .5rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fffafa;
  font-weight: 600;
  cursor: pointer;
}
button:hover:enabled { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: wait; }
button.quiet { border-color: var(--line); background: var(--surface); color: var(--accent); }
button.quiet:hover:enabled { background: var(--blush); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#unlock-button { width: 100%; margin-top: 1.1rem; }
.hint, #status, .receipt { color: var(--subtle); font-size: .82rem; }
.hint { margin-top: .52rem; }
#notice {
  max-width: 47rem;
  margin: 0 auto .8rem;
  padding: .65rem .9rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--blush);
  font-size: .9rem;
}
#file-preview {
  margin: 0 0 .8rem;
  padding: .65rem .9rem;
  border-radius: .85rem;
  background: var(--peach);
}
#file-preview a { color: var(--accent); }
#room {
  max-width: 47rem;
  margin-inline: auto;
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 1.7rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.bar, .actions, .invite-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.room-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}
.room-heading { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.room-portrait {
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  border: 1px solid var(--line);
  border-radius: .92rem;
  object-fit: cover;
  object-position: center 58%;
}
.room-bar h2 { font-size: clamp(1.3rem, 4vw, 1.75rem); }
.actions { justify-content: flex-end; margin-top: .45rem; }
#status { display: flex; align-items: baseline; gap: .45rem; margin-top: .27rem; }
#status::before { content: ""; width: .44rem; height: .44rem; flex: 0 0 .44rem; align-self: center; border-radius: 50%; background: #b97980; }
#status.connected { color: var(--green); }
#status.connected::before { background: var(--green); }
#invite, #verify {
  margin-top: 1rem;
  padding: clamp(.9rem, 4vw, 1.35rem);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: linear-gradient(135deg, var(--peach), var(--surface) 78%);
}
#invite h3, #verify h3 { margin-bottom: .55rem; }
.invite-actions input { flex: 1 1 13rem; min-width: 0; }
#verify button { margin-top: .8rem; margin-right: .3rem; }
#safety-code {
  width: fit-content;
  margin: .65rem 0 .8rem;
  border: 1px dashed #d9a3b2;
  border-radius: .85rem;
  padding: .6rem .75rem;
  background: #fff9f6;
  color: var(--accent);
  font: .96rem/1.65 "IBM Plex Mono", Menlo, Consolas, monospace;
  letter-spacing: .015em;
  overflow-wrap: anywhere;
}
#chat { position: relative; }
#empty-thread {
  position: absolute;
  inset: 4.3rem 0 auto;
  text-align: center;
  pointer-events: none;
  color: var(--subtle);
  font-size: .9rem;
}
#empty-thread::before { display: block; content: "♡"; color: var(--accent); font-size: 1.3rem; }
#messages {
  min-height: 12rem;
  max-height: 48svh;
  display: grid;
  align-content: safe end;
  gap: .75rem;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 1rem .12rem;
}
#messages li { display: grid; justify-items: start; gap: .2rem; min-width: 0; }
#messages .mine { justify-items: end; }
.bubble {
  max-width: min(88%, 30rem);
  padding: .55rem .85rem;
  border-radius: 1.08rem 1.08rem 1.08rem .3rem;
  background: var(--peach);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mine .bubble { border-radius: 1.08rem 1.08rem .3rem 1.08rem; background: var(--blush); }
#messages img {
  width: min(78%, 16rem);
  max-height: 17rem;
  object-fit: contain;
  background: #fff;
  padding: .35rem .35rem .75rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  box-shadow: 0 3px 9px #94636a16;
}
#compose { padding-top: .65rem; border-top: 1px solid var(--line); }
#camera { padding-top: .65rem; border-top: 1px solid var(--line); }
#camera h3 { margin-bottom: .55rem; }
#camera img, #camera video { display: block; width: 100%; max-height: 56svh; object-fit: contain; background: var(--peach); border-radius: 1rem; }
details { margin-top: 1.25rem; color: var(--subtle); font-size: .82rem; }
details button, #locked-reset { margin-top: .5rem; font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 680px) {
  main { padding-top: .85rem; }
  .masthead { margin-bottom: .85rem; }
  .masthead-detail { display: none; }
  #gate { grid-template-columns: 1fr; min-height: 0; border-radius: 1.45rem; }
  .cover { height: auto; aspect-ratio: 1.38; }
  .gate-panel { padding: 1.3rem 1.15rem 1.45rem; }
  .gate-content { max-width: none; }
  #unlock { margin-top: .9rem; }
  .room-heading { gap: .45rem; }
  .room-portrait { width: 2.4rem; height: 2.4rem; flex-basis: 2.4rem; }
}
