:root {
  color-scheme: light;
  --bg: #f2efe7;
  --bg-deep: #e8e4d9;
  --panel: #fffdf8;
  --panel-soft: #faf7f0;
  --ink: #14211c;
  --ink-soft: #34443d;
  --muted: #748079;
  --line: #e4dfd2;
  --line-strong: #d6d0c1;
  --side: #10231e;
  --side-soft: #17322b;
  --side-ink: #f5f2e9;
  --side-muted: #9eb0a8;
  --accent: #0e766e;
  --accent-dark: #095b55;
  --accent-soft: #e4f2ee;
  --lime: #b8f26a;
  --orange: #d97745;
  --danger: #ad3b30;
  --danger-soft: #fbeae6;
  --shadow-sm: 0 1px 2px rgb(20 33 28 / 4%), 0 10px 30px rgb(20 33 28 / 4%);
  --shadow-lg: 0 24px 70px rgb(16 35 30 / 16%);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button, input { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
::selection { background: var(--lime); color: var(--side); }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-button:hover { background: var(--bg); color: var(--ink); }
.icon-button:focus-visible,
.nav-item:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ---------- App shell ---------- */

.app-body { height: 100dvh; overflow: hidden; }
.app-shell { display: flex; height: 100dvh; }

.sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 276px;
  flex: 0 0 276px;
  padding: 26px 18px 18px;
  color: var(--side-ink);
  background:
    radial-gradient(circle at 10% 0%, rgb(184 242 106 / 9%), transparent 35%),
    radial-gradient(circle at 100% 85%, rgb(14 118 110 / 24%), transparent 42%),
    var(--side);
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}
.sidebar > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 6px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--lime);
  color: var(--side);
  box-shadow: inset 0 -2px 0 rgb(16 35 30 / 12%);
}
.brand-mark .icon { width: 23px; height: 23px; stroke-width: 2; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-family: var(--display); font-size: 22px; letter-spacing: -.04em; }
.brand-copy small { margin-top: 5px; font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--side-muted); }
.sidebar-close { display: none; margin-left: auto; color: var(--side-muted); }
.sidebar-close:hover { color: var(--side-ink); background: rgb(255 255 255 / 8%); }

.nav { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-top: 26px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 15%) transparent; }
.nav-label {
  margin: 0 10px 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: #7e938a;
}
.nav-label-spaced { margin-top: 28px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #c9d6d0;
  font-size: 14px;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-item .icon { width: 19px; height: 19px; opacity: .8; }
.nav-item:hover { background: rgb(255 255 255 / 6%); color: #fff; }
.nav-item.active {
  background: rgb(184 242 106 / 12%);
  color: var(--lime);
  box-shadow: inset 0 0 0 1px rgb(184 242 106 / 10%);
}
.nav-item.active .icon { opacity: 1; }
.nav-count {
  min-width: 23px;
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgb(255 255 255 / 6%);
  color: #9fb2a9;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.nav-item.active .nav-count { background: rgb(184 242 106 / 14%); color: var(--lime); }

.device-list { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 11px;
  min-width: 0;
}
.device-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 10px;
  background: rgb(255 255 255 / 4%);
  color: #a9bdb4;
}
.device-icon .icon { width: 16px; height: 16px; }
.device-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--side);
  border-radius: 50%;
  background: #718078;
}
.device-dot.online { background: var(--lime); box-shadow: 0 0 0 3px rgb(184 242 106 / 10%); }
.device-copy { display: flex; flex-direction: column; min-width: 0; }
.device-name { overflow: hidden; color: #dce6e1; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.device-status { margin-top: 1px; color: #7f938a; font-size: 10px; }
.device-empty { padding: 4px 8px 8px; color: #7f938a; font-size: 11.5px; line-height: 1.5; }
.device-skeleton { height: 45px; margin: 0 8px; border-radius: 10px; background: rgb(255 255 255 / 5%); animation: pulse 1.4s infinite; }

.sidebar-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / 8%); }
.privacy-card {
  display: flex;
  gap: 10px;
  margin: 0 4px 10px;
  padding: 12px;
  border: 1px solid rgb(184 242 106 / 12%);
  border-radius: 13px;
  background: rgb(184 242 106 / 5%);
  color: #aabbb3;
}
.privacy-card .icon { width: 17px; height: 17px; margin-top: 1px; color: var(--lime); }
.privacy-card strong { display: block; color: #dfe9e4; font-size: 11.5px; }
.privacy-card span { display: block; margin-top: 3px; font-size: 10.5px; line-height: 1.45; }
.logout-button { color: #94a79f; font-size: 12.5px; }

.main { display: flex; flex-direction: column; flex: 1; min-width: 0; height: 100dvh; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 88px;
  padding: 19px 32px 17px;
  border-bottom: 1px solid var(--line);
}
.mobile-menu { display: none; }
.page-heading { min-width: 0; }
.page-heading h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 730;
  letter-spacing: -.04em;
}
.page-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.alert-button { border-color: var(--line); background: var(--panel); }
.alert-button.enabled { border-color: rgb(14 118 110 / 22%); background: var(--accent-soft); color: var(--accent); }
.alert-button:disabled { opacity: .45; cursor: not-allowed; }
.live-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #9d9d92; }
.live-state[data-state="live"] { border-color: rgb(14 118 110 / 18%); color: var(--accent); }
.live-state[data-state="live"] .live-dot { background: var(--accent); box-shadow: 0 0 0 4px rgb(14 118 110 / 10%); animation: live-pulse 2.4s infinite; }
.live-state[data-state="offline"] { color: var(--danger); border-color: rgb(173 59 48 / 16%); background: var(--danger-soft); }
.live-state[data-state="offline"] .live-dot { background: var(--danger); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  padding: 20px 32px 0;
}
.stat-card {
  position: relative;
  min-width: 0;
  padding: 16px 18px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.stat-card::after {
  content: "";
  position: absolute;
  top: -28px;
  right: -22px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(14 118 110 / 8%), transparent 65%);
}
.stat-label { display: block; color: var(--muted); font-size: 10.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.stat-value {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 29px;
  font-weight: 740;
  line-height: 1;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}
.stat-note { display: block; margin-top: 6px; overflow: hidden; color: #97a09b; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.stat-devices .stat-value { color: var(--accent); }

.board {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  margin: 16px 32px 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.threads-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.list-toolbar { display: flex; gap: 8px; padding: 15px 14px 9px; }
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--muted);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.searchbox:focus-within { border-color: rgb(14 118 110 / 40%); background: var(--panel); box-shadow: 0 0 0 3px rgb(14 118 110 / 7%); }
.searchbox .icon { width: 17px; height: 17px; }
.searchbox input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}
.searchbox input::placeholder { color: #9ba49f; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 50%; background: var(--line); color: var(--ink-soft); cursor: pointer; }
.search-clear .icon { width: 13px; height: 13px; }
.refresh-button { border-color: var(--line); border-radius: 12px; background: var(--panel-soft); }
.refresh-button.loading .icon { animation: spin .8s linear infinite; }
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 18px 10px; color: var(--muted); font-size: 10.5px; }
.live-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.live-hint .icon { width: 12px; height: 12px; }

.thread-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.thread-list::-webkit-scrollbar, .message-list::-webkit-scrollbar, .nav::-webkit-scrollbar { width: 7px; }
.thread-list::-webkit-scrollbar-thumb, .message-list::-webkit-scrollbar-thumb, .nav::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--line-strong); }
.thread-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid #eeeae0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .13s ease;
}
.thread-item:hover { background: #faf8f2; }
.thread-item.selected { background: var(--accent-soft); }
.thread-item.selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  bottom: 13px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.thread-item.unread .thread-name { font-weight: 760; }
.thread-item.unread .thread-snippet { color: var(--ink-soft); font-weight: 550; }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.avatar-large { width: 44px; height: 44px; font-size: 13px; }
.avatar.c0 { background: #0e766e; }
.avatar.c1 { background: #b45a35; }
.avatar.c2 { background: #496c9a; }
.avatar.c3 { background: #7a5c93; }
.avatar.c4 { background: #a64c61; }
.avatar.c5 { background: #7f742f; }
.avatar.c6 { background: #32715a; }
.avatar.c7 { background: #5d675f; }
.thread-copy { min-width: 0; flex: 1; }
.thread-top { display: flex; align-items: baseline; gap: 8px; }
.thread-name { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 640; text-overflow: ellipsis; white-space: nowrap; }
.thread-time { flex: 0 0 auto; color: #939c97; font-size: 9.5px; font-weight: 550; }
.thread-snippet { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11.5px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.thread-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.unread-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 800; }
.type-pill { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; background: #f0ece2; color: #8a8376; font-size: 8.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.type-pill.sent { background: var(--accent-soft); color: var(--accent); }
.thread-divider { display: flex; align-items: center; gap: 8px; padding: 14px 18px 8px; color: #969f9a; font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.empty-list { display: flex; flex-direction: column; align-items: center; padding: 42px 26px; text-align: center; }
.empty-list-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.empty-list h3 { margin: 13px 0 5px; font-size: 14px; letter-spacing: -.02em; }
.empty-list p { max-width: 245px; margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }

.search-result {
  display: block;
  width: 100%;
  padding: 13px 17px;
  border: 0;
  border-bottom: 1px solid #eeeae0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.search-result:hover { background: #faf8f2; }
.search-result-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.search-result-address { overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.search-result-time { flex: 0 0 auto; color: #939c97; font-size: 9.5px; }
.search-result-body { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.thread-skeletons { padding-top: 4px; }
.thread-skeleton { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #f1eee7; }
.thread-skeleton > span { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; background: #f0ece2; animation: pulse 1.4s infinite; }
.thread-skeleton > div { flex: 1; }
.thread-skeleton i { display: block; width: 58%; height: 9px; margin: 3px 0 9px; border-radius: 99px; background: #f0ece2; animation: pulse 1.4s infinite; }
.thread-skeleton i + i { width: 82%; height: 8px; margin: 0; opacity: .7; animation-delay: .15s; }

/* ---------- Conversation ---------- */

.conversation-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.conversation-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 36%, rgb(14 118 110 / 5%), transparent 36%),
    linear-gradient(160deg, #fffdf8, #f7f4ec);
}
.empty-illustration { position: relative; display: grid; place-items: center; width: 126px; height: 126px; margin-bottom: 18px; }
.empty-illustration > .icon { width: 58px; height: 58px; color: var(--accent); stroke-width: 1.2; }
.empty-bubble { position: absolute; border-radius: 50%; }
.bubble-one { width: 100%; height: 100%; border: 1px dashed rgb(14 118 110 / 20%); animation: drift 18s linear infinite; }
.bubble-two { width: 72%; height: 72%; border: 1px solid rgb(14 118 110 / 10%); background: rgb(255 255 255 / 40%); }
.conversation-empty h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: -.035em; }
.conversation-empty p { max-width: 370px; margin: 9px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.empty-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 20px; }
.empty-badges span { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgb(255 255 255 / 70%); color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .03em; }
.empty-badges .icon { width: 12px; height: 12px; color: var(--accent); }

.conversation { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.conversation-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 253 248 / 92%);
  backdrop-filter: blur(12px);
}
.conversation-title { min-width: 0; flex: 1; }
.conversation-title h2 { margin: 0; overflow: hidden; font-family: var(--display); font-size: 16px; font-weight: 720; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title p { margin: 3px 0 0; overflow: hidden; color: var(--muted); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.back-button { display: none; margin-left: -5px; }
.readonly-pill { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: var(--panel-soft); color: #8b918c; font-size: 9.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.readonly-pill .icon { width: 12px; height: 12px; }

.message-list {
  flex: 1;
  min-height: 0;
  padding: 22px 24px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 100% 0%, rgb(14 118 110 / 3%), transparent 35%),
    var(--panel);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.date-sep { display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; color: #939c97; font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.date-sep::before, .date-sep::after { content: ""; height: 1px; flex: 1; background: #eeeae0; }
.message-row { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 11px; animation: rise .2s ease-out both; }
.message-row.out { align-items: flex-end; }
.sender-line { margin: 0 0 4px 9px; color: #9aa39e; font-size: 9.5px; font-weight: 600; }
.bubble {
  position: relative;
  max-width: min(76%, 600px);
  padding: 10px 13px 7px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  background: #fbf8f1;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.52;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgb(20 33 28 / 2%);
}
.message-row.out .bubble {
  border-color: transparent;
  border-radius: 16px 4px 16px 16px;
  background: var(--accent);
  color: #f5fffc;
  box-shadow: 0 4px 12px rgb(14 118 110 / 12%);
}
.bubble-time { display: block; margin-top: 5px; color: #9da6a1; font-size: 9px; line-height: 1; text-align: right; white-space: nowrap; }
.message-row.out .bubble-time { color: rgb(236 255 250 / 60%); }
.bubble-state { display: inline-flex; align-items: center; gap: 3px; margin-right: 4px; color: rgb(236 255 250 / 72%); font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.message-row.draft .bubble, .message-row.failed .bubble { border-color: rgb(217 119 69 / 28%); background: #fff5ed; color: #744329; }
.message-row.failed .bubble { border-color: rgb(173 59 48 / 22%); background: var(--danger-soft); color: #6f2b23; }
.load-older-wrap { display: flex; justify-content: center; padding: 4px 0 16px; }
.load-older { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--muted); font-size: 10px; font-weight: 650; cursor: pointer; }
.load-older:hover { border-color: var(--line-strong); color: var(--ink); }
.load-older:disabled { opacity: .55; cursor: default; }
.conversation-foot { display: flex; align-items: center; gap: 7px; padding: 11px 22px; border-top: 1px solid var(--line); background: #fdfbf5; color: #98a19c; font-size: 9.5px; }
.conversation-foot .icon { width: 13px; height: 13px; color: var(--accent); }
.message-list-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 12px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 15px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 13px;
  background: var(--side);
  color: #eef4f0;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 18px 45px rgb(16 35 30 / 24%);
  animation: toast-in .2s ease-out;
}
.toast strong { color: var(--lime); font-weight: 700; }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(8 20 16 / 48%); backdrop-filter: blur(2px); }

/* ---------- Login ---------- */

.login-body { min-height: 100dvh; background: var(--bg); }
.login-shell { display: grid; grid-template-columns: minmax(420px, 1.05fr) minmax(440px, .95fr); min-height: 100dvh; }
.login-story {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 42px clamp(36px, 5vw, 76px);
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 12%, rgb(184 242 106 / 15%), transparent 30%),
    radial-gradient(circle at 12% 92%, rgb(14 118 110 / 34%), transparent 38%),
    var(--side);
  color: var(--side-ink);
}
.login-story::before {
  content: "";
  position: absolute;
  width: 540px;
  height: 540px;
  right: -220px;
  bottom: -230px;
  border: 1px solid rgb(184 242 106 / 15%);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgb(184 242 106 / 3%), 0 0 0 160px rgb(184 242 106 / 2%);
}
.login-story::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .14;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}
.login-story > * { position: relative; z-index: 1; }
.brand-light .brand-copy strong { color: #fff; }
.story-copy { max-width: 530px; margin: auto 0; padding: 64px 0 44px; }
.eyebrow { margin: 0 0 14px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .19em; text-transform: uppercase; }
.login-story .eyebrow { color: var(--lime); }
.story-copy h1 { margin: 0; font-family: var(--display); font-size: clamp(38px, 4.4vw, 64px); font-weight: 680; line-height: 1.02; letter-spacing: -.055em; }
.story-copy h1 em { color: var(--lime); font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.035em; }
.story-lede { max-width: 430px; margin: 22px 0 0; color: #aebfb7; font-size: 14px; line-height: 1.68; }
.story-points { display: flex; flex-direction: column; gap: 17px; margin: 38px 0 0; padding: 0; list-style: none; }
.story-points li { display: flex; gap: 13px; }
.point-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border: 1px solid rgb(184 242 106 / 13%); border-radius: 10px; background: rgb(184 242 106 / 7%); color: var(--lime); }
.point-icon .icon { width: 17px; height: 17px; }
.story-points strong { display: block; margin-bottom: 3px; color: #eef5f1; font-size: 12px; font-weight: 680; }
.story-points span { color: #93a79e; font-size: 11px; line-height: 1.5; }
.story-foot { margin: 0; color: #6f877c; font-size: 10px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 36px clamp(24px, 5vw, 80px); background: var(--bg); }
.login-card { width: 100%; max-width: 410px; padding: 38px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-lg); }
.login-mobile-brand { display: none; align-items: center; gap: 9px; margin-bottom: 28px; }
.login-card h2 { margin: 0; font-family: var(--display); font-size: 27px; font-weight: 720; letter-spacing: -.045em; }
.login-sub { margin: 9px 0 28px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.login-sub code { padding: 2px 5px; border-radius: 4px; background: var(--bg); color: var(--ink-soft); font-family: "Cascadia Code", Consolas, monospace; font-size: 10.5px; }
.field-label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 10.5px; font-weight: 750; letter-spacing: .02em; }
.password-wrap { position: relative; }
.password-wrap input {
  width: 100%;
  height: 47px;
  padding: 0 47px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.password-wrap input:focus { border-color: rgb(14 118 110 / 50%); background: #fff; box-shadow: 0 0 0 3px rgb(14 118 110 / 8%); }
.password-wrap input::placeholder { color: #a7aea9; }
.password-toggle { position: absolute; top: 3px; right: 4px; display: grid; place-items: center; width: 41px; height: 41px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--ink); background: var(--bg); }
.password-toggle .icon { width: 17px; height: 17px; }
.form-error { margin: 10px 0 0; padding: 9px 11px; border: 1px solid rgb(173 59 48 / 15%); border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 11px; line-height: 1.45; }
.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 47px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(14 118 110 / 14%);
  transition: background .15s ease, transform .15s ease;
}
.primary-button:hover { background: var(--accent-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.primary-button .icon { width: 16px; height: 16px; transform: rotate(180deg); }
.login-submit { margin-top: 20px; }
.login-security { display: flex; gap: 8px; margin-top: 23px; padding-top: 17px; border-top: 1px solid var(--line); color: #919a95; font-size: 9.5px; line-height: 1.55; }
.login-security .icon { width: 14px; height: 14px; margin-top: 1px; color: var(--accent); }
.login-foot { max-width: 410px; margin: 20px auto 0; color: #969f9a; font-size: 9.5px; line-height: 1.55; text-align: center; }

/* ---------- Motion ---------- */

@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 4px rgb(14 118 110 / 10%); } 50% { box-shadow: 0 0 0 6px rgb(14 118 110 / 4%); } }
@keyframes pulse { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes drift { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .board { grid-template-columns: minmax(300px, 345px) minmax(0, 1fr); }
  .topbar, .stats { padding-left: 24px; padding-right: 24px; }
  .board { margin-left: 24px; margin-right: 24px; }
  .stat-note { font-size: 10px; }
}

@media (max-width: 980px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 286px; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app-shell.sidebar-open .sidebar { transform: none; }
  .sidebar-close { display: inline-grid; }
  .mobile-menu { display: inline-grid; border-color: var(--line); background: var(--panel); }
  .main { width: 100%; }
  .topbar { min-height: 78px; padding: 13px 20px; }
  .stats { padding: 16px 20px 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { margin: 14px 20px 20px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-mobile-brand { display: flex; }
  .login-panel { background: radial-gradient(circle at 50% 0%, rgb(14 118 110 / 7%), transparent 40%), var(--bg); }
}

@media (max-width: 760px) {
  .app-body { overflow: hidden; }
  .main { height: 100dvh; }
  .topbar { gap: 10px; padding: 11px 14px; min-height: 68px; }
  .page-heading h1 { font-size: 17px; }
  .page-heading p { display: none; }
  .top-actions { gap: 7px; }
  .live-state { height: 29px; padding: 0 9px; }
  .live-label { font-size: 10px; }
  .alert-button { width: 38px; height: 38px; }
  .mobile-menu { width: 38px; height: 38px; }
  .stats { gap: 8px; padding: 12px 14px 0; }
  .stat-card { padding: 11px 12px 10px; border-radius: 14px; }
  .stat-label { font-size: 8.5px; letter-spacing: .06em; }
  .stat-value { margin-top: 5px; font-size: 22px; }
  .stat-note { margin-top: 4px; font-size: 8.5px; }
  .board { position: relative; margin: 10px 14px 14px; border-radius: 19px; grid-template-columns: 1fr; }
  body.conversation-open .stats { display: none; }
  body.conversation-open .board { flex: 1; margin-top: 10px; }
  .threads-pane { border: 0; }
  .conversation-pane { display: none; }
  .conversation-pane.open {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    background: var(--panel);
    animation: slide-in .18s ease-out;
  }
  .back-button { display: inline-grid; }
  .conversation-head { min-height: 66px; padding: 10px 13px; gap: 9px; }
  .conversation-title h2 { font-size: 14px; }
  .readonly-pill { display: none; }
  .avatar-large { width: 37px; height: 37px; font-size: 11px; }
  .message-list { padding: 14px 12px 8px; }
  .bubble { max-width: 86%; font-size: 13px; }
  .conversation-foot { padding: 9px 13px; font-size: 8.5px; }
  .list-toolbar { padding: 11px 10px 7px; }
  .thread-item { padding: 11px 12px; }
  .thread-snippet { font-size: 11px; }
  .list-meta { padding: 2px 13px 8px; }
  .toast { right: 14px; bottom: 14px; left: 14px; max-width: none; }
  .searchbox { height: 40px; }
  .login-panel { padding: 20px; }
  .login-card { padding: 24px 21px; border-radius: 20px; }
}

@media (max-width: 380px) {
  .stat-note { display: none; }
  .stat-card { min-height: 68px; }
  .page-heading h1 { font-size: 15px; }
  .login-card { padding: 22px 17px; }
}

@keyframes slide-in { from { opacity: .5; transform: translateX(22px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
