:root {
  color-scheme: dark;
  --bg: #06100e;
  --panel: #0a1715;
  --panel-2: #0e1e1b;
  --line: #203b35;
  --line-soft: #142b27;
  --text: #f5fbf9;
  --muted: #8fa8a2;
  --mint: #67e3bc;
  --mint-strong: #8cf5d0;
  --mint-dark: #123e34;
  --amber: #ffc35b;
  --danger: #ff7d7d;
  --shadow: 0 24px 70px #0009;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.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; }
.muted { color: var(--muted); line-height: 1.5; }
.eyebrow, .section-label { color: var(--mint); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand img { border-radius: 50%; filter: drop-shadow(0 0 12px #41e6b855); }
.brand div { display: flex; align-items: baseline; gap: 6px; letter-spacing: .12em; }
.brand strong { font-size: 1rem; }
.brand span { color: var(--mint); font-size: .62rem; font-weight: 900; }
.brand--large { justify-content: center; }
.brand--large strong { font-size: 1.35rem; }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 20%, #17483b 0, #081512 36%, #040908 78%); overflow: auto; }
.auth-card { width: min(460px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 28px; background: #091714f2; box-shadow: var(--shadow); }
.auth-card h1 { margin: 6px 0 8px; font-size: clamp(1.8rem, 7vw, 2.45rem); }
.auth-card > .eyebrow { margin: 28px 0 0; }
.windows-download { display: grid; gap: 15px; margin-top: 24px; padding: 18px; border: 1px solid #2d6656; border-radius: 16px; background: linear-gradient(135deg, #0e2922, #091714); }
.windows-download .eyebrow { margin: 0; }
.windows-download h2 { margin: 3px 0 6px; font-size: 1.05rem; }
.windows-download p:last-child { margin: 0; font-size: .76rem; line-height: 1.45; }
.windows-download__button { display: grid; place-items: center; text-decoration: none; }
.windows-download__button[aria-disabled="true"] { pointer-events: none; opacity: .55; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #c8d7d3; font-size: .84rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #06110f; color: var(--text); outline: none; }
input, select { min-height: 46px; padding: 0 13px; }
textarea { padding: 12px 14px; resize: none; }
input:focus, textarea:focus, select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px #67e3bc24; }
.primary, .quiet, .danger-outline { min-height: 44px; border: 1px solid transparent; border-radius: 12px; padding: 0 18px; cursor: pointer; font-weight: 800; }
.primary { background: var(--mint); color: #062019; }
.primary:hover { background: var(--mint-strong); }
.primary.compact { min-height: 38px; }
.quiet { border-color: var(--line); background: #0b1917; }
.danger-outline { border-color: #7e3939; background: #241314; color: #ffb0b0; }
.wide { width: 100%; }
.form-status { min-height: 1.4em; color: var(--amber); }
.vault-owner { padding: 12px; border-radius: 12px; background: var(--mint-dark); color: var(--mint-strong); }
.lab-warning { margin: 20px 0 0; padding: 12px; border: 1px solid #5a4828; border-radius: 12px; color: #f0ca85; background: #1e1a0f; font-size: .75rem; line-height: 1.45; }

.app-shell { width: 100%; height: 100dvh; display: grid; grid-template: 64px minmax(0, 1fr) / 72px 304px minmax(0, 1fr); background-image: radial-gradient(#17312b44 1px, transparent 1px); background-size: 22px 22px; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; min-width: 0; padding: 0 18px; border-bottom: 1px solid var(--line); background: #07120fff; z-index: 10; }
.info-ticker { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 9px; color: #b7cbc5; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 9px var(--mint); }
.transport-pill { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; color: #b8cbc6; font-size: .74rem; white-space: nowrap; }
.transport-pill output { color: var(--mint); font-variant-numeric: tabular-nums; }
.traffic-light { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px #ffc35b88; }
.traffic-light[data-state="online"] { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.traffic-light[data-state="offline"] { background: #ff6f6f; box-shadow: 0 0 8px #ff6f6faa; }
.icon-button, .composer-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 13px; background: #0b1917; cursor: pointer; }
.icon-button:hover, .composer-icon:hover { border-color: #3e6c60; background: #10241f; }
.icon-button svg, .composer-icon svg { width: 20px; height: 20px; fill: #b9cec8; }

.space-rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; border-right: 1px solid var(--line); background: #050d0b; overflow-y: auto; }
.space-button { width: 48px; min-height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 16px; background: #0d1d19; cursor: pointer; transition: border-radius .18s, background .18s; }
.space-button svg { width: 22px; fill: #a5bcb6; }
.space-button:hover, .space-button.active { border-radius: 12px; background: var(--mint); color: #052019; }
.space-button.active svg { fill: #062019; }
.space-button.dashed { border-style: dashed; color: var(--mint); font-size: 1.5rem; }
.space-button:disabled { opacity: .42; cursor: not-allowed; }
.rail-divider { width: 32px; height: 1px; background: var(--line); }
.community-rail { display: grid; gap: 10px; }

.sidebar { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: #081310f5; overflow: hidden; }
.my-profile { min-height: 74px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.my-profile:hover { background: #0d1d19; }
.my-profile span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.my-profile small { color: var(--muted); font-size: .6rem; letter-spacing: .09em; }
.my-profile strong { overflow: hidden; text-overflow: ellipsis; }
.my-profile svg { width: 19px; fill: var(--mint); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; background: linear-gradient(145deg, #a2f1d4, #61deb7); color: #04231a; font-weight: 900; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-nav { display: grid; gap: 5px; padding: 14px 10px 8px; }
.nav-row { min-height: 44px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 11px; background: transparent; text-align: left; cursor: pointer; }
.nav-row:hover, .nav-row.active { background: #12231f; }
.nav-icon { color: var(--mint); font-size: 1.2rem; }
.badge { min-width: 21px; height: 21px; display: grid; place-items: center; border-radius: 11px; background: #19342e; color: var(--mint); font-size: .68rem; }
.badge.amber { background: #3b2c11; color: var(--amber); }
.add-friend { min-height: 44px; margin: 4px 12px 14px; border: 1px solid #286050; border-radius: 12px; background: #0b201a; color: var(--mint); font-weight: 800; cursor: pointer; }
.sidebar > .section-label { display: flex; justify-content: space-between; padding: 0 15px 8px; color: #c0d4ce; }
.dialog-list { flex: 1 1 auto; padding: 0 8px 12px; overflow-y: auto; scrollbar-gutter: stable; }
.dialog-row { width: 100%; min-height: 62px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid transparent; border-radius: 13px; background: transparent; text-align: left; cursor: pointer; }
.dialog-row:hover, .dialog-row.active { border-color: #285246; background: #10231e; }
.dialog-copy { min-width: 0; display: grid; gap: 4px; }
.dialog-copy strong, .dialog-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-copy small { color: var(--muted); }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: #667873; }
.unread-dot.new { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.server-status { min-height: 68px; display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 9px; padding: 10px 14px; border-top: 1px solid var(--line); }
.server-status span:last-child { display: grid; gap: 3px; }
.server-status strong { font-size: .72rem; }
.server-status small { color: var(--muted); font-size: .62rem; }
.mini-lights { display: grid; gap: 2px; }
.mini-lights i { width: 8px; height: 8px; border-radius: 50%; background: #27342f; }
.mini-lights i:last-child { background: var(--amber); }

.main-panel { grid-column: 3; grid-row: 2; min-width: 0; min-height: 0; background: #07110ff0; overflow: hidden; }
.friends-view, .requests-view, .chat-view { width: 100%; height: 100%; min-height: 0; }
.friends-view, .requests-view { display: flex; flex-direction: column; }
.view-header, .chat-header { min-height: 64px; display: flex; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); background: #091512fa; position: relative; }
.view-header h2 { margin: 0; font-size: 1rem; }
.view-tabs { display: flex; gap: 4px; }
.view-tabs button { min-height: 36px; padding: 0 13px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.view-tabs button.active { background: #152722; color: var(--text); }
.view-header > .primary { margin-left: auto; }
.friends-body { flex: 1; min-height: 0; padding: 18px 24px; overflow-y: auto; }
.search-box { position: relative; display: block; }
.search-box svg { position: absolute; left: 14px; top: 13px; width: 19px; fill: var(--muted); pointer-events: none; }
.search-box input { padding-left: 43px; }
.list-caption { margin: 22px 0 8px; color: #c3d2ce; font-size: .72rem; font-weight: 800; }
.friend-list { display: grid; }
.friend-row { min-height: 70px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.friend-row:hover { background: #0a1815; }
.friend-row-copy { min-width: 0; display: grid; gap: 4px; }
.friend-row-copy small { color: var(--muted); }
.friend-actions { display: flex; gap: 8px; }
.friend-actions button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #14231f; cursor: pointer; }
.empty-state { max-width: 410px; margin: 14vh auto 0; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--text); }
.empty-orbit { width: 76px; height: 76px; display: grid; place-items: center; margin: auto; border: 1px solid #2d5f52; border-radius: 50%; color: var(--mint); font-size: 2rem; box-shadow: inset 0 0 25px #48dbad1a, 0 0 35px #48dbad12; }

.chat-view { display: grid; grid-template-rows: 64px auto minmax(0, 1fr) auto; }
.chat-person { display: grid; gap: 3px; min-width: 0; }
.chat-person small { color: var(--muted); font-size: .68rem; }
.chat-header > .icon-button { margin-left: auto; }
.lab-strip { min-height: 30px; display: grid; place-items: center; padding: 5px 10px; border-bottom: 1px solid #4b4022; background: #17170f; color: #e6bd64; font-size: .67rem; text-align: center; }
.typing { display: flex; align-items: center; gap: 4px; color: var(--mint); font-size: .7rem; }
.typing i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; animation: type-dot 1.1s infinite; }
.typing i:nth-last-child(2) { animation-delay: .16s; }.typing i:last-child { animation-delay: .32s; }
.pencil { display: inline-block; animation: pencil 1.1s ease-in-out infinite; }
@keyframes type-dot { 0%,60%,100% { opacity:.25; transform: translateY(0) } 30% { opacity:1; transform: translateY(-2px) } }
@keyframes pencil { 0%,100% { transform:rotate(-9deg) translateY(0) } 50% { transform:rotate(5deg) translateY(-1px) } }
.contact-menu { position: absolute; z-index: 4; top: 54px; right: 16px; width: 210px; display: grid; padding: 6px; border: 1px solid var(--line); border-radius: 13px; background: #0b1715; box-shadow: var(--shadow); }
.contact-menu button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; }
.contact-menu button:hover { background: #152722; }.contact-menu button.danger { color: var(--danger); }
.message-log { min-height: 0; padding: 20px clamp(14px, 3vw, 42px); overflow-y: auto; overflow-anchor: none; }
.message { max-width: min(68%, 720px); margin: 9px 0; padding: 10px 13px; border: 1px solid #253c37; border-radius: 17px 17px 17px 5px; background: #14221f; line-height: 1.42; overflow-wrap: anywhere; }
.message.out { margin-left: auto; border-color: #28604f; border-radius: 17px 17px 5px 17px; background: #104536; }
.message-meta { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; color: #84a49b; font-size: .62rem; }
.message-file { max-width: min(78%, 640px); display: grid; grid-template-columns: 42px 1fr; gap: 10px; margin: 10px 0; padding: 12px; border: 1px solid #315047; border-radius: 15px; background: #101e1b; }
.file-progress { grid-column: 1 / -1; width: 100%; height: 5px; border: 0; border-radius: 5px; overflow: hidden; accent-color: var(--mint); }
.composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 12px clamp(12px, 2vw, 24px) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #081310; }
.composer-icon { width: 46px; height: 46px; }
.message-field { position: relative; }
.message-field textarea { min-height: 46px; max-height: 156px; padding-right: 70px; }
.message-field small { position: absolute; right: 10px; bottom: 7px; color: #66827a; font-size: .58rem; pointer-events: none; }
.send-button { width: 50px; height: 50px; display: grid; place-items: center; border: 0; border-radius: 16px; background: var(--mint); cursor: pointer; box-shadow: 0 7px 20px #2ed7a42c; }
.send-button:hover { background: var(--mint-strong); transform: translateY(-1px); }
.send-button svg { width: 34px; height: 34px; }
.send-wing { fill: #073126; }.send-cut { fill: var(--mint); }
.request-list { padding: 18px; overflow-y: auto; }
.request-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; border-bottom: 1px solid var(--line); }
.request-actions { display: flex; gap: 8px; }
.mobile-back, .mobile-menu { display: none; width: 42px; height: 42px; border: 0; border-radius: 12px; background: #10221e; font-size: 1.5rem; }

.modal { width: min(560px, calc(100% - 24px)); max-height: min(820px, calc(100dvh - 24px)); padding: 0; border: 1px solid #36594f; border-radius: 22px; background: #0b1916; color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.modal::backdrop { background: #000a; backdrop-filter: blur(7px); }
.modal-card { position: relative; display: grid; gap: 14px; padding: 28px; }
.modal-card h2 { margin: -7px 0 0; font-size: 1.7rem; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: #10211d; font-size: 1.4rem; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.contact-preview { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #07110f; }
.settings-card { width: 100%; }
.settings-section { display: grid; gap: 13px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #0c1b18; }
.settings-section h3, .settings-section .section-label { margin: 0; }
.toggle-row, .radio-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.toggle-row span, .radio-row span { display: grid; gap: 3px; }
.toggle-row small, .radio-row small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.toggle-row input { width: 44px; min-height: 24px; accent-color: var(--mint); }
.radio-row { grid-template-columns: auto 1fr; }.radio-row input { width: 19px; min-height: 19px; accent-color: var(--mint); }
.fingerprint { padding: 15px; border: 1px solid #3a6156; border-radius: 12px; background: #06100e; color: var(--mint-strong); font-family: ui-monospace, Consolas, monospace; line-height: 1.65; overflow-wrap: anywhere; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); display: grid; gap: 10px; width: min(390px, calc(100% - 36px)); pointer-events: none; }
.toast { padding: 13px 15px; border: 1px solid #3b6157; border-left: 4px solid var(--mint); border-radius: 13px; background: #10201deF; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 64px 280px minmax(0, 1fr); }
  .info-ticker { display: none; }
  .transport-pill span:not(.traffic-light), .transport-pill output { display: none; }
  .transport-pill { padding: 0 13px; }
  .message { max-width: 84%; }
}

@media (max-width: 700px) {
  html, body { overscroll-behavior: none; }
  .app-shell { grid-template: 58px minmax(0, 1fr) / 1fr; }
  .topbar { grid-column: 1; grid-row: 1; padding: 0 10px; gap: 9px; }
  .brand { flex: 1; }.brand img { width: 34px; height: 34px; }
  .transport-pill { min-height: 42px; }
  .space-rail { display: none; }
  .sidebar { grid-column: 1; grid-row: 2; border-right: 0; }
  .main-panel { grid-column: 1; grid-row: 2; }
  .app-shell[data-mobile-panel="sidebar"] .main-panel { display: none; }
  .app-shell:not([data-mobile-panel="sidebar"]) .sidebar { display: none; }
  .mobile-back, .mobile-menu { display: grid; place-items: center; flex: 0 0 auto; }
  .view-header, .chat-header { min-height: 58px; padding: 0 10px; gap: 10px; }
  .view-tabs { display: none; }
  .friends-body { padding: 13px; }
  .empty-state { margin-top: 10vh; padding: 0 18px; }
  .chat-view { grid-template-rows: 58px auto minmax(0, 1fr) auto; }
  .chat-header .avatar { width: 38px; height: 38px; }
  .typing { display: none !important; }
  .message-log { padding: 13px 10px; }
  .message { max-width: 88%; }
  .composer { gap: 7px; padding: 9px 8px max(9px, env(safe-area-inset-bottom)); }
  .composer-icon { width: 44px; height: 44px; }
  .send-button { width: 48px; height: 48px; }
  .auth-shell { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 24px 18px; border-radius: 22px; }
  .modal { max-height: calc(100dvh - 12px); width: calc(100% - 12px); border-radius: 18px; }
  .modal-card { padding: 24px 16px; }
}

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