/* FlakChat v3 — dark design system, Option C */

:root {
  /* Base layers — dark navy, not pure black */
  --bg:            #050810;
  --bg-secondary:  #0d1525;
  --bg-tertiary:   #111d30;
  --grouped-bg:    #0d1525;

  /* Separators */
  --separator:        rgba(255,255,255,.07);
  --separator-opaque: #1a2640;

  /* Type */
  --label:            #FFFFFF;
  --label-secondary:  rgba(255,255,255,.70);
  --label-tertiary:   rgba(255,255,255,.55);
  --label-quaternary: rgba(255,255,255,.30);

  /* Accent — cyan to deep blue */
  --accent:        #19C9F9;
  --accent-dark:   #0057A3;
  --accent-mid:    #3BBFE8;
  --accent-bg:     rgba(25,201,249,.12);

  /* Semantic */
  --red:    #FF6B6B;
  --green:  #5EE87A;
  --orange: #FFB347;
  --yellow: #FFD166;

  /* Bubbles */
  --bubble-mine:        linear-gradient(135deg, #19C9F9 0%, #0057A3 100%);
  --bubble-theirs:      #1a2640;
  --bubble-mine-text:   #FFFFFF;
  --bubble-theirs-text: #FFFFFF;

  /* Layout */
  --nav-height:    52px;
  --tab-height:    56px;
  --compose-height: 60px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     22px;

  /* Fonts */
  --font:         -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  --font-display: -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'SF Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

  /* Shadows — more dramatic on dark */
  --shadow-sm: 0 1px 4px rgba(0,0,0,.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; height: 100dvh;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}

/* ── shell ───────────────────────────────────────────────────────────── */
.shell {
  display: flex;
  flex-direction: column;
  height: 100%; height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}
@media (max-height: 500px) {
  /* landscape on phones — fill full width, respect notch */
  .shell {
    max-width: 100%;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  /* compact nav bar in landscape */
  .nav-bar { height: 44px; }
  /* compact compose bar in landscape */
  .compose-bar { padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
  /* hide tab labels in landscape to save space */
  .tab-item { font-size: 0; gap: 0; }
  .tab-item svg { width: 22px; height: 22px; }
  .tab-bar {
    height: calc(44px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── nav bar ─────────────────────────────────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 8px 0 4px;
  background: rgba(13,21,37,.95);
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.3px;
  color: var(--label);
  white-space: nowrap;
  pointer-events: none;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--accent-mid);
  font-size: 15px;
  font-family: var(--font);
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-width: 44px;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.nav-btn:active { opacity: .6; }
.nav-btn.destructive { color: var(--red); }
.nav-spacer { flex: 1; }

.nav-badge {
  display: inline-flex;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 4px;
}

/* ── tab bar ─────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  height: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px));
  background: rgba(13,21,37,.95);
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: rgba(255,255,255,.55);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .2px;
  transition: color .15s;
  padding-bottom: 2px;
}
.tab-item.active { color: var(--accent-mid); }
.tab-item svg { width: 24px; height: 24px; }

/* ── auth screens ────────────────────────────────────────────────────── */
.auth-immersive {
  position: relative;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 52px 24px 52px;
  background: #050810;
  z-index: 0;
}

.auth-immersive::before {
  content: '';
  position: absolute;
  top: -5%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(25,201,249,.22) 0%, rgba(0,87,163,.14) 40%, transparent 68%);
  border-radius: 50%;
  animation: glowPulse 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
.auth-immersive::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35%;
  background: linear-gradient(to top, rgba(0,87,163,.08), transparent);
  pointer-events: none;
  z-index: 0;
}
@keyframes glowPulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50%       { opacity: .65; transform: translateX(-50%) scale(1.08); }
}
.auth-immersive > * { position: relative; z-index: 1; }

.auth-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
  width: 100%;
  text-align: center;
}
.auth-logo {
  width: 76px; height: 76px;
  border-radius: 20px;
  margin-bottom: 18px;
  box-shadow: 0 0 0 1px rgba(25,201,249,.25), 0 8px 32px rgba(25,201,249,.2);
}
.auth-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.8px;
  color: #FFFFFF;
  margin-bottom: 8px;
  text-align: center;
}
.auth-sub {
  font-size: 15px;
  color: rgba(255,255,255,.45);
  text-align: center;
  line-height: 1.5;
  letter-spacing: .1px;
}
.auth-card {
  width: 100%;
  background: rgba(13,21,37,.85);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 14px;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  color-scheme: dark;
  padding-bottom: 4px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: transparent;
  position: relative;
}
.auth-field:last-child { border-bottom: none; }
.auth-field label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 5px;
}
.auth-field input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: var(--font);
  color: #FFFFFF;
  padding: 4px 0;
  width: 100%;
  caret-color: var(--accent);
  -webkit-text-fill-color: #FFFFFF;
  color-scheme: dark;
}
.auth-field input::placeholder { color: rgba(255,255,255,.25); }
.auth-field input:-webkit-autofill,
.auth-field input:-webkit-autofill:hover,
.auth-field input:-webkit-autofill:focus,
.auth-field input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 2000px #0d1525 inset !important;
  -webkit-text-fill-color: #FFFFFF !important;
  caret-color: var(--accent) !important;
  border-radius: 0 !important;
  transition: background-color 9999s ease 0s, color 9999s ease 0s;
}
.auth-field input.code-input {
  font-family: var(--font-mono);
  letter-spacing: 4px;
  font-size: 18px;
}
.auth-immersive .btn-primary {
  background: linear-gradient(135deg, #19C9F9 0%, #0A6FBB 100%);
  box-shadow: 0 4px 24px rgba(25,201,249,.35), 0 1px 0 rgba(255,255,255,.15) inset;
  font-size: 17px;
  letter-spacing: -.1px;
  border-radius: 14px;
  height: 52px;
}
.auth-immersive .btn-primary:active {
  transform: scale(.98);
  box-shadow: 0 2px 12px rgba(25,201,249,.25);
}
.auth-link-row {
  font-size: 15px;
  color: rgba(255,255,255,.35);
  text-align: center;
  margin-top: 6px;
}
.auth-link-row a { color: rgba(255,255,255,.65); text-decoration: none; font-weight: 500; }
.auth-link-row a:hover { color: #fff; }
.auth-status {
  font-size: 14px;
  text-align: center;
  min-height: 1.4em;
  margin-top: 6px;
  color: rgba(255,255,255,.5);
}
.auth-status.err { color: #FF6B6B; }
.auth-status.ok  { color: #5EE87A; }
.auth-screen {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 40px;
  background: var(--bg);
}

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-xl);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  width: 100%;
  transition: opacity .15s, transform .1s;
  position: relative;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(25,201,249,.3);
}
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--accent-mid);
  border: 1px solid var(--separator-opaque);
}
.btn-ghost {
  background: none;
  color: var(--accent-mid);
}
.btn-danger {
  background: rgba(255,107,107,.12);
  color: var(--red);
  border: 1px solid rgba(255,107,107,.2);
}
.btn .spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: block; }
.btn.loading .btn-label { opacity: .5; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── status messages ─────────────────────────────────────────────────── */
.status-msg {
  font-size: 14px;
  color: var(--label-secondary);
  text-align: center;
  min-height: 1.4em;
  margin-top: 8px;
}
.status-msg.err { color: var(--red); }
.status-msg.ok  { color: var(--green); }
.link-row {
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
  margin-top: 4px;
}
.link-row a { color: var(--accent-mid); text-decoration: none; font-weight: 500; }

/* ── main content ────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--label-tertiary);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 20px 20px 8px;
}

/* ── thread list ─────────────────────────────────────────────────────── */
.thread-list { padding: 0; }
.swipe-row-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--separator);
  display: flex;
  flex-direction: column;
}
.swipe-row-wrap:first-child { border-top: 1px solid var(--separator); }
.swipe-actions {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  display: flex;
  align-items: stretch;
  min-height: 100%;
}
.swipe-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .2px;
  min-width: 80px;
  min-height: 60px;
  -webkit-tap-highlight-color: transparent;
}
.swipe-action-btn.delete  { background: var(--red); }
.swipe-action-btn.leave   { background: var(--orange); }
.swipe-action-btn.remove  { background: var(--orange); }
.swipe-action-btn.block   { background: #8A74F9; }

.thread-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--grouped-bg);
  cursor: pointer;
  transition: transform .2s cubic-bezier(.25,.46,.45,.94), background .1s;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  position: relative;
  z-index: 1;
}
.thread-row:active { background: var(--bg-tertiary); }
.thread-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(25,201,249,.3);
}
.thread-info { flex: 1; min-width: 0; }
.thread-name {
  font-size: 16px; font-weight: 600;
  color: var(--label);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.thread-meta {
  font-size: 13px;
  color: var(--label-secondary);
  display: flex; align-items: center; gap: 6px;
}
.thread-chevron { color: var(--label-tertiary); font-size: 18px; flex-shrink: 0; }
.thread-unread {
  background: var(--accent-mid);
  color: #fff;
  font-size: 12px; font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
}

/* ── tier badges ─────────────────────────────────────────────────────── */
.tier-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: .3px;
}
.tier-badge.standard  { background: rgba(25,201,249,.15);  color: var(--accent-mid); }
.tier-badge.ephemeral { background: rgba(255,179,71,.15);  color: var(--orange); }
.tier-badge.vault     { background: rgba(138,116,249,.15); color: #8A74F9; }

/* ── contact rows ────────────────────────────────────────────────────── */
.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--grouped-bg);
  transition: transform .2s cubic-bezier(.25,.46,.45,.94);
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  position: relative;
  z-index: 1;
}
.contact-handle { flex: 1; font-size: 16px; font-weight: 500; color: var(--label); }
.contact-actions { display: flex; gap: 8px; }
.contact-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
}
.contact-btn.accept  { background: rgba(94,232,122,.15); color: var(--green); border: 1px solid rgba(94,232,122,.3); }
.contact-btn.decline { background: var(--bg-tertiary); color: var(--label-secondary); border: 1px solid var(--separator-opaque); }

/* ── empty state ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  gap: 12px;
  text-align: center;
}
.empty-state-icon { font-size: 48px; margin-bottom: 4px; opacity: .4; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--label); }
.empty-state p  { font-size: 15px; line-height: 1.5; color: var(--label-secondary); }

/* ── FAB ─────────────────────────────────────────────────────────────── */
.fab {
  position: absolute;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px) + 16px);
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-size: 26px; font-weight: 300;
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(25,201,249,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: scale(.92); box-shadow: 0 2px 10px rgba(25,201,249,.3); }

/* ── conversation ────────────────────────────────────────────────────── */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
.msg-row { display: flex; margin: 1px 0; }
.msg-row.mine   { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }
.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
  transition: opacity .2s;
  position: relative;
}
.msg-row.mine .bubble {
  background: linear-gradient(135deg, #19C9F9 0%, #0057A3 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .bubble {
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--separator);
}
.bubble.redacted {
  background: var(--label-quaternary) !important;
  color: transparent !important;
  border-radius: 18px !important;
  user-select: none;
}
.bubble.redacted::after {
  content: '🔒';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  font-size: 14px;
}

/* lock prompt */
.lock-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 14px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.lock-prompt::before {
  content: '';
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(138,116,249,.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.lock-icon {
  font-size: 0;
  width: 64px; height: 64px;
  background: rgba(138,116,249,.12);
  border: 1px solid rgba(138,116,249,.2);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  position: relative;
}
.lock-icon::after {
  content: '';
  display: block;
  width: 28px; height: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(138,116,249,.9)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.lock-title { font-size: 20px; font-weight: 700; color: var(--label); text-align: center; position: relative; }
.lock-sub   { font-size: 14px; color: var(--label-secondary); text-align: center; line-height: 1.5; position: relative; }

/* key inputs */
.key-fields { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.key-field-wrap {
  background: var(--grouped-bg);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.key-field-wrap label {
  font-size: 11px; font-weight: 600;
  color: var(--label-tertiary);
  text-transform: uppercase; letter-spacing: .5px;
  display: block; margin-bottom: 4px;
}
.key-field-wrap input {
  background: none; border: none; outline: none;
  font-size: 16px;
  font-family: var(--font-mono);
  color: var(--label);
  width: 100%;
  caret-color: var(--accent);
}
.key-field-wrap input::placeholder { color: var(--label-tertiary); font-family: var(--font); }

.remember-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--label-secondary);
  cursor: pointer; padding: 4px 0;
}
.remember-row input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--accent-mid);
  cursor: pointer;
}

/* ── compose bar ─────────────────────────────────────────────────────── */
.compose-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--separator);
  flex-shrink: 0;
}
.compose-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--separator-opaque);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--label);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  height: 38px;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color .15s, height .1s ease;
  caret-color: var(--accent);
  -webkit-overflow-scrolling: touch;
}
.compose-input:focus { border-color: var(--accent); }
.compose-input::placeholder { color: var(--label-tertiary); }
.send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border: none; cursor: pointer;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 1px;
  box-shadow: 0 2px 8px rgba(25,201,249,.35);
  transition: transform .1s;
}
.send-btn:active { transform: scale(.9); }
.hide-btn {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  padding: 4px; opacity: .4;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 3px;
}
.hide-btn:active { opacity: 1; }

/* ── bottom sheet ────────────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 100;
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  background: var(--bg-secondary);
  border: 1px solid var(--separator-opaque);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 20px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; margin: 0 auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.25,.46,.45,.94);
  max-height: 90vh; overflow-y: auto;
}
.sheet-overlay.open .sheet { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--separator-opaque);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -.3px;
  color: var(--label);
}

/* preset cards */
.preset-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  cursor: pointer;
  border-width: 2px;
  border-color: transparent;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.preset-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.preset-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.preset-icon.standard  { background: rgba(25,201,249,.15); }
.preset-icon.ephemeral { background: rgba(255,179,71,.15); }
.preset-icon.vault     { background: rgba(138,116,249,.15); }
.preset-text strong { display: block; font-size: 16px; font-weight: 600; margin-bottom: 2px; color: var(--label); }
.preset-text span   { font-size: 13px; color: var(--label-secondary); line-height: 1.4; }

/* key count picker */
.key-count-row { display: flex; gap: 8px; margin-bottom: 16px; }
.key-count-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-md);
  border: 2px solid var(--separator-opaque);
  background: var(--bg-tertiary);
  color: var(--label-secondary);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.key-count-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-mid);
}

/* generated keys */
.generated-keys {
  background: var(--bg-tertiary);
  border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.generated-keys-label {
  font-size: 12px; font-weight: 600;
  color: var(--label-secondary);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.generated-key-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--separator);
}
.generated-key-row:last-child { border-bottom: none; }
.generated-key-num { font-size: 12px; font-weight: 600; color: var(--label-tertiary); width: 20px; flex-shrink: 0; }
.key-override-input {
  flex: 1;
  background: none; border: none; outline: none;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--label);
  caret-color: var(--accent);
}
.key-override-input::placeholder { color: var(--label-tertiary); font-family: var(--font); font-size: 13px; }

.copy-all-btn {
  background: var(--accent-bg);
  border: 1px solid rgba(25,201,249,.3);
  color: var(--accent-mid);
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.copy-all-btn:active { opacity: .7; }

.warning-box {
  background: rgba(255,179,71,.08);
  border: 1px solid rgba(255,179,71,.25);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--orange);
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── vault notes ─────────────────────────────────────────────────────── */
.note-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--grouped-bg);
  cursor: pointer;
  transition: transform .2s cubic-bezier(.25,.46,.45,.94), background .1s;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  position: relative;
  z-index: 1;
}
.note-row:active { background: var(--bg-tertiary); }
.note-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(138,116,249,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  overflow: hidden;
}
.note-info { flex: 1; min-width: 0; }
.note-title { font-size: 16px; font-weight: 600; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.note-meta { font-size: 13px; color: var(--label-secondary); }

.note-title-input {
  background: none; border: none; outline: none;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  color: var(--label);
  padding: 16px 20px 8px;
  width: 100%;
  caret-color: var(--accent);
}
.note-body-input {
  flex: 1;
  background: none; border: none; outline: none;
  font-family: var(--font);
  font-size: 16px;
  color: var(--label);
  padding: 8px 20px 20px;
  resize: none;
  line-height: 1.6;
  caret-color: var(--accent);
}
.note-locked-view {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px; gap: 16px;
}

/* ── divider ─────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--separator); margin: 0 16px; }

/* ── auth form short viewport fix ───────────────────────────────────── */
@media (max-height: 750px) {
  .auth-lockup { margin-bottom: 24px; }
  .auth-lockup .auth-logo { width: 56px; height: 56px; margin-bottom: 12px; }
  .auth-title { font-size: 24px; }
  .auth-field { padding: 11px 18px; }
  .auth-card { margin-bottom: 12px; }
}
@media (max-height: 600px) {
  .auth-lockup { margin-bottom: 16px; }
  .auth-lockup .auth-logo { display: none; }
  .auth-title { font-size: 20px; margin-bottom: 4px; }
  .auth-field { padding: 9px 16px; }
}

/* ── date separators ─────────────────────────────────────────────────────── */
.date-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 6px;
  pointer-events: none;
}
.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--separator);
}
.date-separator-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-tertiary);
  letter-spacing: .4px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── read indicators ─────────────────────────────────────────────────────── */
.msg-row.mine .bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 72%;
  margin-left: auto;
}
.msg-row.mine .bubble-wrap .bubble {
  max-width: none;
  width: 100%;
}
.read-indicator {
  font-size: 10px;
  color: var(--label-tertiary);
  margin-top: 2px;
  margin-right: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
  transition: color .3s;
}
.read-indicator.read {
  color: var(--accent-mid);
}
