:root {
  color-scheme: light dark;
  --sj-primary: light-dark(
    var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)),
    var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45))
  );
  --sj-secondary: light-dark(
    var(--color-sanajong-light-secondary, oklch(0.6016 0.2214 292.23)),
    var(--color-sanajong-dark-secondary, oklch(0.7052 0.1615 293.33))
  );
  --sj-accent: light-dark(
    var(--color-sanajong-light-accent, oklch(0.7697 0.1645 70.61)),
    var(--color-sanajong-dark-accent, oklch(0.8334 0.1641 83.87))
  );
  --page: light-dark(
    var(--color-neutral-50, oklch(0.9843 0.0017 247.84)),
    oklch(0.165 0.022 260)
  );
  --surface: light-dark(
    var(--color-brand-card, oklch(1 0 0)),
    var(--color-neutral-900, oklch(0.2103 0.0316 264.78))
  );
  --surface-translucent: light-dark(
    color-mix(in oklch, var(--color-brand-card, #ffffff) 86%, transparent),
    color-mix(in oklch, var(--color-neutral-900, oklch(0.2103 0.0316 264.78)) 86%, transparent)
  );
  --surface-soft: light-dark(
    var(--color-neutral-100, oklch(0.9679 0.0027 264.54)),
    var(--color-sanajong-dark-surface, oklch(0.2794 0.0299 256.85))
  );
  --surface-hover: light-dark(
    var(--color-neutral-200, oklch(0.9278 0.0058 264.53)),
    var(--color-neutral-700, oklch(0.376 0.0308 259.85))
  );
  --ink: light-dark(
    var(--color-neutral-900, oklch(0.2103 0.0316 264.78)),
    var(--color-neutral-50, oklch(0.9843 0.0017 247.84))
  );
  --muted: light-dark(
    var(--color-neutral-600, oklch(0.4449 0.0266 256.8)),
    var(--color-neutral-400, oklch(0.7141 0.0198 261.48))
  );
  --line: light-dark(
    var(--color-neutral-200, oklch(0.9278 0.0058 264.53)),
    color-mix(in oklch, var(--color-neutral-700, oklch(0.376 0.0308 259.85)) 65%, transparent)
  );
  --line-strong: light-dark(
    var(--color-neutral-300, oklch(0.8724 0.0091 258.34)),
    var(--color-neutral-700, oklch(0.376 0.0308 259.85))
  );
  --forest: var(--color-neutral-900, oklch(0.2103 0.0316 264.78));
  --forest-deep: oklch(0.155 0.028 264);
  --accent: var(--color-sanajong-dark-accent, oklch(0.8334 0.1641 83.87));
  --accent-ink: var(--color-neutral-900, oklch(0.2103 0.0316 264.78));
  --green: var(--sj-primary);
  --green-solid: var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6));
  --green-hover: color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 86%, black);
  --mine-bg: light-dark(
    color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 11%, white),
    color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 18%, var(--color-neutral-900, oklch(0.2103 0.0316 264.78)))
  );
  --mine-border: light-dark(
    color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 26%, white),
    color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 36%, var(--color-neutral-900, oklch(0.2103 0.0316 264.78)))
  );
  --danger: light-dark(
    var(--color-error, oklch(0.6356 0.2082 25.38)),
    oklch(0.72 0.18 25)
  );
  --danger-soft: light-dark(
    color-mix(in oklch, var(--color-error, oklch(0.6356 0.2082 25.38)) 12%, white),
    color-mix(in oklch, var(--color-error, oklch(0.6356 0.2082 25.38)) 22%, var(--color-neutral-900, oklch(0.2103 0.0316 264.78)))
  );
  --focus-ring: color-mix(in oklch, var(--sj-primary) 28%, transparent);
  --shadow-sm: light-dark(0 1px 3px rgb(15 23 42 / 0.06), 0 1px 3px rgb(0 0 0 / 0.32));
  --shadow-md: light-dark(0 8px 24px rgb(15 23 42 / 0.10), 0 10px 28px rgb(0 0 0 / 0.45));
  --shadow-lg: light-dark(0 24px 64px rgb(15 23 42 / 0.18), 0 24px 64px rgb(0 0 0 / 0.65));
  --dot-pattern: light-dark(
    color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 22%, transparent),
    color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 14%, transparent)
  );
  --glow-bg: light-dark(
    color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 12%, white),
    color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 14%, oklch(0.165 0.022 260))
  );
  --code-bg: light-dark(
    var(--color-neutral-100, oklch(0.9679 0.0027 264.54)),
    oklch(0.155 0.022 262)
  );
  --quote-bg: light-dark(
    var(--color-neutral-100, oklch(0.9679 0.0027 264.54)),
    var(--color-sanajong-dark-surface, oklch(0.2794 0.0299 256.85))
  );
  --quote-border: var(--sj-secondary);
  --display-font: 'Geist', var(--font-family-sans, Inter, system-ui, -apple-system, sans-serif);
  font-family: 'Geist', var(--font-family-sans, Inter, system-ui, -apple-system, sans-serif);
  color: var(--ink);
  background: var(--page);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

a {
  color: inherit;
}

button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, .feed:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Inline SVG icon system */
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  display: block;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-xs {
  width: 14px;
  height: 14px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

/* Theme toggle icon branching without JS classes */
.theme-opt-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-dark {
    display: none;
  }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-light {
    display: inline-flex;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-dark {
  display: none;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-light {
  display: inline-flex;
}

/* App Shell */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 621px) {
  .app {
    transition: grid-template-columns 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 26px 16px 16px;
  background: linear-gradient(160deg, oklch(0.24 0.042 262) 0%, var(--forest) 50%, var(--forest-deep) 100%);
  color: var(--color-neutral-50, #f8fafc);
  border-right: 1px solid rgb(255 255 255 / 0.08);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.collapse-sidebar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding: 2px 8px;
  width: max-content;
  text-decoration: none;
  font-weight: 760;
  font-size: 24px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand-period {
  color: var(--accent);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: contain;
  flex: none;
  background: rgb(255 255 255 / 0.08);
  padding: 2px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.22);
}

.new-button {
  margin: 28px 0 24px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 38%, transparent);
  border-radius: 11px;
  background: color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 18%, transparent);
  text-align: left;
  color: var(--color-neutral-50, #f8fafc);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.new-button:hover {
  background: color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 28%, transparent);
  border-color: color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 60%, transparent);
}

.new-button:active {
  transform: scale(0.985);
}

.new-button .icon {
  color: var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45));
}

.side-label {
  padding: 0 10px 8px;
  font-size: 10.5px;
  letter-spacing: 0.13em;
  color: var(--color-neutral-400, #94a3b8);
  font-weight: 700;
}

.sidebar nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / 0.2) transparent;
}

.room-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 8px 10px;
  color: var(--color-neutral-300, #cbd5e1);
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid transparent;
  font-size: 14px;
  transition: background 0.14s ease, color 0.14s ease;
}

.room-link:hover {
  background: rgb(255 255 255 / 0.08);
  color: #fff;
}

.room-link.active {
  background: color-mix(in oklch, var(--color-sanajong-light-primary, oklch(0.6261 0.1859 259.6)) 20%, transparent);
  color: #fff;
  font-weight: 600;
  border-color: color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 32%, transparent);
}

.room-link.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45));
}

.room-link.p2p span:first-child {
  font-size: 9px;
  letter-spacing: -0.04em;
}

.room-link span:first-child {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 18%, transparent);
  color: var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45));
  flex: none;
  font: 700 14px/1 var(--display-font);
}

.room-link.active span:first-child {
  background: color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 30%, transparent);
  color: #fff;
}

.room-link span:nth-child(2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-attention::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 28%, transparent);
  margin-left: auto;
  flex: none;
}

.sidebar-empty {
  font-size: 13px;
  color: var(--color-neutral-400, #94a3b8);
  margin: 6px 10px;
  line-height: 1.5;
}

.side-bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgb(255 255 255 / 0.11);
  display: flex;
  align-items: center;
  gap: 6px;
}

.identity {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 6px 8px 6px 6px;
  background: none;
  text-align: left;
  color: var(--color-neutral-50, #f8fafc);
  transition: background 0.14s ease;
}

.identity:hover {
  background: rgb(255 255 255 / 0.1);
}

.identity > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.identity strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
  font-weight: 600;
}

.identity small {
  color: var(--color-neutral-400, #94a3b8);
  font-size: 11px;
}

.identity-edit {
  margin-left: auto;
  color: var(--color-neutral-400, #94a3b8);
  display: inline-flex;
  opacity: 0.75;
  transition: opacity 0.14s ease;
}

.identity:hover .identity-edit {
  opacity: 1;
  color: var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45));
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.05);
  color: var(--color-neutral-300, #cbd5e1);
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.theme-toggle:hover {
  background: rgb(255 255 255 / 0.14);
  color: var(--accent);
  border-color: color-mix(in oklch, var(--accent) 45%, transparent);
}

.person-avatar {
  height: 36px;
  width: 36px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  flex: none;
  color: #1e3a8a;
  background: #dbeafe;
  font-size: 12.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tone-1 { background: #ede9fe; color: #5b21b6; }
.tone-2 { background: #fef3c7; color: #92400e; }
.tone-3 { background: #d1fae5; color: #065f46; }
.tone-4 { background: #e0f2fe; color: #075985; }
.tone-5 { background: #fce7f3; color: #9d174d; }

/* Main Column */
main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--page);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-translucent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 3;
}

.room-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--green);
  font: 700 22px/1 var(--display-font);
}

.room-icon.p2p {
  font-size: 13px;
  letter-spacing: -0.04em;
}

.room-heading {
  min-width: 0;
}

.room-heading h1 {
  margin: 0 0 2px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-heading p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--color-success, oklch(0.6902 0.1481 162.37));
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-success, oklch(0.6902 0.1481 162.37)) 24%, transparent);
}

.status-dot.waiting {
  background: var(--color-warning, oklch(0.7697 0.1645 70.61));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-warning, oklch(0.7697 0.1645 70.61)) 24%, transparent);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.members {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.members .person-avatar {
  width: 28px;
  height: 28px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  font-size: 9.5px;
  margin-left: -6px;
}

.members .person-avatar:first-child {
  margin-left: 0;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  padding: 7px 10px;
  min-height: 36px;
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background 0.14s ease, color 0.14s ease;
}

.ghost-button:hover {
  background: var(--surface-soft);
  color: var(--green);
}

.ghost-button .icon {
  color: var(--muted);
}

.ghost-button:hover .icon {
  color: var(--green);
}

.invite-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--mine-border);
  border-radius: 9px;
  background: var(--mine-bg);
  color: var(--green);
  padding: 7px 13px;
  min-height: 36px;
  font-size: 13.5px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.invite-button:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.invite-button:active {
  transform: scale(0.98);
}

.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  min-height: 36px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.outline-button:hover:not(:disabled) {
  background: var(--surface-soft);
}

.outline-button:disabled {
  opacity: 0.5;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  border: 0;
  background: transparent;
  border-radius: 9px;
  width: 34px;
  height: 34px;
  flex: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--ink);
}

.dots {
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
}

.menu-toggle, .shade {
  display: none;
}

/* Landing & Join */
.landing {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 36px 20px 56px;
  background:
    radial-gradient(ellipse at 50% 42%, var(--glow-bg) 0, transparent 58%),
    radial-gradient(var(--dot-pattern) 1px, transparent 1px);
  background-size: auto, 22px 22px;
}

.welcome {
  text-align: center;
  max-width: 560px;
  min-width: 0;
}

.illustration {
  width: 278px;
  height: 156px;
  position: relative;
  margin: 0 auto 20px;
  isolation: isolate;
}

.orbit {
  position: absolute;
  inset: 28px 7px;
  border: 1px solid color-mix(in oklch, var(--sj-primary) 32%, transparent);
  border-radius: 50%;
  transform: rotate(-18deg);
  z-index: -1;
}

.orbit-two {
  inset: 20px 17px;
  transform: rotate(15deg);
  border-color: color-mix(in oklch, var(--sj-secondary) 28%, transparent);
}

.bubble-back {
  position: absolute;
  width: 113px;
  height: 83px;
  left: 54px;
  top: 24px;
  border-radius: 23px;
  background: linear-gradient(135deg, var(--sj-secondary), var(--sj-primary));
  border: 1.5px solid color-mix(in oklch, var(--sj-primary) 65%, black);
  transform: rotate(-13deg);
  box-shadow: 3px 5px 0 color-mix(in oklch, var(--sj-secondary) 32%, transparent);
}

.bubble-back::after, .bubble-front::after {
  content: '';
  position: absolute;
  left: 14px;
  bottom: -12px;
  width: 24px;
  height: 17px;
  background: inherit;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.bubble-front {
  position: absolute;
  left: 124px;
  top: 52px;
  width: 111px;
  height: 79px;
  border-radius: 23px;
  background: var(--forest);
  border: 1.5px solid color-mix(in oklch, var(--sj-primary) 45%, transparent);
  box-shadow: 5px 7px 0 color-mix(in oklch, var(--sj-primary) 26%, transparent);
  transform: rotate(10deg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.hero-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
}

@media (prefers-reduced-motion: no-preference) {
  .bubble-back {
    animation: float-back 6s ease-in-out infinite;
  }
  .bubble-front {
    animation: float-front 5.4s ease-in-out infinite;
  }
}

@keyframes float-back {
  0%, 100% { transform: rotate(-13deg) translateY(0); }
  50% { transform: rotate(-11deg) translateY(-5px); }
}

@keyframes float-front {
  0%, 100% { transform: rotate(10deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-6px); }
}

.spark {
  position: absolute;
  font-style: normal;
  color: var(--green);
}

.spark-one { left: 31px; top: 31px; font-size: 22px; }
.spark-two { right: 18px; top: 19px; font-size: 28px; }
.spark-three { left: 86px; bottom: 3px; font-size: 14px; }

.welcome h2 {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 400;
  font-size: clamp(46px, 7vw, 88px);
  letter-spacing: -0.04em;
  line-height: 0.96;
  color: var(--ink);
}

.welcome h2 em {
  font-weight: 400;
  color: var(--green);
}

.welcome p {
  margin: 20px 0 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--green-solid);
  color: #fffef7;
  padding: 10px 18px;
  font-weight: 650;
  font-size: 14.5px;
  min-height: 42px;
  box-shadow: var(--shadow-sm);
  transition: background 0.14s ease, transform 0.12s ease, box-shadow 0.14s ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--green-hover);
  box-shadow: var(--shadow-md);
}

.primary-button:active:not(:disabled) {
  transform: scale(0.98);
}

.welcome .primary-button {
  padding: 12px 20px;
  border-radius: 12px;
}

.primary-button .icon {
  color: var(--accent);
}

/* Chat Area */
.chat {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.drop-overlay {
  position: absolute;
  inset: 14px;
  z-index: 12;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 2px dashed var(--green);
  background: var(--surface-translucent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

.drop-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 32px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  text-align: center;
}

.drop-overlay-card .icon {
  color: var(--green);
  margin-bottom: 4px;
}

.drop-overlay-card span {
  font-size: 12.5px;
  color: var(--muted);
}

.feed {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.thread {
  max-width: 880px;
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 20px;
}

.older {
  align-self: center;
  color: var(--green);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 7px 14px;
  margin-bottom: 16px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.14s ease;
}

.older:hover {
  background: var(--surface-hover);
}

.empty-room {
  margin: auto;
  text-align: center;
  padding: 24px 0;
}

.empty-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  color: var(--green);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  transform: rotate(-6deg);
  border-radius: 17px;
  font: 700 34px/1 var(--display-font);
}

.empty-room h2 {
  font: 400 clamp(30px, 5vw, 48px)/1.08 var(--display-font);
  letter-spacing: -0.035em;
  margin: 12px 0 8px;
  overflow-wrap: anywhere;
}

.empty-room p {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 14.5px;
}

.date-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.date-line::before, .date-line::after {
  content: '';
  height: 1px;
  background: var(--line);
  flex: 1;
}

/* Messages */
.message {
  display: flex;
  position: relative;
  gap: 11px;
  margin: 14px 0 0;
  padding: 2px 6px;
  border-radius: 12px;
  min-width: 0;
  transition: background 0.14s ease;
}

.message:hover {
  background: light-dark(rgb(15 23 42 / 0.025), rgb(255 255 255 / 0.025));
}

.message.grouped {
  margin-top: 3px;
}

.message-gutter {
  width: 36px;
  flex: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 2px;
}

.grouped-time {
  font-size: 10px;
  color: var(--muted);
  opacity: 0;
  font-variant-numeric: tabular-nums;
  padding-top: 9px;
  white-space: nowrap;
  transition: opacity 0.12s ease;
}

.message.grouped:hover .grouped-time,
.message.grouped:focus-within .grouped-time {
  opacity: 1;
}

.message-body {
  min-width: 0;
  flex: 1;
  max-width: min(100%, 700px);
}

.message-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  margin: 0 0 4px;
}

.message-head strong {
  font-size: 13.5px;
  font-weight: 680;
}

.message-head time, .message-head small {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--mine-bg);
  border: 1px solid var(--mine-border);
  color: var(--green);
  font-size: 10.5px;
  font-weight: 650;
}

.message-text {
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  background: var(--surface);
  padding: 9px 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  box-shadow: var(--shadow-sm);
}

.message.grouped .message-text {
  border-radius: 12px 16px 16px 16px;
}

.mine .message-text {
  background: var(--mine-bg);
  border-color: var(--mine-border);
}

.message-text a {
  color: var(--green);
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}

.message-text a:hover {
  opacity: 0.8;
}

.message-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code-bg);
  border: 1px solid var(--line);
}

.message-text pre {
  margin: 6px 0 2px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: pre;
}

.message-text pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12.5px;
  line-height: 1.45;
}

.quote {
  border: 0;
  border-left: 3px solid var(--quote-border);
  background: var(--quote-bg);
  border-radius: 0 8px 8px 0;
  padding: 4px 9px;
  color: var(--muted);
  display: block;
  text-align: left;
  max-width: min(100%, 360px);
  font-size: 11.5px;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.14s ease;
}

.quote:hover {
  background: var(--surface-hover);
}

.image-button {
  display: block;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 0;
  margin: 5px 0;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.image-button img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.image-button:hover {
  border-color: var(--green);
}

/* Floating pill message tools */
.message-tools {
  position: absolute;
  top: -12px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 2;
}

.message:hover .message-tools,
.message:focus-within .message-tools,
.message-tools:has(.popover:not([hidden])) {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message-tools .icon-button {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--muted);
}

.message-tools .quick-emoji {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 14px;
  display: inline-grid;
  place-items: center;
  transition: background 0.12s ease, transform 0.12s ease;
}

.message-tools .quick-emoji:hover {
  background: var(--surface-soft);
  transform: scale(1.15);
}

.tools-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 2px;
}

/* Popovers */
.popover {
  z-index: 6;
  min-width: 168px;
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.popover button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
  width: 100%;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.popover button:hover {
  background: var(--surface-soft);
}

.popover .danger {
  color: var(--danger);
}

.popover .danger:hover {
  background: var(--danger-soft);
}

.room-menu {
  right: 0;
  top: calc(100% + 8px);
}

.message-menu {
  right: 0;
  top: calc(100% + 6px);
}

.emoji-menu {
  display: flex;
  min-width: max-content;
  right: 0;
  top: calc(100% + 6px);
  gap: 2px;
}

.emoji-menu button {
  width: auto;
  padding: 6px 8px;
  font-size: 16px;
}

/* Reactions */
.reactions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  padding: 2px 8px;
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.reaction:hover {
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.reaction.selected {
  background: var(--mine-bg);
  border-color: var(--mine-border);
  color: var(--green);
  font-weight: 600;
}

/* Link Cards */
.link-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  max-width: 390px;
  width: fit-content;
  min-width: min(250px, 100%);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.link-card:hover {
  border-color: var(--line-strong);
}

.link-card img {
  display: block;
  width: 100%;
  max-height: 168px;
  object-fit: cover;
  background: var(--surface-soft);
}

.link-info {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 3px;
  overflow-wrap: anywhere;
}

.link-info small {
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 700;
}

.link-info strong {
  font-size: 13.5px;
  color: var(--ink);
}

.link-info span {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Voice Notes */
.voice-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: fit-content;
  min-width: min(240px, 100%);
  max-width: 100%;
  margin-top: 5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.mine .voice-note {
  background: var(--mine-bg);
  border-color: var(--mine-border);
}

.voice-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

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

.voice-duration {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.voice-note audio {
  display: block;
  width: 100%;
  max-width: 300px;
  height: 36px;
}

/* Collapsible Video Embeds */
.video-embed {
  margin-top: 6px;
  max-width: 100%;
}

.video-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.mine .video-toggle {
  background: var(--mine-bg);
  border-color: var(--mine-border);
}

.video-toggle:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.video-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  flex: none;
}

.video-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-expand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
  transition: transform 0.16s ease, color 0.14s ease;

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.video-toggle[aria-expanded="true"] .video-expand-icon,
.video-embed.expanded .video-expand-icon {
  transform: rotate(180deg);
  color: var(--green);
}

.video-frame-wrap {
  aspect-ratio: 16 / 9;
  width: min(100%, 480px);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.video-frame-wrap.portrait {
  aspect-ratio: 9 / 16;
  max-width: 300px;
}

.video-frame-wrap iframe,
.video-frame-wrap video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Floating Jump to Latest */
.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 124px;
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--green);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: var(--shadow-md);
  transition: transform 0.14s ease, background 0.14s ease;
}

.jump-latest:hover {
  background: var(--surface-soft);
  transform: translateX(-50%) translateY(-2px);
}

/* Composer */
.composer-zone {
  position: relative;
  padding: 4px 28px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--page) 82%, transparent);
}

.composer-width {
  max-width: 824px;
  margin: auto;
}

.composer-anchor {
  position: relative;
}

.typing {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  min-height: 18px;
  margin: 0 0 5px;
  padding: 0 4px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
}

@media (prefers-reduced-motion: no-preference) {
  .typing-dots i {
    animation: typing-bounce 1.2s ease-in-out infinite;
  }
  .typing-dots i:nth-child(2) { animation-delay: 0.18s; }
  .typing-dots i:nth-child(3) { animation-delay: 0.36s; }
}

@keyframes typing-bounce {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.composer {
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: var(--surface);
  padding: 7px 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-sm);
}

.composer textarea {
  width: 100%;
  display: block;
  color: var(--ink);
  background: transparent;
  border: 0;
  resize: none;
  min-height: 46px;
  max-height: 160px;
  outline: none !important;
  padding: 9px 10px 6px;
  line-height: 1.48;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 1px;
}

.compose-hint {
  font-size: 11px;
  color: var(--muted);
}

.compose-hint span {
  padding: 0 3px;
}

.char-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.char-count.warn {
  color: var(--danger);
  font-weight: 650;
}

.attach {
  width: 34px;
  height: 32px;
}

.send-button {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 0;
  border-radius: 9px;
  background: var(--green-solid);
  color: #fffef9;
  padding: 5px 12px;
  font-weight: 650;
  font-size: 13px;
  transition: background 0.14s ease, transform 0.12s ease;
}

.char-count:not([hidden]) + .send-button {
  margin-left: 6px;
}

.send-button .icon {
  color: var(--accent);
}

.send-button:disabled {
  background: var(--surface-soft);
  color: var(--muted);
}

.send-button:disabled .icon {
  color: inherit;
}

.send-button:not(:disabled):hover {
  background: var(--green-hover);
}

.send-button:not(:disabled):active {
  transform: scale(0.97);
}

.room-caption {
  margin: 6px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

.draft-strip, .draft-preview {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 7px 10px;
  margin: 1px 0 5px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.draft-strip > div, .draft-preview > div {
  min-width: 0;
  flex: 1;
}

.draft-strip strong, .draft-strip p {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  font-size: 12px;
}

.draft-strip p {
  font-size: 11.5px;
  color: var(--muted);
  margin: 2px 0 0;
}

.draft-strip img {
  width: 42px;
  height: 40px;
  border-radius: 7px;
  object-fit: cover;
}

.draft-strip .icon-button, .draft-preview .icon-button {
  width: 26px;
  height: 26px;
}

.draft-preview {
  align-items: flex-start;
}

.draft-preview .link-card {
  margin: 0;
  max-width: 340px;
  width: 100%;
  flex-direction: row;
  box-shadow: none;
}

.draft-preview .link-card img {
  width: 78px;
  min-height: 55px;
  max-height: 85px;
}

/* Voice Note Recording & Draft */
#record-voice.recording {
  color: var(--danger);
  background: var(--danger-soft);
}

.voice-recording {
  border-color: light-dark(#e8c5c6, #5a2b2e);
  background: var(--danger-soft);
}

.voice-recording strong {
  color: var(--danger);
}

.voice-recording #voice-timer {
  font-variant-numeric: tabular-nums;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  flex: none;

  @media (prefers-reduced-motion: no-preference) {
    animation: rec-pulse 1.2s ease-in-out infinite;
  }
}

@keyframes rec-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

.voice-draft audio {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 300px;
  height: 36px;
}

.voice-draft .icon-button {
  margin-left: auto;
}

/* Floating Mentions */
.mention-options {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.mention-options button {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 6px 9px;
  font-size: 13px;
}

.mention-options button small {
  color: var(--muted);
  font-size: 12px;
}

.mention-options .person-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 10px;
}

.mention-options button.active, .mention-options button:hover {
  background: var(--surface-soft);
}

.mention-text {
  color: var(--green);
  font-weight: 700;
  background: var(--mine-bg);
  padding: 0 4px;
  border-radius: 5px;
}

.mention-me .message-text {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green), var(--shadow-sm);
}

.message-highlight .message-text {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Dialogs & Top-Layer Animations */
dialog {
  width: min(92vw, 430px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(8px) scale(0.97);
  }
}

dialog::backdrop {
  background: rgb(15 23 42 / 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog[open]:where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);

    @starting-style {
      transform: translateY(8px) scale(0.97);
    }
  }

  &::backdrop {
    background: rgb(15 23 42 / 0.56);
    backdrop-filter: blur(4px);

    @starting-style {
      background: rgb(15 23 42 / 0);
      backdrop-filter: blur(0px);
    }
  }
}

/* Slide-over Drawer Panel for Gallery & Pins */
.feature-panel {
  width: min(92vw, 560px);
  max-height: 86dvh;
  overflow: auto;
}

.drawer-panel {
  margin: 0 0 0 auto;
  width: min(94vw, 440px);
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 20px 0 0 20px;
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
  padding: 22px 22px 28px;

  @media (prefers-reduced-motion: no-preference) {
    transform: translateX(36px);
  }
}

.drawer-panel[open]:where(:not([data-closing])) {
  @media (prefers-reduced-motion: no-preference) {
    transform: translateX(0);

    @starting-style {
      transform: translateX(36px);
    }
  }
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-top h2 {
  margin: 0;
  font: 400 28px/1.15 var(--display-font);
  letter-spacing: -0.025em;
}

.dialog-top .icon-button {
  margin: -6px -6px 0 0;
}

.dialog-top + p {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.mode-picker {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  display: grid;
  gap: 8px;
  accent-color: var(--green);
}

.mode-picker legend {
  margin-bottom: 8px;
  font: 600 12.5px/1.3 var(--font, inherit);
}

dialog .mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
}

dialog .mode-option:has(:checked) {
  border-color: var(--green);
  background: color-mix(in oklch, var(--green) 10%, transparent);
}

dialog .mode-option input {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 2px;
  padding: 0;
  accent-color: var(--green);
}

dialog .mode-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

dialog .mode-option small {
  color: var(--muted);
  font-weight: 450;
  line-height: 1.4;
}

@supports not (accent-color: var(--green)) {
  dialog .mode-option input {
    appearance: none;
    border: 2px solid var(--line-strong);
    border-radius: 50%;
    background: var(--page);
  }

  dialog .mode-option input:checked {
    border-color: var(--green);
    background: radial-gradient(circle, var(--green) 0 45%, transparent 50%);
  }
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

dialog label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
}

dialog input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: var(--page);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

dialog input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

/* Image Lightbox Viewer */
.viewer {
  width: min(96vw, 1080px);
  max-width: 96vw;
  max-height: 94dvh;
  padding: 14px;
  background: var(--forest-deep);
  color: var(--color-neutral-50, #f8fafc);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 18px;
  overflow: hidden;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 12px;
}

.viewer-meta {
  font-size: 13px;
  color: var(--color-neutral-400, #94a3b8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.08);
  color: var(--color-neutral-50, #f8fafc);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 550;
  transition: background 0.14s ease;
}

.viewer-link:hover {
  background: rgb(255 255 255 / 0.16);
}

.viewer-close {
  color: var(--color-neutral-50, #f8fafc);
  background: rgb(255 255 255 / 0.08);
}

.viewer-close:hover {
  background: rgb(255 255 255 / 0.18);
  color: #fff;
}

.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.viewer img {
  display: block;
  max-width: 100%;
  max-height: calc(86dvh - 56px);
  object-fit: contain;
  border-radius: 10px;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 99px;
  background: rgb(15 23 42 / 0.72);
  border: 1px solid rgb(255 255 255 / 0.16);
  color: #fff;
  backdrop-filter: blur(6px);
}

.viewer-nav:hover {
  background: rgb(15 23 42 / 0.92);
  color: var(--accent);
}

#viewer-prev { left: 10px; }
#viewer-next { right: 10px; }

/* Toast */
.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(88vw, 380px);
  border-radius: 11px;
  padding: 11px 16px;
  background: var(--forest);
  color: var(--color-neutral-50, #f8fafc);
  border: 1px solid color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 32%, transparent);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {
  .toast:not([hidden]) {
    animation: toast-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Join Card */
.join-card {
  width: min(400px, 100%);
  padding: 30px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.join-card h2 {
  font: 400 30px/1.12 var(--display-font);
  letter-spacing: -0.025em;
  margin: 14px 0 8px;
}

.join-card p, .panel-note {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.join-card form {
  display: grid;
  gap: 10px;
  text-align: left;
  margin: 20px 0;
}

.join-card label {
  font-size: 12.5px;
  font-weight: 650;
}

.join-card input {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--page);
  color: var(--ink);
}

.back-link {
  color: var(--green);
  font-size: 12.5px;
  text-underline-offset: 3px;
}

/* Feature Panels (Gallery, Pins, Settings) */
.feature-panel .dialog-top {
  margin-bottom: 16px;
}

.segments {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  margin: 0 0 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.segments button {
  border: 0;
  border-radius: 7px;
  padding: 7px 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.14s ease, color 0.14s ease;
}

.segments button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.gallery-grid.links {
  grid-template-columns: 1fr;
}

.gallery-tile, .panel-row {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 11px;
  min-width: 0;
}

.gallery-image {
  display: block;
  padding: 0;
  border: 0;
  background: var(--surface-soft);
  width: 100%;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}

.gallery-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1.4;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.gallery-image:hover img {
  transform: scale(1.03);
}

.gallery-tile footer, .panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
}

.gallery-tile footer span, .panel-row strong {
  display: block;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.panel-row {
  align-items: start;
}

.panel-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.panel-list {
  display: grid;
  gap: 8px;
}

.panel-list p {
  margin: 0;
}

.panel-link {
  color: var(--green);
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-underline-offset: 2px;
}

.compact-button {
  padding: 5px 9px;
  min-height: 28px;
  font-size: 11.5px;
}

#gallery-more {
  margin-top: 14px;
  width: 100%;
}

.settings-group {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--page);
}

.settings-group h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 680;
}

.settings-group .panel-note {
  margin: 0 0 10px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 12px;
}

.settings-actions .outline-button {
  font-size: 12.5px;
  min-height: 32px;
  padding: 5px 10px;
}

.settings-group label span {
  color: var(--muted);
  font-weight: 400;
}

.settings-group input[type="datetime-local"] {
  width: min(100%, 260px);
}

.settings-group input:disabled {
  opacity: 0.55;
}

.settings-group .check-row {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 12px 0 0;
  font-weight: 500;
}

.check-row input {
  width: auto;
  accent-color: var(--green-solid);
}

.outline-button.danger {
  color: var(--danger);
  border-color: light-dark(#e8c5c6, #5a2b2e);
}

.outline-button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

/* Desktop room rail */
@media (min-width: 621px) {
  .collapse-sidebar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border: 1px solid rgb(255 255 255 / 0.12);
    border-radius: 10px;
    background: rgb(255 255 255 / 0.05);
    color: var(--color-neutral-300, #cbd5e1);
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  }

  .collapse-sidebar:hover {
    background: rgb(255 255 255 / 0.14);
    color: var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45));
    border-color: color-mix(in oklch, var(--color-sanajong-dark-primary, oklch(0.7157 0.1425 254.45)) 40%, transparent);
  }

  .collapse-sidebar .icon {
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .app.sidebar-collapsed {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .app.sidebar-collapsed .sidebar {
    padding-inline: 10px;
  }

  .app.sidebar-collapsed .side-head {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .app.sidebar-collapsed .brand {
    padding-inline: 0;
  }

  .app.sidebar-collapsed .new-button,
  .app.sidebar-collapsed .room-link,
  .app.sidebar-collapsed .identity {
    position: relative;
    justify-content: center;
    padding-inline: 0;
  }

  .app.sidebar-collapsed .side-bottom {
    flex-direction: column;
    align-items: center;
  }

  .app.sidebar-collapsed .collapse-text,
  .app.sidebar-collapsed .room-link span:nth-child(2),
  .app.sidebar-collapsed .identity > span:nth-child(2),
  .app.sidebar-collapsed .identity-edit,
  .app.sidebar-collapsed .sidebar-empty {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app.sidebar-collapsed .room-link.active::before {
    left: 0;
  }

  .app.sidebar-collapsed .room-attention::after {
    position: absolute;
    top: 8px;
    right: 6px;
    margin: 0;
  }

  .app.sidebar-collapsed .collapse-sidebar .icon {
    transform: rotate(180deg);
  }
}

/* Responsive */
@media (max-width: 820px) {
  .app {
    grid-template-columns: 215px minmax(0, 1fr);
  }
  .sidebar {
    padding-inline: 12px;
  }
  .topbar {
    padding-inline: 18px;
  }
  .thread, .composer-zone {
    padding-inline: 18px;
  }
  .members {
    display: none;
  }
}

@media (max-width: 620px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(276px, 84vw);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    padding-top: 22px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .shade {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9;
    border: 0;
    background: rgb(15 23 42 / 0.48);
    backdrop-filter: blur(2px);
  }
  .menu-toggle {
    display: grid;
    width: 34px;
    height: 34px;
  }
  .topbar {
    min-height: 60px;
    gap: 8px;
    padding: 8px 12px;
  }
  .room-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }
  .room-heading h1 {
    font-size: 15px;
  }
  .room-heading p {
    font-size: 10.5px;
  }
  .top-actions {
    gap: 4px;
  }
  .top-actions .room-tool span {
    display: none;
  }
  .top-actions .room-tool {
    padding: 7px;
    min-width: 34px;
  }
  .invite-button {
    padding: 6px 9px;
    min-height: 33px;
    font-size: 12.5px;
  }
  .dots {
    width: 33px;
    height: 33px;
  }
  .welcome h2 {
    font-size: clamp(46px, 13vw, 72px);
  }
  .landing {
    padding-bottom: 42px;
  }
  .welcome p {
    font-size: 14.5px;
  }
  .thread {
    padding: 16px 10px 10px;
  }
  .composer-zone {
    padding-inline: 10px;
  }
  .compose-hint {
    display: none;
  }
  .message {
    gap: 8px;
    padding: 2px 3px;
  }
  .message-gutter {
    width: 30px;
  }
  .message .person-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 11px;
  }
  .message-tools {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
    background: transparent;
    border: 0;
    padding: 0;
    align-self: flex-start;
  }
  .message-tools .quick-emoji,
  .message-tools .tools-divider {
    display: none;
  }
  .drawer-panel {
    width: 100vw;
    border-radius: 0;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  }
  .panel-row {
    flex-wrap: wrap;
  }
  .toast {
    right: 12px;
    bottom: 14px;
  }
}

@media (hover: none) {
  .message-tools {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app, .collapse-sidebar .icon {
    transition: none;
  }
  dialog, dialog::backdrop {
    transition-duration: 0.1s;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* UI SDK (@ui-sdk/web) Primitives */
.message-tools:has(ui-menu[data-open]) {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

ui-menu-content,
ui-menu-sub-content {
  min-width: 176px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

ui-menu-item,
ui-menu-sub-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  outline: none;
  transition: background 0.12s ease;
}

ui-menu-item[data-highlighted],
ui-menu-sub-trigger[data-highlighted] {
  background: var(--surface-soft);
}

ui-menu-item.danger {
  color: var(--danger);
}

ui-menu-item.danger[data-highlighted] {
  background: var(--danger-soft);
}

ui-menu-sub-trigger::after {
  content: '›';
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

ui-trigger-menu {
  display: block;
  width: 100%;
}

ui-trigger-menu-content {
  min-width: 220px;
  max-width: min(360px, 90vw);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 5px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

ui-trigger-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

ui-trigger-menu-item[data-highlighted] {
  background: var(--surface-soft);
}

ui-trigger-menu-empty {
  display: block;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

ui-segmented-control.segments {
  position: relative;
  display: inline-flex;
  isolation: isolate;
}

ui-segmented-control-indicator {
  position: absolute;
  z-index: -1;
  top: var(--segmented-control-indicator-top);
  left: var(--segmented-control-indicator-left);
  width: var(--segmented-control-indicator-width);
  height: var(--segmented-control-indicator-height);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: top 0.18s ease, left 0.18s ease, width 0.18s ease, height 0.18s ease;
}

ui-segmented-control-indicator[data-activation-direction="none"] {
  transition: none;
}

ui-segmented-control-item {
  border-radius: 7px;
  padding: 7px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: color 0.14s ease;
}

ui-segmented-control-item[data-state="checked"] {
  color: var(--ink);
}

ui-segmented-control-item:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

ui-collapsible.video-embed {
  display: block;
}

ui-collapsible.video-embed[data-open] .video-expand-icon {
  transform: rotate(180deg);
}

.settings-group h3 span {
  color: var(--muted);
  font-weight: 400;
  font-size: 12.5px;
}

.settings-group input:not([type]),
.settings-group input[type="password"] {
  width: 100%;
  margin-bottom: 8px;
}

.settings-group code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

#connection-form .mode-picker {
  margin-bottom: 0;
}

.safety-code {
  margin: 4px 0 10px;
  font: 650 20px/1.2 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
