:root {
  --ink: #f4efe5;
  --muted: #9e998f;
  --faint: #656159;
  --bg: #0d0c0b;
  --panel: #151412;
  --panel-raised: #1b1917;
  --line: rgba(244, 239, 229, 0.1);
  --amber: #e9a84c;
  --amber-deep: #8a5827;
  --mint: #87c9ad;
  --violet: #a99bd7;
  --danger: #e08072;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(233, 168, 76, 0.11), transparent 34rem),
    radial-gradient(circle at 100% 80%, rgba(135, 201, 173, 0.06), transparent 30rem),
    var(--bg);
  overflow-x: hidden;
}

button, textarea, select, input { font: inherit; }
button { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' 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='.12'/%3E%3C/svg%3E");
}

.shell { width: min(1480px, 100%); margin: 0 auto; padding: 20px 28px 28px; }

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 16px; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; margin: 1px 0 0; letter-spacing: 0.01em; }
.eyebrow, .section-label { color: var(--amber); font-size: 10px; font-weight: 700; letter-spacing: 0.19em; margin: 0; }

.brand-mark { width: 43px; height: 43px; position: relative; display: grid; place-items: center; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; border: 1px solid rgba(233, 168, 76, 0.7); border-radius: 50%; }
.brand-mark::before { width: 34px; height: 34px; }
.brand-mark::after { width: 20px; height: 20px; border-color: rgba(233, 168, 76, 0.35); }
.brand-mark span { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px rgba(233, 168, 76, 0.7); }
.brand-mark span:nth-child(1) { transform: translate(-17px, 5px); }
.brand-mark span:nth-child(2) { transform: translate(14px, 10px); background: var(--mint); }
.brand-mark span:nth-child(3) { transform: translate(2px, -18px); background: var(--violet); }

.status-cluster { display: flex; gap: 9px; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; background: rgba(21, 20, 18, 0.72); }
.status-dot, .presence { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px rgba(135, 201, 173, 0.55); }
.status-pill.offline .status-dot { background: var(--faint); box-shadow: none; }

.room { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - 131px); }
.participants { padding: 34px 26px 20px 0; border-right: 1px solid var(--line); }
.participants > .section-label { margin-bottom: 15px; }

.participant { position: relative; display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(27, 25, 23, 0.55); }
.participant h2 { font-size: 13px; font-weight: 650; margin: 0 0 4px; }
.participant p { color: var(--faint); font-size: 10px; margin: 0; }
.participant .presence { position: absolute; top: 13px; right: 13px; width: 6px; height: 6px; }
.avatar, .mini-avatar { display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; font-family: Georgia, serif; font-size: 16px; }
.avatar { width: 38px; height: 38px; }
.avatar-openclaw { color: #18130d; background: linear-gradient(135deg, #f0bc68, #bc722f); }
.avatar-hermes { color: #101411; background: linear-gradient(135deg, #a4d9c1, #578e78); }

.room-note { display: flex; gap: 10px; margin-top: 23px; padding: 14px 5px; border-top: 1px solid var(--line); color: var(--faint); }
.room-note p { font-size: 11px; line-height: 1.6; margin: 0; }
.note-icon { color: var(--amber); font-size: 18px; }

.conversation { min-width: 0; display: flex; flex-direction: column; height: calc(100vh - 102px); padding: 27px 0 0 31px; }
.conversation-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding-right: 4px; }
.conversation-actions { display: flex; align-items: center; gap: 8px; }
.conversation-subtitle { color: var(--faint); font-size: 11px; margin: 7px 0 0; }

.quiet-button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 11px; cursor: pointer; }
.quiet-button.danger { color: var(--danger); border-color: rgba(224, 128, 114, 0.22); }
.quiet-button:hover { background: rgba(255,255,255,0.04); }

.messages { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 28px max(4vw, 38px) 20px; scrollbar-color: #39352f transparent; }
.empty-state { height: 100%; min-height: 260px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-family: Georgia, serif; font-size: 25px; font-weight: 400; margin: 18px 0 8px; }
.empty-state p { max-width: 430px; font-size: 12px; line-height: 1.7; margin: 0; }
.empty-orbit { width: 72px; height: 72px; border: 1px solid rgba(233, 168, 76, 0.23); border-radius: 50%; position: relative; animation: rotate 18s linear infinite; }
.empty-orbit::after { content: ""; position: absolute; inset: 16px; border: 1px solid rgba(135, 201, 173, 0.2); border-radius: 50%; }
.empty-orbit i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); top: -4px; left: 31px; }
.empty-orbit i:nth-child(2) { background: var(--mint); top: 54px; left: 5px; }
.empty-orbit i:nth-child(3) { background: var(--violet); top: 49px; left: 59px; }
@keyframes rotate { to { transform: rotate(360deg); } }

.message { display: grid; grid-template-columns: 34px minmax(0, 760px); gap: 12px; margin: 0 auto 20px; max-width: 900px; animation: message-in 220ms ease-out; }
.message.user { grid-template-columns: minmax(0, 760px) 34px; justify-content: end; }
.message.user .message-avatar { grid-column: 2; grid-row: 1; background: #34312c; color: var(--ink); }
.message.user .message-body { grid-column: 1; grid-row: 1; align-items: flex-end; }
.message-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-family: Georgia, serif; font-size: 13px; background: linear-gradient(135deg, #f0bc68, #9d5e28); color: #17100a; }
.message.hermes .message-avatar { background: linear-gradient(135deg, #a4d9c1, #4d7d6b); color: #0c1511; }
.message.system .message-avatar { background: #302d29; color: var(--muted); }
.message-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.message-meta { display: flex; align-items: center; gap: 8px; font-size: 10px; margin: 1px 3px 7px; }
.message-author { color: var(--muted); font-weight: 650; }
.message-time { color: var(--faint); }
.message-bubble { max-width: 100%; padding: 12px 15px; border: 1px solid var(--line); border-radius: 4px 15px 15px; color: #ded9cf; background: rgba(27, 25, 23, 0.92); font-size: 13px; line-height: 1.68; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.hermes .message-bubble { border-color: rgba(135, 201, 173, 0.14); }
.message.user .message-bubble { border-radius: 15px 4px 15px 15px; color: #1d160d; background: linear-gradient(135deg, #e9aa50, #c8873d); border: none; }
.message.system .message-bubble { color: var(--muted); font-size: 11px; border-style: dashed; background: transparent; }
@keyframes message-in { from { opacity: 0; transform: translateY(6px); } }

.typing-card { display: grid; grid-template-columns: 29px 1fr auto; align-items: center; gap: 10px; margin: 0 max(4vw, 38px) 10px; padding: 9px 12px; border-left: 2px solid var(--amber); color: var(--muted); background: rgba(233, 168, 76, 0.045); font-size: 11px; }
.typing-card[hidden] { display: none; }
.typing-card small { color: var(--faint); }
.mini-avatar { width: 28px; height: 28px; color: #17100a; background: var(--amber); font-size: 11px; }
.typing-dots { display: inline-flex; gap: 3px; margin-left: 8px; }
.typing-dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--amber); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 140ms; }
.typing-dots i:nth-child(3) { animation-delay: 280ms; }
@keyframes bounce { 50% { opacity: 0.25; transform: translateY(-3px); } }

.composer { border-top: 1px solid var(--line); padding: 13px 4px 4px; }
.composer-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.segmented { display: flex; gap: 3px; margin: 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 6px 10px; color: var(--faint); border-radius: 999px; font-size: 10px; cursor: pointer; }
.segmented input:checked + span { color: var(--ink); background: #2a2722; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04); }
.round-picker { display: flex; align-items: center; gap: 7px; color: var(--faint); font-size: 10px; }
.round-picker input { width: 68px; color: var(--muted); background: #1c1a17; border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; outline: none; }
.input-wrap { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; min-height: 58px; padding: 8px 8px 8px 15px; border: 1px solid rgba(244, 239, 229, 0.15); border-radius: 15px; background: var(--panel-raised); box-shadow: 0 14px 50px rgba(0,0,0,0.18); }
.input-wrap:focus-within { border-color: rgba(233, 168, 76, 0.38); box-shadow: 0 0 0 3px rgba(233, 168, 76, 0.05); }
textarea { width: 100%; max-height: 140px; resize: none; border: 0; outline: 0; padding: 10px 0; color: var(--ink); background: transparent; font-size: 13px; line-height: 1.45; }
textarea::placeholder { color: #5d5952; }
.send-button { display: flex; align-items: center; gap: 10px; border: 0; border-radius: 10px; padding: 10px 12px 10px 14px; color: #1a1209; background: var(--amber); font-size: 11px; font-weight: 700; cursor: pointer; }
.send-button:hover { background: #f1b660; }
.send-button:disabled { opacity: 0.35; cursor: not-allowed; }
.send-arrow { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 7px; background: rgba(27,17,6,0.13); font-size: 14px; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; min-height: 29px; color: #57534c; font-size: 9px; }
.continue-button { color: var(--amber); border: 0; background: none; font-size: 10px; cursor: pointer; }
.continue-button:disabled { color: #4c4943; cursor: not-allowed; }

.auth-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(7,7,6,0.83); backdrop-filter: blur(14px); }
.auth-backdrop[hidden] { display: none; }
.auth-card { width: min(390px, 100%); display: flex; flex-direction: column; align-items: stretch; padding: 34px; border: 1px solid rgba(233, 168, 76, 0.2); border-radius: 20px; background: #171512; box-shadow: 0 30px 90px #000; text-align: center; }
.auth-symbol { color: var(--amber); font-family: Georgia, serif; font-size: 35px; }
.auth-card .eyebrow { margin-top: 12px; }
.auth-card h2 { font-family: Georgia, serif; font-weight: 400; margin: 7px 0 8px; }
.auth-card p:not(.eyebrow) { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0 0 20px; }
.auth-card input { width: 100%; color: var(--ink); background: #0f0e0c; border: 1px solid var(--line); border-radius: 10px; outline: 0; padding: 12px; margin-bottom: 10px; }
.auth-card .send-button { justify-content: center; }
.settings-field { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; text-align: left; }
.settings-field input { margin-bottom: 8px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translateX(-50%); padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #29251f; box-shadow: 0 8px 30px #000; color: var(--ink); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .shell { padding: 12px 14px 18px; }
  .topbar { height: 68px; }
  .brand h1 { font-size: 20px; }
  .brand-mark { width: 34px; height: 34px; transform: scale(0.82); }
  .status-pill:first-child { display: none; }
  .room { grid-template-columns: 1fr; min-height: calc(100vh - 80px); }
  .participants { display: none; }
  .conversation { height: calc(100vh - 80px); padding: 18px 0 0; }
  .messages { padding: 22px 3px 14px; }
  .typing-card { margin-inline: 3px; }
  .conversation-head { padding-inline: 4px; }
  .composer-toolbar { align-items: flex-end; gap: 8px; }
  .segmented span { padding-inline: 8px; }
  .round-picker { flex-direction: column; align-items: flex-end; gap: 3px; }
  .composer-foot > span { display: none; }
  .composer-foot { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
