:root {
  color-scheme: light;
  --ink: #1c3328;
  --muted: #5d7568;
  --paper: #eef6ec;
  --card: #ffffff;
  --line: #d5e4d8;
  --pine: #1f4d3a;
  --green: #2f7d4a;
  --mine: #d7f0d0;
  --warn: #b42318;
  --shadow: 0 16px 40px rgba(22, 53, 40, 0.12);
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #07140f 0%, #10261c 100%);
  color: var(--ink);
}

button, input { font: inherit; }

button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  background: var(--green);
  color: white;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green);
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  top: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  margin: 0;
  max-width: min(440px, calc(100% - 1.6rem));
  padding: 0.8rem 1.15rem;
  background: #d7f0d0;
  color: #143528;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(20, 53, 40, 0.18);
  text-align: center;
  font-weight: 650;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 80% 12%, rgba(228, 239, 230, 0.16), transparent 18%),
    linear-gradient(180deg, #050e0b 0%, #0c1e16 42%, #17352a 100%);
}

.card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.4rem 2rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.scene { width: min(280px, 100%); height: auto; display: block; margin: 0 auto 0.4rem; }

.mark {
  margin: 0;
  color: var(--pine);
  font-weight: 700;
}

.card h1 { margin: 0.35rem 0; font-size: 1.45rem; }

.lede, .status, .kicker { color: var(--muted); }

.empty-den p {
  margin: 0.2rem 0 0;
  color: #f4fbf6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.error { color: var(--warn); min-height: 1.2rem; }

.auth-note { margin: 0 0 0.4rem; color: var(--pine); }

.card label { display: flex; flex-direction: column; margin: 0.8rem 0; text-align: left; }

.row { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }

input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: white;
  color: var(--ink);
  min-width: 0;
}

.shell {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  background: white;
}

aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: white;
  color: var(--ink);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: none;
  background: var(--pine);
  color: #f4fbf6;
  padding: 0.75rem 0.85rem;
}

.side-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding: 0.75rem;
}

#side-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#talks { flex: 1; }

.whoami, .talk-title { min-width: 0; }

.whoami {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
}

.whoami strong, #talk-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: #fff6ea;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px rgba(255, 246, 234, 0.45);
}

.logo img { width: 40px; height: 40px; display: block; object-fit: contain; }

#talk-title { margin: 0; font-size: 1.05rem; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--green);
  color: white;
  flex: none;
  font-weight: 700;
}

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

.whoami .avatar { width: 36px; height: 36px; background: #3d8f5a; }

.icon-actions { display: flex; gap: 0.15rem; flex: none; align-items: center; }

.icon, .send {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
  border: 0;
  flex: none;
}

.icon svg, .send svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon svg .dot { fill: currentColor; stroke: none; }

.side-head .icon {
  width: 36px;
  height: 36px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.28);
}

.side-head .icon:hover { background: rgba(255, 255, 255, 0.22); color: #ffffff; }

.menu { position: relative; }

.menu-panel {
  position: absolute;
  top: 44px;
  right: 0;
  min-width: 148px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 4;
}

.menu-item {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.menu .icon { position: relative; }

.menu .icon .unread {
  position: absolute;
  top: -4px;
  right: -4px;
  margin: 0;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-size: 0.65rem;
  line-height: 1rem;
}

.menu-item:hover { background: #e7f3ea; }

.pending-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0;
}

.pending-row span { flex: 1; min-width: 0; }

.pending-row button { width: auto; }

.journal-switch {
  display: flex;
  gap: 0.4rem;
}

.journal-switch button { width: auto; }

.journal-range {
  display: grid;
  gap: 0.45rem;
}

.journal-line {
  display: grid;
  gap: 0.12rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.journal-line.error {
  background: #fde8e8;
  color: #8d1d1d;
}

.journal-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.journal-line.error .journal-meta { color: #a14a4a; }

.journal-line span { overflow-wrap: anywhere; }

.panel {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  flex: none;
}

.finder {
  display: grid;
  gap: 0.28rem;
  margin: 0 0 0.65rem;
  flex: none;
  color: var(--muted);
  font-size: 0.78rem;
}

.finder input { width: 100%; border-radius: 999px; background: #f4faf5; }

#people { max-height: 180px; }

.list {
  display: grid;
  align-content: start;
  gap: 0.15rem;
  overflow: auto;
  min-height: 0;
}

.list button {
  width: 100%;
  min-width: 0;
  text-align: left;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 0.55rem 0.45rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.7rem;
}

.row-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.unread {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}

.row-text span, .row-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list button small { color: var(--muted); font-size: 0.75rem; }

.list button.active, .list button:hover { background: #e7f3ea; }

main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #f7fbf7;
}

.talk-head {
  position: relative;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.7rem 1rem;
  background: white;
  border-bottom: 1px solid var(--line);
}

.talk-head .icon { color: var(--green); }

.talk-head .icon:hover { background: #e7f3ea; }

.talk-head .icon.danger { color: var(--warn); }

.talk-head .icon.off { color: var(--warn); background: #fde8e4; }

.join {
  padding: 0.4rem 0.85rem;
  background: var(--green);
  color: white;
  white-space: nowrap;
}

.place-tools { position: relative; }

.den-panel { min-width: 16rem; max-height: 24rem; overflow: auto; }

.den-panel input { width: 100%; margin: 0.15rem 0 0.35rem; }

.den-list { display: grid; gap: 0.25rem; max-height: 16rem; overflow: auto; }

.den-list .member-chip { max-width: none; width: 100%; }

.den-empty { margin: 0.35rem 0.55rem; color: var(--muted); font-size: 0.9rem; }

.den-panel .member-form { flex-direction: column; align-items: stretch; margin-top: 0.35rem; }

.den-panel .member-form select { max-width: none; width: 100%; }

.place-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 6;
  display: grid;
  gap: 0.15rem;
  min-width: 15rem;
  padding: 0.4rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.place-menu button {
  background: transparent;
  color: var(--pine);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  text-align: left;
}

.place-menu button:hover { background: #e7f3ea; }

.place-menu button.danger { color: var(--warn); }

.rename-form {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
}

.rename-form input { flex: 1; min-width: 0; }

.rename-form button {
  background: #8a4b22;
  color: white;
  white-space: nowrap;
}

.talk-extra {
  position: relative;
  z-index: 3;
  background: #f7fbf7;
}

.status:empty { display: none; }

.status {
  margin: 0.55rem 0.85rem 0.45rem;
  padding: 0.65rem 0.85rem;
  background: #fff8ee;
  color: #6d3a18;
  border: 1px solid #efd3b0;
  border-radius: 12px;
  line-height: 1.4;
}

.kicker { margin: 0 0 0.1rem; font-size: 0.78rem; }

.talk-title { flex: 1 1 140px; min-width: 0; }

.icon-actions { margin-left: auto; }

.member-box {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.member-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  min-width: 0;
  overflow-x: auto;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  max-width: 9rem;
  padding: 0.15rem 0.55rem 0.15rem 0.15rem;
  border-radius: 999px;
  background: #e7f3ea;
  color: var(--ink);
  cursor: pointer;
}

.member-chip > span:not(.avatar) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-chip .avatar { width: 26px; height: 26px; font-size: 0.75rem; background: var(--pine); }

.member-chip.owner { background: #fff1e0; }

.member-chip.owner .avatar { background: #e07a2f; }

.member-chip small { color: #8a4b22; font-size: 0.72rem; }

.member-form {
  display: flex;
  flex: 1 1 8rem;
  min-width: 0;
  gap: 0.35rem;
  align-items: center;
}

.member-form select {
  width: auto;
  min-width: 0;
  flex: 1;
  max-width: 10rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: #f4faf5;
  color: var(--ink);
}

.member-form button { white-space: nowrap; background: #8a4b22; padding: 0.4rem 0.75rem; }

.member-form button:hover { background: #6d3a18; }

.thread {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #07140f;
}

.grove {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.fox-spot {
  position: absolute;
  z-index: 0;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
}

.fox-spot.one { width: 132px; left: 5%; bottom: 9%; }
.fox-spot.two { width: 76px; left: 36%; top: 14%; transform: scaleX(-1); }
.fox-spot.three { width: 104px; right: 8%; bottom: 12%; }
.fox-spot.four { width: 62px; right: 30%; top: 20%; transform: scaleX(-1); }

#empty-den[hidden] { display: none !important; }

.empty-den {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 1rem;
  pointer-events: none;
}

.card .scene { width: 168px; }

.empty-den .scene { width: min(200px, 70%); }

.thread-empty {
  margin: auto;
  max-width: 16rem;
  color: #d7ead4;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.letter-finder {
  position: absolute;
  top: 0.55rem;
  left: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.35rem 0.3rem 0.85rem;
  background: #fff8ee;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.letter-finder input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.35rem 0;
  border-radius: 0;
  box-shadow: none;
}

.letter-finder .icon { width: 32px; height: 32px; color: var(--pine); }

.letter-finder .icon svg { width: 18px; height: 18px; }

#letter-count {
  flex: none;
  min-width: 4.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.messages.searching { padding-top: 4.2rem; }

.messages.picking { padding-bottom: 4.4rem; }

.messages.picking .bubble.picked { box-shadow: 0 0 0 2px #2f6b45; }

.messages.picking .bubble.picked::before {
  content: "✓";
  position: absolute;
  top: -8px;
  left: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2f6b45;
  color: white;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.messages.picking .bubble.mine.picked::before { left: auto; right: -8px; }

.pick-bar {
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  bottom: 0.55rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem 0.4rem 0.85rem;
  background: #fff8ee;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.pick-bar #pick-count { flex: 1; color: var(--pine); font-weight: 650; }

.pick-bar #pick-forward {
  background: var(--green);
  color: white;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}

.pick-bar #pick-forward:hover { background: var(--pine); }

.pick-bar .icon { width: 32px; height: 32px; color: var(--pine); }

.pick-bar .forward-list { flex-basis: 100%; background: white; border-radius: 10px; }

.messages {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 2.6rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.letter {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  max-width: 100%;
  min-width: 0;
}

.letter.mine { justify-content: flex-end; }

.letter.call-row { justify-content: center; }

.bubble.call-line {
  margin: 0 auto;
  background: #fff8ee;
  color: #6d3a18;
  border-radius: 999px;
  cursor: default;
}

.receipt {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.receipt.read { color: var(--pine); }

.letter-face {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  cursor: pointer;
}

.bubble {
  position: relative;
  z-index: 1;
  max-width: min(68%, 640px);
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 12px 12px 12px 4px;
  background: white;
  border: 0;
  box-shadow: 0 1px 1px rgba(22, 53, 40, 0.06);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.bubble.mine {
  border-radius: 12px 12px 4px 12px;
  background: var(--mine);
  color: var(--ink);
}

.bubble .who { display: block; font-size: 0.75rem; color: var(--green); margin-bottom: 0.15rem; cursor: pointer; }
.bubble .when { display: block; margin-top: 0.28rem; color: var(--muted); font-size: 0.72rem; text-align: right; }
.bubble.mine .when { color: #5d6f62; }

.forward-mark {
  margin: 0 0 0.28rem;
  color: #8a4b22;
  font-size: 0.78rem;
  font-weight: 650;
}

#talk-title, #me-name, #me-avatar { cursor: pointer; }

.bubble.mine .who { color: var(--pine); }

.quote {
  display: grid;
  gap: 0.1rem;
  margin-bottom: 0.35rem;
  padding: 0.28rem 0.55rem;
  border-left: 3px solid #e07a2f;
  border-radius: 8px;
  background: rgba(224, 122, 47, 0.1);
  font-size: 0.82rem;
  cursor: pointer;
}

.quote:hover { background: rgba(224, 122, 47, 0.2); }

.quote strong { color: #8a4b22; }

.quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble.hit { box-shadow: 0 0 0 2px #c6a15a; }

.bubble.hit-current { box-shadow: 0 0 0 2px #e07a2f; }

.bubble.jumped { box-shadow: 0 0 0 3px #e07a2f; }

.msg-actions {
  position: fixed;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  width: max-content;
  max-width: min(280px, calc(100% - 16px));
  padding: 0.25rem;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
}

.msg-actions button {
  background: transparent;
  color: var(--pine);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.msg-actions button:hover { background: #e7f3ea; }

.msg-actions button.danger { color: var(--warn); }

.msg-actions button.danger:hover { background: #fde8e4; }

.bubble img, .bubble video, .videos video {
  display: block;
  max-width: 280px;
  max-height: 220px;
  border-radius: 12px;
  margin-top: 0.45rem;
  background: #163528;
}

.bubble audio, .videos audio { display: block; width: min(100%, 260px); margin-top: 0.45rem; }

.file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: #f4faf5;
  color: var(--ink);
}

.bubble.mine .file-card { background: rgba(255, 255, 255, 0.72); }

.file-save {
  display: inline-block;
  margin-top: 0.35rem;
  color: var(--pine);
  font-weight: 650;
  font-size: 0.85rem;
}

.file-card .file-save { margin-top: 0; }

.bubble img + .file-save,
.bubble video + .file-save,
.bubble audio + .file-save { display: block; }

.videos { display: flex; flex-wrap: wrap; gap: 0.6rem; padding: 0 1rem 0.6rem; }

.videos:empty { display: none; }

.videos video {
  width: 220px;
  height: 160px;
  object-fit: cover;
  margin-top: 0;
  background: #111;
}

.typing {
  margin: 0 0.35rem;
  min-height: 1.1rem;
  color: var(--pine);
  font-size: 0.85rem;
}

.typing::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: typing-dots 1.2s steps(4, end) infinite;
}

@keyframes typing-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.call-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  max-width: calc(100% - 2rem);
  padding: 0.7rem 0.85rem;
  background: #fff8ee;
  color: #6d3a18;
  border: 1px solid #efd3b0;
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.call-banner p { margin: 0; }

.call-banner .ghost {
  color: var(--warn);
  border-color: #e7b2ab;
}

.composer {
  position: relative;
  display: grid;
  gap: 0.45rem;
  background: #f7fbf7;
  padding: 0.55rem 0.8rem 0.7rem;
}

.record-bar, .upload-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.record-bar span { color: var(--warn); font-size: 0.85rem; }

.upload-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #d5e4d8;
  overflow: hidden;
}

#upload-fill {
  width: 0;
  height: 100%;
  background: var(--green);
}

.composer-row { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }

#body {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: white;
  box-shadow: inset 0 0 0 1px var(--line);
}

.file input { display: none; }

.composer .icon {
  color: #143528;
  background: #d7ead4;
}

.composer .icon svg { width: 24px; height: 24px; stroke-width: 2.35; }

.composer .icon:hover { background: #b7d8b4; color: #0c2418; }

.send {
  background: var(--green);
  color: white;
}

.send:hover { background: var(--pine); }

.send svg { width: 18px; height: 18px; }

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0.4rem;
  padding: 0.35rem 0.45rem 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.reply-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0.4rem;
  padding: 0.35rem 0.35rem 0.35rem 0.75rem;
  border-left: 3px solid #e07a2f;
  border-radius: 12px;
  background: white;
}

.reply-chip strong { display: block; color: #8a4b22; font-size: 0.8rem; }

.reply-chip span {
  display: block;
  max-width: 420px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-panel {
  position: absolute;
  left: 0.8rem;
  bottom: calc(100% + 0.45rem);
  width: min(420px, calc(100% - 1.6rem));
  height: 420px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 5;
}

.emoji-tabs {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  padding: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.emoji-grid {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-content: start;
  gap: 0.15rem;
  padding: 0.45rem;
}

.emoji-tabs button, .emoji-grid button {
  height: 40px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-family: "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  font-size: 1.35rem;
}

.settings {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  min-height: 0;
  overflow: auto;
}

.settings h2 { margin: 0.2rem 0 0; font-size: 1.2rem; }

.settings h3 { margin: 0 0 0.3rem; font-size: 0.82rem; color: var(--pine); }

.settings p { margin: 0; color: var(--muted); line-height: 1.4; }

.settings section {
  padding: 0.75rem 0.8rem;
  background: #f4faf5;
  border-radius: 14px;
}

.check {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--ink);
}

#settings-sound-row { margin-top: 0.7rem; }

.check input {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.15rem;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--pine);
  flex: none;
}

.settings label {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
}

.settings textarea {
  min-height: 4.6rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--ink);
}

.settings form button { margin-top: 0.7rem; }

.profile {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(7, 20, 15, 0.45);
  padding: 1rem;
}

.profile-card {
  position: relative;
  width: min(420px, 100%);
  display: grid;
  justify-items: start;
  gap: 0.45rem;
  padding: 1.1rem;
  background: #fff8ee;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.profile-tools {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  display: flex;
  gap: 0.1rem;
}

.profile-tools .icon { color: var(--green); }

.profile-tools .icon:hover { background: #e7f3ea; }

.profile-card h2 { margin: 0; }

.profile-card .profile-line {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  margin: 0;
  padding: 0.7rem 0.85rem;
  background: white;
  border-radius: 12px;
}

.profile-card .profile-line span {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.profile-card .profile-line strong,
.profile-card .profile-line em {
  font-style: normal;
  font-weight: 650;
  line-height: 1.4;
  color: var(--ink);
}

.profile-card .avatar { width: 64px; height: 64px; font-size: 1.4rem; }

.composer .icon.gif {
  width: auto;
  min-width: 40px;
  padding: 0 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}

.avatar-actions .ghost { padding: 0.45rem 0.8rem; }

.avatar-actions .ghost,
.settings form button,
.member-form button {
  max-width: 100%;
}

.gif-panel {
  position: absolute;
  left: 0.8rem;
  bottom: calc(100% + 0.45rem);
  width: min(420px, calc(100% - 1.6rem));
  height: min(420px, 46vh);
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 5;
}

.gif-panel input {
  margin: 0.55rem;
  width: auto;
}

.gif-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 0.4rem;
  padding: 0 0.55rem 0.55rem;
}

.gif-grid button {
  padding: 0;
  border-radius: 12px;
  background: #f4faf5;
  overflow: hidden;
}

.gif-grid img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
}

.gif-add {
  display: block;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--line);
  color: var(--pine);
  font-weight: 650;
  cursor: pointer;
}

.gif-add input { display: none; }

.forward-list {
  flex-basis: 100%;
  display: grid;
  gap: 0.15rem;
  max-height: 180px;
  overflow: auto;
  min-width: 180px;
}

.forward-list p { margin: 0.15rem 0.35rem; color: var(--muted); font-size: 0.75rem; }

.forward-list button {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 0.4rem 0.55rem;
}

.emoji-tabs button { width: 40px; flex: none; }

.emoji-tabs button.active, .emoji-grid button:hover, .emoji-tabs button:hover {
  background: #e7f3ea;
}

.all-hits { display: flex; flex-direction: column; gap: 0.2rem; margin: 0 0 0.4rem; max-height: 240px; overflow: auto; }
.all-hits button, .all-empty {
  text-align: left;
  border-radius: 10px;
  background: #fff8ee;
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  margin: 0;
}
.list button.pinned { box-shadow: inset 3px 0 0 var(--green); }
.list button.muted small { font-style: italic; }
.seen { margin: 0.15rem 0 0.4rem; color: var(--pine); font-size: 0.85rem; }
.edited { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.72rem; }
.reacts { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.35rem; }
.reacts button, .react-pick button {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  background: #fff;
  color: var(--ink);
}
.reacts button.mine { background: #e7f3ea; }
.react-pick { display: flex; gap: 0.2rem; padding: 0.2rem; }
.composer.drop-over, .messages.drop-over { outline: 2px dashed var(--green); outline-offset: -6px; }

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 38vh) minmax(0, 1fr);
  }
}
