:root {
  color-scheme: light;
  --surface: #fff;
  --canvas: #f8f7f5;
  --chat: #f3f0ed;
  --text: #251e1b;
  --muted: #6d625d;
  --border: #e8e0db;
  --accent: #a93d23;
  --on-accent: #fff;
  --tint: #fce9e0;
  --own: #fae2d6;
  --danger: #9c3026;
  --focus: #a93d23;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
  font-synthesis: none;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --surface: #211c1a; --canvas: #181513; --chat: #1c1816; --text: #f5eae5;
  --muted: #c6b4aa; --border: #3f3530; --accent: #ffa488; --on-accent: #33130b;
  --tint: #443026; --own: #4c2e22; --danger: #ff9a8d; --focus: #ffa488;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='system'] {
    color-scheme: dark;
    --surface: #211c1a; --canvas: #181513; --chat: #1c1816; --text: #f5eae5;
    --muted: #c6b4aa; --border: #3f3530; --accent: #ffa488; --on-accent: #33130b;
    --tint: #443026; --own: #4c2e22; --danger: #ff9a8d; --focus: #ffa488;
  }
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; padding: 8px 12px; cursor: pointer; }
button:hover { background: var(--tint); }
button:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, a { touch-action: manipulation; }
a { color: var(--accent); overflow-wrap: anywhere; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.8rem; letter-spacing: -.035em; line-height: 1.15; }
h2 { font-size: 1.25rem; overflow-wrap: anywhere; }
h3 { font-size: 1.1rem; overflow-wrap: anywhere; }
form { display: grid; gap: 14px; }
form > .primary { justify-self: start; }
input:not([type='checkbox']), textarea, select {
  width: 100%; background: var(--canvas); border: 1px solid var(--border); border-radius: 12px;
  min-height: 44px; padding: 9px 12px; min-width: 0;
}
textarea { resize: vertical; }
input[type='checkbox'] { margin: 0; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
small { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.48; }
.primary, .accent { background: var(--accent); color: var(--on-accent); font-weight: 650; }
.primary:hover, .accent:hover { background: var(--accent); filter: brightness(.94); }
.secondary { background: var(--tint); color: var(--text); font-weight: 600; }
.danger { color: var(--danger); font-weight: 650; }
.icon { display: inline-grid; place-items: center; flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; font-size: 1.45rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.brand { display: flex; gap: 11px; align-items: center; }
.brand strong { font-size: 1.35rem; letter-spacing: -.05em; }
.field { display: grid; gap: 7px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.field input, .field select, .field textarea { font-weight: 400; }
.check { display: flex; gap: 9px; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.auth-card { width: min(100%, 430px); display: grid; gap: 22px; background: var(--surface); padding: clamp(20px, 6vw, 38px); border: 1px solid var(--border); border-radius: 24px; }
.auth-card p { line-height: 1.5; }
.workspace { display: grid; grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); height: 100dvh; }
.sidebar { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-top { min-height: 68px; display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.side-body { display: flex; flex-direction: column; gap: 12px; overflow: auto; padding: 20px 12px; }
.side-body > input { width: calc(100% - 16px); margin-inline: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-body .section-head { padding: 3px 8px; }
.group-list { display: grid; gap: 4px; min-width: 0; }
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 15px; background: #f1d9eb; color: #592b54; font-weight: 750; }
.avatar[data-tone='1'] { background: #f3dcd0; color: #6e3223; }
.avatar[data-tone='2'] { background: #dce6e0; color: #295249; }
.avatar[data-tone='3'] { background: #dde2f2; color: #303e65; }
.avatar.small { width: 32px; height: 32px; border-radius: 11px; font-size: .75rem; }
.group-row { width: 100%; display: flex; align-items: center; min-height: 68px; text-align: start; gap: 11px; }
.group-row.active { background: var(--tint); }
.row-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.row-copy strong, .row-copy small, .chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-copy small, .chat-title small { color: var(--muted); }
.chevron { color: var(--muted); font-size: 1.15rem; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 4px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.tabs button { display: grid; justify-items: center; gap: 3px; color: var(--muted); font-size: .68rem; padding: 5px 1px; overflow-wrap: anywhere; }
.tabs button span { font-size: 1.15rem; line-height: 1; }
.tabs .selected { color: var(--accent); background: var(--tint); }
.main-view { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.placeholder { flex: 1; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 16px; text-align: center; }
.page { width: min(100%, 750px); margin: 0 auto; padding: clamp(16px, 4vw, 42px); display: grid; gap: 18px; }
.profile { justify-items: start; }
.profile form, .profile .field { width: min(100%, 410px); }
.account-id { overflow-wrap: anywhere; font-size: .78rem; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }
.chat-head { background: var(--surface); display: flex; align-items: center; padding: 7px 12px; min-height: 68px; border-bottom: 1px solid var(--border); gap: 5px; flex: none; }
.chat-title { flex: 1; display: flex; align-items: center; text-align: start; gap: 10px; min-width: 0; padding: 4px; }
.chat-title span:last-child { display: grid; gap: 3px; min-width: 0; }
.mobile-back { display: none; }
.chat-scroll { background: var(--chat); padding: 14px clamp(10px, 4vw, 44px); overflow: auto; min-height: 0; flex: 1; overscroll-behavior: contain; display: flex; flex-direction: column; }
.messages { display: grid; gap: 10px; margin: auto auto 0; width: min(100%, 810px); }
.earlier { align-self: center; margin-bottom: 14px; }
.message { display: flex; gap: 6px; align-items: end; min-width: 0; }
.message.own { justify-content: flex-end; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 0 10px 6px; max-width: min(85%, 560px); min-width: 100px; }
.own .bubble { background: var(--own); border-radius: 14px 14px 4px 14px; }
.bubble-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; color: var(--accent); }
.bubble-top strong { overflow-wrap: anywhere; }
.bubble-top .icon { margin-right: -10px; font-size: 1.12rem; }
.bubble-meta { margin-top: 4px; color: var(--muted); font-size: .71rem; text-align: right; }
.bubble blockquote { border-inline-start: 3px solid var(--accent); margin: 0 0 7px; padding: 4px 8px; background: var(--canvas); border-radius: 5px; overflow-wrap: anywhere; }
.bubble blockquote strong { display: block; font-size: .76rem; }
.bubble img, .bubble video, .bubble audio { max-width: 100%; display: block; border-radius: 8px; }
.audio { display: flex; flex-wrap: wrap; gap: 6px; }
.audio select { width: auto; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; }
.reactions button { background: var(--canvas); }
.reactions button.selected { background: var(--tint); }
.activity-link { color: var(--accent); padding: 5px 0; text-align: start; font-weight: 700; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 6px 9px max(8px, env(safe-area-inset-bottom)); flex: none; }
.compose-row { display: flex; align-items: flex-end; gap: 4px; max-width: 810px; margin: auto; }
.compose-row textarea { min-height: 44px; max-height: 125px; resize: vertical; }
.recording { color: var(--danger); background: var(--tint); }
.reply-bar { max-width: 810px; margin: 0 auto 5px; display: flex; align-items: center; justify-content: space-between; color: var(--accent); gap: 8px; }
.reply-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog { width: min(520px, calc(100% - 24px)); max-height: min(85dvh, 760px); padding: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 14px 60px #0003; }
dialog::backdrop { background: #17111088; }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface); padding: 8px 14px 8px 18px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 16px 18px; display: grid; gap: 12px; }
.dialog-error { color: var(--danger); padding: 9px; border: 1px solid var(--border); border-radius: 10px; }
.group-hero { display: flex; align-items: center; gap: 10px; }
.menu-row { text-align: start; border-bottom: 1px solid var(--border); border-radius: 0; }
.member-line { display: flex; gap: 10px; align-items: center; }
.member-line div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card, .activity-card { border: 1px solid var(--border); background: var(--canvas); border-radius: 14px; padding: 13px; display: grid; gap: 7px; overflow-wrap: anywhere; text-align: start; }
.activities, .filter-results { display: grid; gap: 9px; }
.pill { padding: 5px 10px; background: var(--tint); border-radius: 18px; font-size: .82rem; }
.countdown { font-weight: 750; color: var(--accent); }
.result div { display: flex; justify-content: space-between; gap: 8px; }
progress { width: 100%; accent-color: var(--accent); }
#notice:not(:empty) { position: fixed; z-index: 5; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 20px); background: var(--text); color: var(--surface); border-radius: 12px; padding: 10px 15px; box-shadow: 0 4px 18px #0003; }
@media (max-width: 700px) {
  .workspace { display: flex; flex-direction: column; }
  .sidebar { display: contents; }
  .sidebar-top { order: 0; min-height: 62px; background: var(--surface); padding-top: max(9px, env(safe-area-inset-top)); }
  .side-body { order: 1; flex: 1; background: var(--surface); }
  .tabs { order: 2; }
  .main-view { display: none; order: 1; flex: 1; }
  .page-open .side-body, .has-chat .sidebar-top, .has-chat .side-body, .has-chat .tabs { display: none; }
  .page-open .main-view, .has-chat .main-view { display: flex; }
  .mobile-back { display: inline-grid; }
  .chat-head { padding-inline: 4px; padding-top: max(7px, env(safe-area-inset-top)); }
  .bubble { max-width: 88%; }
  dialog { max-height: 87dvh; margin: auto auto 0; width: 100%; border-radius: 20px 20px 0 0; }
  .dialog-body { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}
