:root {
  --ink: #10200e;
  --ink-strong: #071306;
  --muted: #737c71;
  --muted-light: #9ba299;
  --line: #e6ebe3;
  --line-strong: #d9e0d6;
  --surface: #ffffff;
  --surface-soft: #f5f7f3;
  --surface-muted: #eef2ec;
  --canvas: #edf0eb;
  --accent: #85e653;
  --accent-hover: #76d846;
  --accent-soft: #eefae8;
  --danger: #d84942;
  --danger-soft: #fff2f0;
  --warning: #b8662f;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-shell: 0 24px 70px rgba(25, 40, 22, .10);
  --shadow-float: 0 18px 50px rgba(25, 40, 22, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: "Manrope", system-ui, sans-serif; }
body { display: flex; justify-content: center; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
p { color: var(--muted); line-height: 1.65; }

.app-shell { position: relative; width: 100%; min-height: 100dvh; overflow: hidden; background: var(--surface); }
.page-surface { min-width: 0; min-height: 100dvh; background: var(--surface); }
.eyebrow, .login-kicker { color: #778074; font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.brand-mark, .wordmark span, .login-brand span { border-radius: 50%; background: var(--ink); color: #fff; box-shadow: none; }
.avatar, .avatar.gradient { border-radius: 50%; background: var(--surface-muted); color: #354432; }

.primary, .google-button {
  min-height: 52px; border: 0; border-radius: var(--radius-md); padding: 0 22px;
  background: var(--ink); color: #fff; box-shadow: none; font-weight: 700;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
}
.primary:hover, .google-button:hover { transform: translateY(-1px); background: #1c2c19; }
.primary:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(133, 230, 83, .42); outline-offset: 2px; }
.primary:disabled { opacity: .48; transform: none; cursor: not-allowed; }
.mini { border-radius: 999px; background: var(--accent); color: var(--ink); }
.mini.secondary { background: var(--surface-muted); color: var(--ink); }

/* Authentication and account screens */
.login-screen.login-v3.login-v4 { background: var(--surface); }
.login-visual { background: var(--surface-soft); }
.login-visual::before { background: rgba(133, 230, 83, .22); }
.login-visual::after { background: rgba(133, 230, 83, .10); }
.login-brand { color: var(--ink); }
.login-copy h1 { color: var(--ink-strong); }
.login-copy p { color: var(--muted); }
.uchat-flow { color: #596656; }
.uchat-flow b { color: var(--ink); }
.uchat-flow i { background: var(--line-strong); }
.connection-card { border-color: var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.92); box-shadow: var(--shadow-float); }
.connection-people span, .connection-people span:last-child { background: var(--accent-soft); color: #44752f; }
.auth-panel { background: var(--surface); }
.auth-panel h2 { color: var(--ink-strong); }
.auth-tabs { gap: 4px; padding: 4px; border-radius: var(--radius-md); background: var(--surface-muted); }
.auth-tabs button { height: 42px; border-radius: var(--radius-sm); }
.auth-tabs button.active { color: var(--ink); box-shadow: none; }
.auth-panel .stack > label > input, .verify-screen input,
.handle-input, .stack > input, .settings-card input, .settings-card select {
  min-height: 52px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: #fbfcfa;
}
.auth-panel .stack > label > input:focus, .verify-screen input:focus, .handle-input:focus-within,
.settings-card input:focus, .settings-card select:focus { border-color: #91d96d; }
.auth-note { color: var(--muted) !important; }

.simple-screen {
  min-height: 100%; padding: clamp(28px, 7vw, 72px); justify-content: center; gap: 34px;
  background: var(--surface) !important;
}
.simple-screen > .brand-mark { position: absolute; top: 28px; left: 28px; }
.simple-screen > div:not(.brand-mark), .simple-screen > form { width: min(100%, 500px); margin-inline: auto; }
.simple-screen h1 { color: var(--ink-strong); font-size: clamp(32px, 5vw, 48px); letter-spacing: -1.8px; }
.simple-screen .locked { width: min(100%, 520px); padding: clamp(30px, 6vw, 52px); border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-float); }
.lock-orb { border-radius: 50%; background: var(--accent-soft); color: #59b72e; }
.verify-screen .locked { max-width: 540px; }
.verify-screen .stack { margin-top: 24px; text-align: left; }
.verify-screen .lock-orb { width: 68px; height: 68px; margin-bottom: 16px; font-size: 25px; }
.verify-screen .locked h1 { margin: 7px 0 12px; }
.verify-screen .locked > p { margin: 0 auto 24px; max-width: 430px; }
.verify-screen .locked > form:not(.stack) { display: flex; justify-content: center; }
.verify-screen .auth-note { margin-top: 22px !important; }

/* Navigation and list pages */
.desktop-nav { display: none; background: var(--surface-soft); border-color: var(--line); }
.wordmark { color: var(--ink); }
.desktop-profile small, .desktop-logout { color: var(--muted-light); }
.desktop-nav nav a { border-radius: var(--radius-sm); color: var(--muted); }
.desktop-nav nav a:first-child { background: var(--surface); color: var(--ink); box-shadow: none; }
.desktop-nav nav i { color: #5ac82d; }
.topbar { height: 104px; padding: calc(22px + env(safe-area-inset-top)) 22px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { color: var(--ink-strong); font-size: 28px; letter-spacing: -1px; }
.topbar .eyebrow { display: none; }
.icon-button { border-radius: 50%; background: var(--surface-muted); color: var(--ink); }
.new-chat span { border-radius: 50%; background: var(--accent); color: var(--ink); box-shadow: none; }
.section { padding: 18px 22px; }
.section-title h2 { color: var(--muted); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; }
.code-card { margin: 18px 22px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-soft); }
.code-value strong { color: var(--ink-strong); }
.chat-list { gap: 0; }
.chat-row { min-height: 76px; padding: 12px 6px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; }
.chat-row:hover { background: #fafbf9; transform: none; }
.chat-row.needs-action, .chat-row.is-waiting { background: transparent; }
.chat-row .grow strong { color: var(--ink-strong); font-size: 13px; }
.chat-row .grow small { color: var(--muted); font-size: 10px; }
.unread-badge { min-width: 22px; height: 19px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: 9px; font-weight: 800; display: grid; place-items: center; }
.unread-badge[hidden] { display: none; }
.state-icon.open { background: transparent; color: var(--muted-light); }
.state-icon.waiting { background: var(--accent-soft); color: #54ac2b; }
.state-icon.incoming { background: var(--accent); color: var(--ink); box-shadow: none; }
.empty { padding: 52px 24px; }
.empty-icon { border-radius: 50%; background: var(--accent-soft); color: #58b32d; }
.searchbox { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.person { border-color: var(--line); }
.bottom-nav { border-top: 1px solid var(--line); background: rgba(255,255,255,.96); box-shadow: none; backdrop-filter: blur(14px); }
.bottom-nav a.active { color: var(--ink); }
.bottom-nav a.active span { color: #59c42d; }

/* Profile */
.profile-page { width: min(100%, 760px); padding: 20px 22px 96px; }
.profile-identity { display: flex; align-items: center; gap: 16px; padding: 10px 0 24px; border-bottom: 1px solid var(--line); }
.profile-avatar { width: 68px; height: 68px; background: var(--accent-soft); color: #4b9c28; font-size: 24px; }
.profile-identity h2 { margin: 0 0 4px; color: var(--ink-strong); font-size: 22px; letter-spacing: -.7px; }
.profile-identity p { margin: 0; font-size: 12px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-soft); }
.profile-stats div { display: grid; gap: 3px; padding: 18px; }
.profile-stats div + div { border-left: 1px solid var(--line); }
.profile-stats strong { color: var(--ink-strong); font-size: 15px; }
.profile-stats span { color: var(--muted); font-size: 10px; }
.profile-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.profile-card h3 { margin: 8px 0 4px; font-size: 23px; letter-spacing: 2.5px; }
.profile-card p { margin: 0; font-size: 11px; }
.profile-actions { margin-top: 30px; }
.profile-actions > div h3 { margin: 0; font-size: 13px; }
.profile-actions > div p { margin: 5px 0 15px; font-size: 11px; }
.profile-signout { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid #f0ceca; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); text-decoration: none; }
.profile-signout > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #fff; }
.profile-signout div { display: grid; gap: 2px; }
.profile-signout strong { font-size: 12px; }
.profile-signout small { color: #9e6b67; font-size: 9px; }
.profile-signout:hover { transform: translateY(-1px); border-color: #e8b8b3; }

/* Conversation surfaces */
.conversation { background: #fafbf9; }
.chat-header { height: 80px; padding: calc(12px + env(safe-area-inset-top)) 18px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-header .small-avatar { border-radius: 50%; }
.chat-header .grow strong { color: var(--ink-strong); }
.chat-header .grow small, .desktop-security { color: var(--muted-light); }
.chat-header .grow i { background: var(--accent); }
.message-list { padding: 24px 18px 14px; gap: 10px; background: #fafbf9; }
.bubble { padding: 11px 14px; border: 0; border-radius: 5px 15px 15px 15px; background: #f0f3ee; color: var(--ink); box-shadow: none; }
.mine .bubble { border: 1px solid var(--line); border-radius: 15px 5px 15px 15px; background: var(--surface); color: var(--ink); }
.bubble-row time { color: var(--muted-light); }
.encryption-banner { background: #fafbf9; color: var(--muted-light); }
.offline-notice { border-bottom: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); }
.composer-wrap { padding: 10px 14px calc(11px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.composer { height: 50px; }
.composer input { height: 44px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.attach, .emoji { border-radius: 50%; background: var(--surface-muted); color: var(--ink); }
.attach { background: var(--surface-muted); }
.send { border: 0 !important; border-radius: 50%; background: var(--accent) !important; color: var(--ink) !important; }
.emoji-panel { border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-float); }
.session-disconnected, .pending-card { border-color: var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-float); }
.disconnect-orb, .waiting-orb { background: var(--accent-soft); color: #5aba30; }
.pending-conversation, .pending-conversation .message-list, .pending-stage { background: #fafbf9; }
.pending-pill { background: var(--accent-soft); color: #438b25; }
.pending-status, .waiting-live { background: var(--accent-soft); color: #438b25; }
.status-pulse, .waiting-live i { background: var(--accent); }
.pending-info { color: var(--muted); }
.secondary-action { border-color: var(--line-strong); border-radius: var(--radius-md); background: var(--surface-soft); color: var(--ink); }
.delete-pending, .delete-local { border-color: #f0ceca; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); }

/* Access, dialogs, settings and feedback */
.access-screen { padding: 24px !important; background: #fafbf9 !important; }
.access-screen > .locked { border-color: var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-float); }
.access-screen input { border-color: var(--line-strong); border-radius: var(--radius-md); background: #fbfcfa; }
.action-divider::before, .danger-zone { border-color: var(--line); background-color: transparent; }
.privacy-action { border-color: var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.privacy-action.destructive { border-color: #f0ceca; background: var(--danger-soft); color: var(--danger); }
dialog { width: min(calc(100% - 28px), 440px); border-radius: 28px; box-shadow: 0 28px 90px rgba(8, 18, 7, .28); }
dialog::backdrop { background: rgba(13, 22, 12, .48); backdrop-filter: blur(5px); }
.settings-card { gap: 20px; padding: 26px; background: var(--surface); }
.close-modal { border-radius: 50%; background: var(--surface-muted); color: var(--ink); cursor: pointer; }
.toast { border-radius: var(--radius-md); background: var(--ink); box-shadow: var(--shadow-float); }

/* Quiet motion: movement supports hierarchy without slowing interaction. */
.motion-ready [data-reveal] { opacity: 0; transform: translateY(14px); }
.motion-ready [data-reveal].is-visible { opacity: 1; transform: translateY(0); transition: opacity .52s cubic-bezier(.2,.7,.2,1), transform .52s cubic-bezier(.2,.7,.2,1); transition-delay: var(--reveal-delay, 0ms); }
.motion-ready .bubble-row.motion-new { animation: message-arrive .3s cubic-bezier(.2,.8,.2,1) both; }
.toast { animation: toast-in .4s cubic-bezier(.2,.8,.2,1) both; }
dialog[open] { animation: sheet-in .26s cubic-bezier(.2,.8,.2,1) both; }
dialog[open]::backdrop { animation: backdrop-in .22s ease both; }
.waiting-orb, .disconnect-orb, .lock-orb { transition: transform .25s ease, background .25s ease; }
.pending-card:hover .waiting-orb, .session-disconnected:hover .disconnect-orb, .locked:hover .lock-orb { transform: translateY(-2px); }
.chat-row, .person, .primary, .mini, .icon-button, .privacy-action, .secondary-action, .delete-pending, .delete-local { transition: transform .18s ease, background-color .18s ease, border-color .18s ease, opacity .18s ease; }
.chat-row:active, .person:active, .primary:active, .mini:active, .icon-button:active { transform: scale(.985); }
@keyframes message-arrive { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 719px) {
  .app-shell, .page-surface { min-height: 100dvh; }
  .login-v4 .auth-panel { background: linear-gradient(180deg, var(--surface-soft) 0 245px, var(--surface) 245px); }
  .login-brand { left: 20px; }
  .login-copy { left: 20px; right: 20px; }
  .auth-panel { padding-left: 20px; padding-right: 20px; }
  .simple-screen { padding: 96px 20px 32px; }
  .simple-screen > .brand-mark { top: 24px; left: 20px; }
  .verify-screen { min-height: 100dvh; padding: calc(22px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); display: grid; grid-template-rows:auto 1fr; gap: 0; }
  .verify-screen > .brand-mark { position: static; width: 46px; height: 46px; }
  .verify-screen > .locked { align-self: center; width: 100%; margin: -30px 0 0; padding: 24px 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
  .verify-screen .locked h1 { font-size: clamp(29px, 8vw, 36px); letter-spacing: -1.4px; }
  .verify-screen .locked > p { max-width: 390px; font-size: 14px; }
  .topbar { height: 88px; align-items: center; }
  .topbar > div { width: 100%; text-align: center; }
  .topbar .new-chat { position: absolute; right: 18px; }
  .code-card { margin: 14px 16px; padding: 18px; border-radius: var(--radius-lg); }
  .section { padding-left: 16px; padding-right: 16px; }
  .section.chats { padding-bottom: 84px; }
  .profile-topbar > div { text-align: left; }
  .profile-page { padding: 16px 18px 92px; }
  .pending-stage { padding: 18px; }
  .pending-card, .session-disconnected { padding: 30px 22px; border-radius: 20px; }
  .closed-actions { align-items: stretch; flex-direction: column; }
  .closed-actions form, .delete-local { width: 100%; }
}

@media (min-width: 720px) {
  body { min-height: 100dvh; padding: 24px; align-items: center; }
  .app-shell { width: min(1180px, calc(100vw - 48px)); height: min(900px, calc(100dvh - 48px)); min-height: 620px; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-shell); }
  .app-shell.has-desktop-nav { padding-left: 250px; }
  .page-surface { height: 100%; min-height: 0; overflow: auto; }
  .desktop-nav { display: flex; position: absolute; inset: 0 auto 0 0; width: 250px; padding: 32px 26px 26px; flex-direction: column; border-right: 1px solid var(--line); }
  .desktop-profile { margin: 40px 0 32px; }
  .desktop-nav nav a { padding: 13px 14px; }
  .desktop-logout { margin-top: auto; padding: 13px 14px; }
  .topbar { height: 112px; padding: 30px 42px 20px; }
  .section { max-width: 850px; padding-left: 42px; padding-right: 42px; }
  .profile-page { padding: 28px 42px 48px; }
  .code-card { max-width: 766px; margin-left: 42px; margin-right: 42px; }
  .bottom-nav { display: none; }
  .conversation { height: 100%; min-height: 0; }
  .chat-header { padding-left: 34px; padding-right: 34px; }
  .chat-header .back { display: none; }
  .message-list { padding: 30px clamp(44px, 7vw, 108px); }
  .bubble-row { max-width: min(66%, 620px); }
  .composer-wrap { padding: 13px clamp(32px, 6vw, 90px) 18px; }
  .composer { max-width: 850px; margin-inline: auto; }
  .encryption-banner { display: none; }
  .access-screen { padding: 34px 44px !important; }
  .access-screen > .back { display: grid !important; }
  .app-shell:not(.has-desktop-nav) { max-width: 1060px; padding-left: 0; }
  .app-shell:not(.has-desktop-nav) .login-screen.login-v3 { height: 100%; min-height: 0; }
}

@media (min-width: 1400px) {
  .app-shell { max-width: 1260px; }
  .app-shell.has-desktop-nav { padding-left: 270px; }
  .desktop-nav { width: 270px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .motion-ready [data-reveal] { opacity: 1; transform: none; }
}
