:root {
  color-scheme: dark;
  --bg: #080a0e;
  --panel: #0e1117;
  --panel-2: #141821;
  --panel-3: #1a202b;
  --line: rgba(255, 255, 255, .1);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #f7f8fa;
  --muted: #a7afbd;
  --muted-2: #747e8e;
  --lime: #c9ff63;
  --lime-soft: rgba(201, 255, 99, .12);
  --cyan: #73e6f4;
  --danger: #ff91a0;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 16px; -webkit-font-smoothing: antialiased; }
body.portal-open { overflow: hidden; }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; padding: 10px 14px; border-radius: 10px; background: var(--lime); color: #11150a; font-weight: 750; transform: translateY(-150%); transition: transform 160ms ease; }
.skip-link:focus { transform: translateY(0); }

.topbar { position: fixed; z-index: 30; top: 0; right: 0; left: 0; display: flex; align-items: center; justify-content: space-between; height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) clamp(16px, 3vw, 36px) 0; border-bottom: 1px solid var(--line); background: rgba(8, 10, 14, .92); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: .98rem; letter-spacing: -.015em; }
.brand small { color: var(--muted-2); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .63rem; letter-spacing: .06em; text-transform: uppercase; }
.brand-mark { position: relative; display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line-strong); border-radius: 11px; background: linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.02)); }
.brand-mark i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px rgba(201,255,99,.6); }
.brand-mark i:nth-child(1) { transform: translate(-7px, 5px); }
.brand-mark i:nth-child(2) { transform: translate(0, -7px); }
.brand-mark i:nth-child(3) { transform: translate(8px, 5px); }
.brand-mark::before, .brand-mark::after { position: absolute; width: 12px; height: 1px; background: rgba(201,255,99,.5); content: ""; transform-origin: center; }
.brand-mark::before { transform: translate(-4px, 0) rotate(-51deg); }
.brand-mark::after { transform: translate(4px, 0) rotate(51deg); }
.connection-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.presence-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--muted-2); }
.connection-pill[data-state="live"] .presence-dot, .rail-status .presence-dot { background: var(--lime); box-shadow: 0 0 14px rgba(201,255,99,.75); animation: pulse 2s ease-out infinite; }
.connection-pill[data-state="warning"] .presence-dot { background: #ffcc68; }

/* Login */
.login-view { position: relative; display: grid; min-height: 100vh; place-items: center; overflow: hidden; padding: 108px 24px 54px; }
.login-grid { position: absolute; inset: 0; opacity: .42; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 64px 64px; mask-image: radial-gradient(circle at center, #000, transparent 75%); }
.login-view::before { position: absolute; width: 650px; height: 650px; border-radius: 50%; background: rgba(120,100,255,.12); filter: blur(120px); content: ""; transform: translate(-42vw, -24vh); }
.login-panel { position: relative; z-index: 2; width: min(100%, 510px); padding: clamp(30px, 5vw, 52px); border: 1px solid var(--line-strong); border-radius: 28px; background: linear-gradient(155deg, rgba(22,26,35,.96), rgba(12,15,21,.98)); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06); }
.eyebrow, .section-label { display: block; margin: 0 0 10px; color: var(--lime); font-size: .72rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.login-panel h1 { margin: 0; font-size: clamp(2.8rem, 7vw, 4.3rem); letter-spacing: -.065em; line-height: .95; }
.login-panel h1 em { color: var(--lime); font-style: normal; font-weight: 560; }
.login-copy { max-width: 410px; margin: 24px 0 32px; color: var(--muted); font-size: 1rem; line-height: 1.65; }
.login-form { display: grid; gap: 10px; }
label { color: #d8dde5; font-size: .86rem; font-weight: 680; }
input, textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; outline: none; background: rgba(3,5,8,.5); transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease; }
input { height: 50px; padding: 0 14px; }
textarea { padding: 13px 14px; line-height: 1.5; resize: none; }
input:focus, textarea:focus, select:focus { border-color: rgba(201,255,99,.72); background: rgba(3,5,8,.75); box-shadow: 0 0 0 4px rgba(201,255,99,.09); }
.secret-field { position: relative; }
.secret-field input { padding-right: 82px; }
.reveal-button { position: absolute; top: 50%; right: 8px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .75rem; transform: translateY(-50%); }
.reveal-button:hover { background: var(--panel-3); color: var(--text); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: .78rem; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 12px; font-size: .88rem; font-weight: 780; }
.primary-button { border: 1px solid var(--lime); background: var(--lime); color: #11150a; }
.primary-button:hover { background: #d8ff8a; }
.primary-button:disabled, .send-button:disabled { cursor: wait; opacity: .58; }
.secondary-button { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.login-form .primary-button { justify-content: space-between; width: 100%; }
.security-note { display: flex; gap: 8px; margin-top: 22px; color: var(--muted-2); font-size: .76rem; }
.login-orbit { position: absolute; top: 50%; left: calc(50% + 430px); width: 500px; height: 500px; transform: translate(-50%, -50%); }
.orbit { position: absolute; inset: 0; border: 1px solid rgba(115,230,244,.2); border-radius: 50%; }
.orbit-a { transform: rotate(20deg) scaleY(.42); }
.orbit-b { border-color: rgba(157,140,255,.2); transform: rotate(-31deg) scaleY(.64); }
.orbit-core { position: absolute; top: 50%; left: 50%; display: grid; width: 76px; height: 76px; place-items: center; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--panel-2); color: var(--lime); font-family: ui-monospace, monospace; transform: translate(-50%, -50%) rotate(-7deg); box-shadow: 0 0 70px rgba(201,255,99,.1); }
.packet { position: absolute; top: 49%; left: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px rgba(115,230,244,.8); }
.packet-a { animation: packet-a 6s linear infinite; }
.packet-b { background: #9d8cff; animation: packet-b 8s linear infinite reverse; }

/* Portal */
.portal { display: grid; grid-template-columns: 310px minmax(0, 1fr); height: 100dvh; padding-top: calc(64px + env(safe-area-inset-top)); overflow: hidden; background: var(--bg); }
.rail { display: flex; min-height: 0; flex-direction: column; padding: 25px 18px 18px; overflow: hidden; border-right: 1px solid var(--line); background: var(--panel); }
.rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; padding: 0 4px; }
.rail-heading .section-label { margin: 0 0 4px; }
.rail-heading h1 { display: flex; align-items: baseline; gap: 9px; margin: 0; font-size: 1.55rem; letter-spacing: -.035em; }
.rail-heading h1 small { color: var(--muted-2); font-size: .72rem; font-weight: 650; }
.rail-actions { display: flex; gap: 7px; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--muted); font-size: 1.05rem; }
.icon-button:hover { border-color: var(--line-strong); background: var(--panel-2); color: var(--text); }
.logout-button { font-size: 1.15rem; transform: rotate(180deg); }
.mobile-channel-picker { display: none; }
.mobile-channel-picker label span { color: var(--muted-2); font-weight: 500; }
.channel-list { display: grid; gap: 7px; min-height: 0; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.channel-button { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; min-height: 66px; padding: 9px 11px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--muted); text-align: left; }
.channel-button:hover { background: rgba(255,255,255,.035); color: var(--text); }
.channel-button.active { border-color: rgba(201,255,99,.2); background: var(--lime-soft); color: var(--text); }
.channel-glyph { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); color: var(--muted); font-size: 1rem; font-weight: 800; }
.channel-button.active .channel-glyph { border-color: rgba(201,255,99,.35); background: rgba(201,255,99,.14); color: var(--lime); }
.channel-copy { display: grid; min-width: 0; gap: 3px; }
.channel-copy strong { overflow: hidden; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.channel-copy small { overflow: hidden; color: var(--muted-2); font-size: .7rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.channel-unread { display: grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 999px; background: var(--lime); color: #10140a; font-size: .65rem; font-weight: 850; }
.icon-button.enabled { border-color: rgba(201,255,99,.35); background: var(--lime-soft); color: var(--lime); }
.new-channel-button { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 42px; margin-top: 11px; border: 1px dashed var(--line-strong); border-radius: 12px; background: transparent; color: var(--muted); font-size: .79rem; font-weight: 680; }
.new-channel-button:hover { border-color: rgba(201,255,99,.45); background: var(--lime-soft); color: var(--lime); }
.device-summary { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.summary-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.summary-heading h2 { margin: 0; font-size: .83rem; }
.summary-heading > span { color: var(--muted-2); font-size: .68rem; }
.device-list { display: grid; gap: 7px; }
.device-card { position: relative; padding: 11px 12px 11px 34px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.device-card::before { position: absolute; top: 17px; left: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); content: ""; }
.device-card.online::before { background: var(--lime); box-shadow: 0 0 11px rgba(201,255,99,.6); }
.device-card strong { display: block; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.device-card small { display: block; margin-top: 3px; color: var(--muted-2); font-size: .66rem; }
.rail-status { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 15px 10px 2px; border-top: 1px solid var(--line); }
.rail-status > div { display: grid; gap: 2px; }
.rail-status strong { font-size: .76rem; }
.rail-status small { color: var(--muted-2); font-size: .65rem; }

.conversation { display: flex; min-width: 0; min-height: 0; flex-direction: column; background: radial-gradient(circle at 50% -10%, rgba(115,230,244,.045), transparent 36rem), var(--bg); }
.conversation-header { display: flex; min-height: 78px; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 18px; padding: 13px clamp(18px, 3vw, 34px); border-bottom: 1px solid var(--line); background: rgba(8,10,14,.78); backdrop-filter: blur(14px); }
.conversation-identity { display: flex; min-width: 0; align-items: center; gap: 13px; }
.conversation-icon { display: grid; width: 46px; height: 46px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(201,255,99,.25); border-radius: 15px; background: var(--lime-soft); color: var(--lime); font-size: 1.05rem; font-weight: 800; }
.conversation-identity > div { min-width: 0; }
.conversation-header h2 { overflow: hidden; margin: 0; font-size: 1.05rem; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.conversation-header p { overflow: hidden; margin: 3px 0 0; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-count { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .7rem; }

.message-scroll { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.message-stream { display: flex; width: min(100%, 860px); min-height: 100%; flex-direction: column; gap: 14px; justify-content: flex-start; margin: 0 auto; padding: 24px clamp(18px, 4vw, 42px) 42px; }
.empty-state { display: grid; min-height: 280px; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.empty-state > span { display: grid; width: 54px; height: 54px; place-items: center; margin-bottom: 15px; border: 1px solid rgba(201,255,99,.25); border-radius: 17px; background: var(--lime-soft); color: var(--lime); font-size: 1.35rem; }
.empty-state strong { color: var(--text); font-size: 1rem; }
.empty-state p { max-width: 390px; margin: 8px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.message-card { width: 100%; max-width: 100%; padding: 17px 18px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-2); box-shadow: 0 10px 24px rgba(0,0,0,.12); animation: message-in 180ms ease-out; }
.message-card[data-sender="portal"] { align-self: stretch; border-color: rgba(201,255,99,.24); border-radius: 18px; background: linear-gradient(145deg, rgba(201,255,99,.1), rgba(20,24,33,.98)); color: var(--text); }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 6px; }
.message-source { color: var(--cyan); font-size: .7rem; font-weight: 740; }
.message-card[data-sender="portal"] .message-source { color: var(--lime); }
.message-meta time { color: var(--muted-2); font-size: .65rem; white-space: nowrap; }
.message-card[data-sender="portal"] .message-meta time { color: var(--muted-2); }
.message-title { margin: 2px 0 8px; color: var(--text); font-size: 1.02rem; letter-spacing: -.02em; }
.message-body { margin: 0; color: #edf0f5; font-size: .96rem; line-height: 1.48; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-card[data-sender="portal"] .message-body { color: #edf0f5; }
.message-details { margin-top: 9px; border-top: 1px solid var(--line); padding-top: 7px; }
.message-card[data-sender="portal"] .message-details { border-top-color: var(--line); }
.message-details summary { color: var(--muted); font-size: .69rem; cursor: pointer; }
.message-card[data-sender="portal"] .message-details summary { color: var(--muted); }
.message-json { max-height: 190px; margin: 8px 0 0; overflow: auto; color: #cbd2dd; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .69rem; line-height: 1.45; white-space: pre-wrap; }
.message-card[data-sender="portal"] .message-json { color: #cbd2dd; }
.message-card.system-event { align-self: center; max-width: 92%; padding: 5px 11px; border: 0; border-radius: 999px; background: rgba(255,255,255,.045); box-shadow: none; }
.message-card.system-event .message-meta, .message-card.system-event .message-details { display: none; }
.message-card.system-event .message-body { color: var(--muted); font-size: .72rem; text-align: center; }

.composer-panel { flex: 0 0 auto; border-bottom: 1px solid var(--line); background: rgba(14,17,23,.96); padding: 12px clamp(16px, 3vw, 30px); backdrop-filter: blur(18px); }
.message-form { width: min(100%, 800px); margin: 0 auto; }
.composer-target { margin: 0 4px 7px; color: var(--muted); font-size: .7rem; }
.composer-target strong { color: var(--text); }
.composer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
.composer-row textarea { min-height: 50px; max-height: 128px; overflow-y: auto; border-radius: 15px; background: #090c11; font-size: 1rem; }
.composer-row textarea::placeholder { color: #737d8d; }
.send-button { display: inline-flex; min-width: 104px; height: 50px; align-items: center; justify-content: center; gap: 9px; padding: 0 15px; border: 1px solid var(--lime); border-radius: 15px; background: var(--lime); color: #10140a; font-size: .84rem; font-weight: 800; }
.send-button:hover { background: #d8ff8a; }
.send-arrow { font-size: 1.05rem; }
.composer-feedback { display: flex; min-height: 18px; align-items: start; justify-content: space-between; gap: 15px; margin: 5px 4px 0; }
.composer-feedback .form-error { min-height: 0; }
.composer-feedback > span { color: var(--muted-2); font-size: .64rem; white-space: nowrap; }

/* Channel dialog */
.channel-dialog, .e2ee-dialog { width: min(calc(100% - 28px), 470px); padding: 0; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--panel-2); color: var(--text); box-shadow: var(--shadow); }
.channel-dialog::backdrop, .e2ee-dialog::backdrop { background: rgba(2,4,7,.82); backdrop-filter: blur(7px); }
.channel-dialog form, .e2ee-dialog form { display: grid; gap: 12px; padding: 26px; }
.dialog-heading { display: flex; gap: 13px; margin-bottom: 8px; }
.dialog-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: var(--lime-soft); color: var(--lime); font-weight: 800; }
.dialog-heading h2 { margin: 0; font-size: 1.2rem; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.dialog-heading code { color: var(--lime); }
.dialog-kicker { margin: 0 0 5px !important; color: var(--lime) !important; font-size: .66rem !important; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.lock-icon { border: 1px solid rgba(201,255,99,.28); }
.e2ee-dialog { border-color: rgba(201,255,99,.24); }
.e2ee-dialog .secret-field input { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .78rem; letter-spacing: .02em; }
.e2ee-dialog .primary-button { justify-content: space-between; width: 100%; }
.e2ee-assurance { display: flex; gap: 9px; padding: 11px 12px; border: 1px solid rgba(201,255,99,.15); border-radius: 12px; background: var(--lime-soft); color: var(--muted); font-size: .72rem; line-height: 1.45; }
.e2ee-assurance > span:first-child { color: var(--lime); font-weight: 850; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 9px; margin-top: 6px; }
.e2ee-actions { grid-template-columns: .82fr 1.4fr; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(380px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--panel-3); box-shadow: var(--shadow); color: var(--text); font-size: .8rem; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity 170ms ease, transform 170ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(201,255,99,.6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(201,255,99,0); } }
@keyframes packet-a { from { transform: translate(0, -50%); } 50% { transform: translate(490px, -50%); } to { transform: translate(0, -50%); } }
@keyframes packet-b { from { transform: translate(245px, -250px); } 50% { transform: translate(245px, 240px); } to { transform: translate(245px, -250px); } }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 980px) {
  .portal { grid-template-columns: 280px minmax(0, 1fr); }
  .message-card { max-width: 84%; }
}

@media (max-width: 760px) {
  .topbar { height: calc(60px + env(safe-area-inset-top)); padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .brand small { display: none; }
  .connection-pill { max-width: 142px; padding: 8px 10px; font-size: .68rem; }
  #connection-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .login-orbit { display: none; }
  .portal { display: flex; height: 100dvh; flex-direction: column; padding-top: calc(60px + env(safe-area-inset-top)); }
  .rail { position: relative; display: block; height: auto; flex: 0 0 auto; padding: 12px max(14px, env(safe-area-inset-right)) 11px max(14px, env(safe-area-inset-left)); overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-heading { min-height: 38px; margin-bottom: 9px; padding: 0; }
  .rail-heading .section-label { display: none; }
  .rail-heading h1 { font-size: 1.18rem; }
  .rail-heading h1 small { font-size: .66rem; }
  .rail-actions .icon-button { width: 44px; height: 44px; }
  .mobile-channel-picker { display: grid; gap: 6px; }
  .mobile-channel-picker label { color: var(--muted); font-size: .7rem; }
  .select-shell { position: relative; }
  .select-shell select { height: 48px; padding: 0 42px 0 13px; appearance: none; background: var(--panel-2); font-size: .94rem; font-weight: 680; }
  .select-shell > span { position: absolute; top: 50%; right: 15px; color: var(--lime); pointer-events: none; transform: translateY(-55%); }
  .channel-list, .device-summary, .rail-status { display: none; }
  .new-channel-button { min-height: 35px; margin-top: 7px; border: 0; justify-content: flex-start; padding: 0 2px; color: var(--muted); }
  .conversation { min-height: 0; flex: 1 1 auto; }
  .conversation-header { min-height: 62px; padding: 9px 14px; }
  .conversation-icon { width: 40px; height: 40px; border-radius: 13px; }
  .conversation-header h2 { font-size: .96rem; }
  .conversation-header p { max-width: 230px; font-size: .7rem; }
  .conversation-count { display: none; }
  .message-stream { gap: 10px; padding: 18px 12px; }
  .message-card { max-width: 100%; padding: 14px 14px 13px; }
  .message-body { font-size: .96rem; }
  .message-card.system-event { max-width: 96%; }
  .composer-panel { padding: 9px max(10px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .composer-target { margin-bottom: 6px; font-size: .68rem; }
  .composer-row { gap: 7px; }
  .composer-row textarea { min-height: 48px; padding: 12px 13px; border-radius: 15px; }
  .send-button { width: 96px; min-width: 96px; height: 48px; padding: 0 12px; border-radius: 15px; }
  .composer-feedback { margin-top: 3px; }
  .toast { right: 12px; bottom: calc(100px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  .channel-dialog, .e2ee-dialog { margin: auto 14px 14px; border-radius: 22px; }
}

@media (max-width: 430px) {
  .login-view { padding: 92px 14px 28px; }
  .login-panel { padding: 29px 22px; border-radius: 23px; }
  .login-panel h1 { font-size: 2.7rem; }
  .login-copy { font-size: .94rem; }
  .channel-dialog form, .e2ee-dialog form { padding: 22px 18px; }
}

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