/* ============================================================
   GEMC2 — App CSS
   All colors live in :root. Change there to re-theme the app.
   ============================================================ */

:root {
  /* ---- Colors (change here to re-theme) ---- */
  --color-bg:              #101010;
  --color-bg-elevated:     #151515;
  --color-bg-input:        #1a1a1a;
  --color-bg-hover:        #202020;

  --color-border:          #2b2b2b;
  --color-border-strong:   #454545;

  --color-accent:          #00e63b;   /* Matrix green, slightly softer */
  --color-accent-dim:      #00c735;
  --color-accent-soft:     rgba(0, 230, 59, 0.08);

  --color-text:            #dedede;   /* Main readable text */
  --color-text-strong:     #f0f0f0;   /* Headings */
  --color-text-muted:      #929292;   /* Metadata: clearer without competing with posts */
  --color-text-inverse:    #101010;   /* Text on accent */

  --color-error:           #ff5c5c;
  --color-warning:         #ffb84d;
  --color-success:         var(--color-accent);

  --color-founder:         #ffd700;   /* Gold for founder badge */

  /* ---- Typography ---- */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fs-xs:  0.75rem;
  --fs-sm:  0.875rem;
  --fs-md:  1rem;
  --fs-post: 1rem;
  --fs-lg:  1.125rem;
  --fs-xl:  1.5rem;
  --fs-2xl: 2rem;
  --lh:     1.6;

  /* ---- Spacing ---- */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;

  /* ---- Radius ---- */
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 8px;

  /* ---- Layout ---- */
  --max-w: 560px;
  --header-h: 72px;

  /* ---- Safe area (iPhone notch + home indicator) ---- */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  /* ---- Motion ---- */
  --t-fast: 120ms ease;
  --t-med:  220ms ease;
}

/* ============================================================
   Reset
   ============================================================ */

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover { color: var(--color-accent-dim); }

button { font: inherit; color: inherit; }

h1, h2, h3 { color: var(--color-text-strong); margin: 0 0 var(--s-4); }

/* ============================================================
   Layout
   ============================================================ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) calc(var(--s-4) + var(--safe-right)) 0 calc(var(--s-4) + var(--safe-left));
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  transition: opacity var(--t-fast);
}

.view-logo {
  display: block;
  width: 120px;
  height: 120px;
  margin: 0 auto var(--s-5);
  object-fit: contain;
}

.brand:hover .brand-logo { opacity: 0.75; }

.header-slot { display: flex; align-items: center; gap: var(--s-3); }

.app-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--header-h) + var(--safe-top) + var(--s-5)) calc(var(--s-4) + var(--safe-right)) calc(var(--s-7) + var(--safe-bottom)) calc(var(--s-4) + var(--safe-left));
}

/* ============================================================
   Views
   ============================================================ */

.view { display: none; }
.view.is-active { display: block; }

.view-title {
  font-size: var(--fs-xl);
  letter-spacing: 0.04em;
  margin-bottom: var(--s-5);
}

.view-footer {
  margin-top: var(--s-5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  font-size: var(--fs-sm);
}

/* ============================================================
   Form
   ============================================================ */

.form { display: flex; flex-direction: column; gap: var(--s-4); }

.field { display: flex; flex-direction: column; gap: var(--s-2); }

.field-label {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.input {
  width: 100%;
  padding: var(--s-3) var(--s-3);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--r-sm);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--fs-md);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.input:hover { background: var(--color-bg-hover); }

.input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-bg-hover);
}

.input::placeholder { color: var(--color-text-muted); }

.form-error {
  display: none;
  padding: var(--s-3);
  border: 1px solid var(--color-error);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  color: var(--color-error);
  font-size: var(--fs-sm);
  background: rgba(255, 92, 92, 0.06);
}

.form-error.is-visible { display: block; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-sm);
  color: var(--color-text);
  cursor: pointer;
  font-size: var(--fs-sm);
  letter-spacing: 0.05em;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  text-align: center;
}

.btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--color-accent-dim);
  border-color: var(--color-accent-dim);
  color: var(--color-text-inverse);
}

/* ============================================================
   Status / metadata
   ============================================================ */

.status {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  padding: var(--s-3) 0;
}

/* ============================================================
   User handle + founder badge
   ============================================================ */

.post-user {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
  text-decoration: none;
  flex-wrap: wrap;
}

.post-user-inline {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-1);
  text-decoration: none;
}

.post-display-name {
  color: var(--color-text-strong);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.post-display-name.is-founder {
  color: var(--color-founder);
}

.post-sep {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

.post-handle {
  font-family: var(--font-mono);
  color: var(--color-accent-dim);
  font-size: var(--fs-md);
}

.post-user:hover .post-display-name {
  text-decoration: underline;
}

.post-user:hover .post-handle {
  color: var(--color-accent);
}

.user-handle {
  font-family: var(--font-mono);
  color: var(--color-accent-dim);
  font-size: 1.25rem;
}

.user-handle.is-founder {
  color: var(--color-founder);
  font-weight: 700;
}

.user-handle.is-founder::before {
  content: "◆ ";
  color: var(--color-founder);
}

.user-display {
  color: var(--color-text-strong);
  font-size: var(--fs-md);
}

.badge-founder {
  display: inline-block;
  padding: 0 var(--s-2);
  margin-left: var(--s-2);
  border: 1px solid var(--color-founder);
  border-radius: var(--r-sm);
  color: var(--color-founder);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  vertical-align: middle;
}

/* ============================================================
   Home
   ============================================================ */

.home-tagline {
  color: var(--color-text);
  font-size: var(--fs-lg);
  margin: 0 0 var(--s-5);
}

.home-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }

.home-user-info {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.home-note {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s-5);
}

/* ============================================================
   Toasts
   ============================================================ */

.toasts {
  position: fixed;
  bottom: calc(var(--s-4) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 100;
  width: min(calc(100% - var(--s-4) * 2), var(--max-w));
  pointer-events: none;
}

.toast {
  padding: var(--s-3) var(--s-4);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-strong);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--color-text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-med), transform var(--t-med);
  pointer-events: auto;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

.toast.is-error   { border-left-color: var(--color-error);   color: var(--color-error); }
.toast.is-warning { border-left-color: var(--color-warning); color: var(--color-warning); }
.toast.is-success { border-left-color: var(--color-success); color: var(--color-success); }

/* ============================================================
   Utility
   ============================================================ */

[hidden] { display: none !important; }

/* ============================================================
   Composer
   ============================================================ */

.composer {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--s-4);
}

.composer-input {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  font-size: var(--fs-md);
  line-height: var(--lh);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--r-sm);
  padding: var(--s-3);
  color: var(--color-text);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.composer-input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-bg-hover);
}

.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--s-2);
  gap: var(--s-3);
}

.composer-count {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

.composer-count.is-over { color: var(--color-error); }

/* ============================================================
   Feed
   ============================================================ */

.feed { display: flex; flex-direction: column; }

.post {
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.post-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}

.post-time {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.post-content {
  color: var(--color-text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0 0 var(--s-3);
  font-size: var(--fs-post);
  line-height: 1.68;
}

.post-content.is-collapsed {
  max-height: 170px;
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
}

.post-show-more {
  display: block;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 var(--s-3);
  color: var(--color-accent);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  transition: color var(--t-fast);
}

.post-show-more:hover { color: var(--color-accent-dim); }

.post-actions {
  display: flex;
  gap: var(--s-4);
  font-size: var(--fs-sm);
}

.post-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 var(--s-1);
  font: inherit;
  font-size: var(--fs-sm);
  transition: color var(--t-fast);
}

.post-action:hover { color: var(--color-accent); }

.post-editor {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.post-editor-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
}

.post-edits {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-sm);
}

.post-edits-title {
  color: var(--color-text-muted);
  margin: 0 0 var(--s-3);
  letter-spacing: 0.05em;
}

.post-edit-item {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.post-edit-item:last-child { border-bottom: none; }

.post-edit-time {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin-bottom: var(--s-2);
}

.post-edit-content {
  color: var(--color-text);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.post-back {
  margin-bottom: var(--s-4);
  font-size: var(--fs-sm);
}

.feed-more {
  display: flex;
  justify-content: center;
  padding: var(--s-5) 0;
}

.feed-empty {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  text-align: center;
  padding: var(--s-5) 0;
}

/* ============================================================
   Replies
   ============================================================ */

.post-reply-indicator {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin: 0 0 var(--s-1);
}

.post-reply-indicator .post-reply-to {
  color: var(--color-accent);
}

.post-replies {
  margin-top: var(--s-5);
}

.post-replies-title {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  letter-spacing: 0.05em;
  margin: 0 0 var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--color-border);
}

.reply-composer {
  margin: var(--s-4) 0;
  padding: var(--s-4) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.reply-composer .composer-input {
  min-height: 60px;
}

.reply-context {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin-bottom: var(--s-2);
}

.reply-context .post-reply-to {
  color: var(--color-accent);
}

.post-like {
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0;
  transition: color var(--t-fast);
}

.post-like:hover { color: var(--color-accent); }

.post-like.is-liked {
  color: var(--color-accent);
  font-weight: 700;
}

.post-like:disabled { opacity: 0.6; cursor: wait; }

.post-repost {
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0;
  transition: color var(--t-fast);
}

.post-repost:hover { color: var(--color-accent); }

.post-repost.is-reposted {
  color: var(--color-accent);
  font-weight: 700;
}

.post-repost:disabled { opacity: 0.6; cursor: wait; }

.post-repost-indicator {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin: 0 0 var(--s-2);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.post-repost-indicator .reposter-handle {
  color: var(--color-accent-dim);
  font-size: var(--fs-md);
}

.post-repost-indicator .reposter-handle.is-founder {
  color: var(--color-founder);
  font-weight: 700;
}

.post-repost-indicator .reposter-handle.is-founder::before {
  content: "◆ ";
}

.btn-small {
  padding: var(--s-1) var(--s-3);
  font-size: var(--fs-xs);
}

.header-handle {
  color: var(--color-accent-dim);
  font-size: var(--fs-lg);
}

.header-handle.is-founder {
  color: var(--color-founder);
  font-weight: 700;
}

.header-handle.is-founder::before {
  content: "◆ ";
}

.hashtag {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--t-fast);
}

.hashtag:hover { color: var(--color-accent-dim); }

.post.is-card {
  cursor: pointer;
}

/* ============================================================
   Profile
   ============================================================ */

.profile {
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--s-4);
}

.profile-head {
  margin-bottom: var(--s-3);
}

.profile-handle {
  display: block;
  color: var(--color-accent-dim);
  font-size: 1.25rem;
  margin-bottom: var(--s-1);
}

.profile-handle.is-founder {
  color: var(--color-founder);
  font-weight: 700;
}

.profile-handle.is-founder::before {
  content: "◆ ";
}

.profile-display {
  color: var(--color-text-strong);
  font-size: var(--fs-md);
  font-weight: 500;
}

.profile-bio {
  color: var(--color-text);
  font-size: var(--fs-md);
  margin: var(--s-3) 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.profile-meta {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-3);
}

.profile-counters {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.profile-counter strong {
  color: var(--color-text-strong);
  font-weight: 700;
}

.profile-actions {
  display: flex;
  gap: var(--s-3);
}

/* ============================================================
   Settings
   ============================================================ */

.settings-section {
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--color-border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section-title {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 var(--s-4);
}

/* ============================================================
   Mentions
   ============================================================ */

.mention {
  color: var(--color-accent-dim);
  text-decoration: none;
  transition: color var(--t-fast);
}

.mention:hover {
  color: var(--color-accent);
}

.profile-blocked {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin: var(--s-3) 0;
  padding: var(--s-3);
  border-left: 3px solid var(--color-warning);
  background: rgba(255, 184, 77, 0.06);
  border-radius: var(--r-sm);
}

/* ============================================================
   Notifications
   ============================================================ */

.notifications-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.notifications-heading .view-title {
  margin-bottom: 0;
}

.notifications {
  display: flex;
  flex-direction: column;
}

.notif {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--fs-md);
}

.notif.is-unread {
  background: rgba(0, 255, 65, 0.04);
  border-left: 3px solid var(--color-accent);
  padding-left: var(--s-3);
}

.notif-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-1);
}

.notif-display {
  color: var(--color-text-strong);
  font-weight: 600;
}

.notif-display.is-founder {
  color: var(--color-founder);
}

.notif-handle {
  color: var(--color-accent-dim);
}

.notif-text {
  color: var(--color-text-muted);
}

.notif-time {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  flex-shrink: 0;
}

.btn-notif-active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 700;
}

/* ============================================================
   Feed tabs
   ============================================================ */

.feed-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--s-4);
  margin-left: calc(-1 * var(--safe-left));
  margin-right: calc(-1 * var(--safe-right));
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top));
  background: var(--color-bg);
  z-index: 5;
}

.feed-tab {
  flex: 1;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--s-3);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  letter-spacing: 0.05em;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.feed-tab:hover {
  color: var(--color-text);
  background: var(--color-bg-hover);
}

.feed-tab.is-active {
  color: var(--color-accent);
  border-bottom: 3px solid var(--color-accent);
  font-weight: 700;
}

/* ============================================================
   Mobile / iOS adjustments
   ============================================================ */

.header-text { display: inline; }
.header-icon { display: none; }
.header-icon-wrap { position: relative; display: inline-flex; }
.header-btn { padding: var(--s-2) var(--s-3); }

/* Badge de mensajes privados: hijo directo del enlace para que sea visible
   tanto en escritorio como en móvil, sin depender de .header-icon. */
.header-messages-btn { position: relative; }
.messages-unread-dot {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 2px solid var(--color-bg);
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-sizing: border-box;
  pointer-events: none;
}


.notif-dot {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

@media (max-width: 600px) {
  .header-text { display: none; }
  .header-icon { display: inline-flex; align-items: center; justify-content: center; }

  .header-slot { gap: var(--s-1); }

  .header-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
  }

  .header-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
  }

  .btn-small {
    min-height: 40px;
    min-width: 40px;
  }

  .notif-dot {
    top: -4px;
    right: -6px;
    font-size: 9px;
    padding: 2px 4px;
  }

  .post-actions {
    gap: var(--s-3);
    flex-wrap: wrap;
  } 

  .post-like,
  .post-repost,
  .post-action {
    padding: var(--s-2) var(--s-1);
    min-height: 36px;
  }
}

@supports (-webkit-touch-callout: none) {
  .app-header {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  button, a, .post.is-card {
    -webkit-tap-highlight-color: transparent;
  }

  @media (hover: none) {
    .btn:hover { border-color: var(--color-border-strong); color: var(--color-text); }
    .btn-primary:hover { background: var(--color-accent); border-color: var(--color-accent); }
    .post-user:hover .post-display-name { text-decoration: none; }
    .post-user:hover .post-handle { color: var(--color-accent-dim); }
    .hashtag:hover { color: var(--color-accent); }
    .mention:hover { color: var(--color-accent-dim); }
  }
}

/* ============================================================
   Admin
   ============================================================ */

.header-admin {
  border-color: var(--color-founder);
  color: var(--color-founder);
}

.header-admin:hover {
  border-color: var(--color-founder);
  color: var(--color-founder);
}

.admin-tabs {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.admin-tab {
  background: none;
  border: none;
  padding: var(--s-3) var(--s-3);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.admin-tab:hover { color: var(--color-text); }

.admin-tab.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 700;
}

.admin-tab.has-badge {
  color: var(--color-accent);
  font-weight: 700;
}

.admin-tab.has-badge.is-active {
  border-bottom-color: var(--color-accent);
}

.admin-reports { display: flex; flex-direction: column; }

.admin-report {
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.admin-report-head {
  display: flex;
  gap: var(--s-3);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--s-2);
  flex-wrap: wrap;
}

.admin-report-id { color: var(--color-text-strong); font-weight: 700; }
.admin-report-cat { color: var(--color-warning); }
.admin-report-sev { color: var(--color-error); }

.admin-report-parties {
  font-size: var(--fs-sm);
  color: var(--color-text);
  margin-bottom: var(--s-3);
}

.admin-user { color: var(--color-accent-dim); }
.admin-user-link { color: var(--color-accent); }

.admin-post {
  margin: var(--s-3) 0;
  padding: var(--s-3);
  background: var(--color-bg-elevated);
  border-left: 3px solid var(--color-border-strong);
  border-radius: var(--r-sm);
}

.admin-post-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--s-2);
}

.admin-hidden-tag {
  color: var(--color-error);
  font-weight: 700;
  margin-left: var(--s-2);
}

.admin-post-content {
  color: var(--color-text);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: var(--s-3);
  max-height: 120px;
  overflow-y: auto;
}

.admin-post-actions {
  display: flex;
  gap: var(--s-2);
}

.admin-report-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.admin-danger {
  border-color: var(--color-error);
  color: var(--color-error);
}

.admin-danger:hover {
  border-color: var(--color-error);
  background: rgba(255, 92, 92, 0.08);
  color: var(--color-error);
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

.modal {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-md);
  padding: var(--s-5);
  max-width: 420px;
  width: 100%;
}

.modal-title {
  margin: 0 0 var(--s-4);
  font-size: var(--fs-lg);
  color: var(--color-text-strong);
}

.modal-body {
  margin-bottom: var(--s-4);
}

.modal-actions {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  cursor: pointer;
}

/* ============================================================
   Admin — Users
   ============================================================ */

.admin-tab-sep {
  margin-left: var(--s-4);
  border-left: 1px solid var(--color-border);
  padding-left: var(--s-4);
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.admin-user-info {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.admin-user-display {
  color: var(--color-text-strong);
  font-weight: 600;
}

.admin-user-display.is-founder {
  color: var(--color-founder);
}

.admin-user-handle {
  font-family: var(--font-mono);
  color: var(--color-accent-dim);
}

.admin-user-status {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--color-border-strong);
}

.admin-user-status.is-suspended {
  color: var(--color-error);
  border-color: var(--color-error);
}

.admin-user-status.is-admin {
  color: var(--color-founder);
  border-color: var(--color-founder);
}

.admin-user-actions {
  display: flex;
  gap: var(--s-2);
}

.admin-user-note {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  padding: 0 var(--s-3);
}

/* ============================================================
   Admin — Pending registrations
   ============================================================ */

.admin-pending {
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.admin-pending-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-2);
}

.admin-pending-meta {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--s-3);
  word-break: break-all;
}

.admin-pending-answer {
  background: var(--color-bg-elevated);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--r-sm);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
}

.admin-pending-answer-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  margin-bottom: var(--s-2);
  text-transform: uppercase;
}

.admin-pending-answer-text {
  color: var(--color-text);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.admin-pending-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

/* ============================================================
   Search & Explore
   ============================================================ */

.search-form {
  margin-bottom: var(--s-5);
}

.search-input {
  font-size: var(--fs-md);
}

.section-title {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: var(--s-5) 0 var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--color-border);
}

.trending-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.trending-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
  text-decoration: none;
}

.trending-item:hover {
  background: var(--color-bg-hover);
}

.trending-tag {
  color: var(--color-accent);
  font-weight: 600;
}

.trending-count {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

.user-list {
  display: flex;
  flex-direction: column;
}

.user-row {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  flex-wrap: wrap;
  transition: background var(--t-fast);
}

.user-row:hover {
  background: var(--color-bg-hover);
}

.user-row-display {
  color: var(--color-text-strong);
  font-weight: 600;
}

.user-row-display.is-founder {
  color: var(--color-founder);
}

.user-row-handle {
  color: var(--color-accent-dim);
  font-size: var(--fs-sm);
}

.user-row-bio {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  flex-basis: 100%;
  margin-top: var(--s-1);
}

/* ============================================================
   Realtime — Banner de nuevos posts
   ============================================================ */

.feed-new-banner {
  display: block;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent);
  border-radius: var(--r-sm);
  color: var(--color-accent);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  margin-bottom: var(--s-4);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.feed-new-banner:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: var(--color-accent);
}

.feed-new-banner:active {
  background: var(--color-accent-dim);
  border-color: var(--color-accent-dim);
  color: var(--color-text-inverse);
}

.app-footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}

.app-footer-links a {
  color: var(--color-text-muted);
}

.app-footer-links a:hover {
  color: var(--color-accent);
}

.app-footer-copy {
  color: var(--color-text-muted);
}

/* ============================================================
   PWA Install Banner
   ============================================================ */

.install-banner {
  position: fixed;
  bottom: calc(var(--s-4) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - var(--s-4) * 2), calc(var(--max-w) - var(--s-4) * 2));
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  z-index: 50;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  animation: install-banner-in var(--t-med) ease forwards;
}

@keyframes install-banner-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.install-banner[hidden] {
  display: none;
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 1;
  min-width: 0;
}

.install-banner-icon {
  flex-shrink: 0;
  border-radius: var(--r-sm);
}

.install-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.install-banner-text strong {
  color: var(--color-text-strong);
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner-text span {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

@media (max-width: 380px) {
  .install-banner {
    flex-wrap: wrap;
  }
  .install-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ============================================================
   WebSocket — Indicador global de conexión
   Integración independiente para GEMC2 PWA
   ============================================================ */

.ws-status-indicator {
  position: fixed;

  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));

  width: 18px;
  height: 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 50%;

  z-index: 90;

  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.ws-status-indicator-dot {
  display: block;

  width: 9px;
  height: 9px;

  border-radius: 50%;

  background: #777777;

  transition: background-color var(--t-fast);
}

/* Conexión operativa */
.ws-status-indicator.is-connected .ws-status-indicator-dot {
  background: #00e63b;
}

/* Error o desconexión inesperada */
.ws-status-indicator.is-error .ws-status-indicator-dot {
  background: #ff5c5c;
}

/* Desconectado o conexión todavía no establecida */
.ws-status-indicator.is-disconnected .ws-status-indicator-dot {
  background: #777777;
}

/* Adaptación para móviles y PWA */
@media (max-width: 600px) {
  .ws-status-indicator {
    right: calc(10px + var(--safe-right));
    bottom: calc(10px + var(--safe-bottom));

    width: 16px;
    height: 16px;
  }

  .ws-status-indicator-dot {
    width: 8px;
    height: 8px;
  }
}
/* ============================================================
   Private messaging and permanent account deactivation
   ============================================================ */
.home-private-messages {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 var(--s-3);
}

.messages-start-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-3);
  align-items: end;
  margin: var(--s-4) 0;
  padding: var(--s-4);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-bg-elevated);
}
.messages-start-form .field { margin: 0; }
.messages-device-conflict {
  margin: var(--s-4) 0;
  padding: var(--s-4);
  border: 1px solid var(--color-warning, #d6a84f);
  border-radius: var(--r-md);
  background: rgba(214, 168, 79, 0.06);
}
.messages-device-conflict .field { margin: var(--s-3) 0; }
.messages-status {
  min-height: 1.4em;
  margin: var(--s-3) 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.messages-status.is-error { color: var(--color-danger, #ff7777); }
.messages-layout {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.5fr);
  gap: var(--s-4);
  align-items: start;
}
.messages-sidebar,
.messages-chat {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-bg-elevated);
  padding: var(--s-3);
}
.messages-sidebar { max-height: 68vh; overflow: auto; }
.message-conversation {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
.message-conversation:hover,
.message-conversation.is-active {
  border-color: var(--color-border);
  background: rgba(0, 230, 59, 0.06);
}
.message-conversation strong { overflow-wrap: anywhere; }
.message-conversation-preview {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.messages-empty {
  padding: var(--s-3);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.messages-chat-header {
  padding: 0 0 var(--s-3);
  border-bottom: 1px solid var(--color-border);
}
.messages-chat-header h2 {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}
.messages-chat-header .field-hint { overflow-wrap: anywhere; }
.messages-thread {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  height: min(48vh, 560px);
  min-height: 220px;
  overflow: auto;
  padding: var(--s-3) 0;
  overscroll-behavior: contain;
}
.message-bubble {
  max-width: 88%;
  padding: var(--s-3);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.5;
}
.message-bubble.is-outgoing {
  align-self: flex-end;
  border-color: rgba(0, 230, 59, 0.35);
  background: rgba(0, 230, 59, 0.07);
}
.message-bubble.is-incoming { align-self: flex-start; }
.message-text { overflow-wrap: anywhere; }
.message-meta {
  margin-top: var(--s-2);
  color: var(--color-text-muted);
  font-size: 0.75rem;
}
.messages-send-form { margin-top: var(--s-2); }
.messages-send-form .field { margin-bottom: var(--s-3); }
.messages-send-form textarea { resize: vertical; }
.settings-danger-zone {
  margin-top: var(--s-5);
  padding: var(--s-4);
  border: 1px solid rgba(255, 92, 92, 0.35);
  border-radius: var(--r-md);
}
.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: var(--s-2);
  line-height: 1.5;
}
.checkbox-field input { margin-top: 0.25em; flex: 0 0 auto; }
.btn-danger {
  border-color: rgba(255, 92, 92, 0.55);
  color: var(--color-danger, #ff7777);
}
.btn-danger:hover { background: rgba(255, 92, 92, 0.08); }


/* Private-message privacy controls */
.message-privacy-block-row { display:flex; align-items:center; justify-content:space-between; gap:var(--s-3); padding:var(--s-2) 0; border-bottom:1px solid var(--color-border); }
.message-privacy-block-row:last-child { border-bottom:0; }
@media (max-width: 640px) { .header-messages-btn .header-text { display:none; } }

.message-conversation-row { display:flex; align-items:stretch; gap:var(--s-1); }
.message-conversation-row .message-conversation { flex:1; min-width:0; }
.message-conversation-delete { align-self:center; flex:0 0 auto; padding-inline:0.65rem; }



/* GEMC2 — mobile private chat: one consolidated rule set */
.messages-mobile-back {
  display: none;
}

@media (max-width: 680px) {
  /* Mobile layout only: desktop rules remain independent below. */
  .messages-start-form {
    grid-template-columns: 1fr;
  }

  body:has(.view[data-view="messages"].is-active) {
    overflow-x: hidden;
  }

  body:has(.view[data-view="messages"].is-active) .app-footer {
    display: none;
  }

  /* Una conversación abierta es una pantalla fija: el documento no debe
     desplazarse al aparecer/desaparecer el teclado. El único scroll es el hilo. */
  html.messages-chat-document-locked,
  body.messages-chat-document-locked {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  body.messages-chat-document-locked .app-main {
    position: fixed;
    /* Follow the visible viewport when iOS pans it for the virtual keyboard. */
    top: var(--messages-viewport-offset-top, 0px);
    left: 0;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    height: var(--messages-viewport-height, 100dvh);
    margin: 0;
    padding: calc(var(--header-h) + var(--safe-top)) 0 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.messages-chat-document-locked .view[data-view="messages"].is-active {
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  body.messages-chat-document-locked .messages-layout {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.messages-chat-document-locked .messages-chat {
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .view[data-view="messages"].is-active {
    min-height: 0;
  }

  .view[data-view="messages"].is-active .messages-layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
  }

  .view[data-view="messages"].is-active .messages-sidebar {
    display: block;
    width: 100%;
    max-height: none;
    overflow-y: auto;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .view[data-view="messages"].is-active .messages-chat {
    display: none;
    flex-direction: column;
    width: 100%;
    height: calc(var(--messages-viewport-height, 100dvh) - var(--header-h) - var(--safe-top));
    min-height: 0;
    padding: 6px;
    gap: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--color-bg);
  }

  .view[data-view="messages"].is-active
  .messages-layout.mobile-chat-open .messages-sidebar {
    display: none;
  }

  .view[data-view="messages"].is-active
  .messages-layout.mobile-chat-open .messages-chat {
    display: flex;
  }

  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .post-back,
  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .view-title,
  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .field-hint,
  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .messages-start-form,
  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .messages-device-conflict,
  .view[data-view="messages"].is-active:has(.mobile-chat-open) > .messages-status {
    display: none;
  }

  .view[data-view="messages"].is-active .messages-chat-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
    margin: 0;
    padding: 4px 0 8px;
  }

  .view[data-view="messages"].is-active .messages-mobile-back {
    display: inline-flex;
    min-height: 38px;
    padding: 6px 10px;
    color: var(--color-accent);
    white-space: nowrap;
  }

  .view[data-view="messages"].is-active .messages-chat-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .messages-chat-header .field-hint {
    width: 100%;
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--color-muted, #929292);
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active
  .messages-chat-header button:not(.messages-mobile-back) {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.78rem;
    border-radius: 8px;
  }

  .view[data-view="messages"].is-active .messages-thread {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    height: auto;
    min-height: 0;
    max-height: none;
    gap: 10px;
    padding: 12px 2px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Larger, wider message bubbles: mobile only. */
  .view[data-view="messages"].is-active .message-bubble {
    max-width: 94%;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 1.15rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  /* Keep timestamp and delivery-state sizing as in the current mobile UI. */
  .view[data-view="messages"].is-active .message-meta {
    margin-top: 5px;
    font-size: 0.65rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .messages-send-form {
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
    gap: 8px;
    margin: 0;
    padding: 10px 0 max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
  }

  /* The keyboard occupies the lower screen area, so do not add the device
     home-indicator safe-area inset a second time while it is visible. */
  .view[data-view="messages"].is-active.messages-keyboard-open .messages-send-form {
    padding-bottom: 2px;
  }

  .view[data-view="messages"].is-active .messages-send-form .field {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    gap: 4px;
  }

  .view[data-view="messages"].is-active .messages-send-form .field-label {
    display: none;
  }

  .view[data-view="messages"].is-active .messages-send-form textarea {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 52px;
    min-height: 52px;
    max-height: 120px;
    padding: 13px 12px;
    border-radius: 10px;
    line-height: 1.4;
    font-size: 16px;
    resize: none;
    overflow-y: auto;
  }

  .view[data-view="messages"].is-active
  .messages-send-form [data-message-count] {
    margin-top: 3px;
    text-align: right;
    font-size: 0.65rem;
    line-height: 1.2;
  }

  .view[data-view="messages"].is-active
  .messages-send-form button[type="submit"] {
    box-sizing: border-box;
    align-self: flex-end;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    min-height: 42px;
    height: 42px;
    padding: 0 15px;
    margin: 0 0 19px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0;
  }

  .view[data-view="messages"].is-active
  [data-action="delete-local-conversation"] {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 10px;
    margin-top: 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    opacity: 0.78;
  }
}


/* GEMC2 — desktop private chat: consolidated layout */
@media (min-width: 681px) {
  body:has(.view[data-view="messages"].is-active) .app-main {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: calc(var(--header-h) + var(--safe-top) + 12px) 16px 12px;
  }

  .view[data-view="messages"].is-active {
    display: block;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .view[data-view="messages"].is-active .messages-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
    height: calc(100dvh - var(--header-h) - var(--safe-top) - 100px);
    min-height: 320px;
    max-height: 680px;
    overflow: hidden;
  }

  .view[data-view="messages"].is-active .messages-sidebar,
  .view[data-view="messages"].is-active .messages-chat {
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-elevated);
  }

  .view[data-view="messages"].is-active .messages-sidebar {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .view[data-view="messages"].is-active .messages-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .view[data-view="messages"].is-active .messages-chat-header {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--color-border);
  }

  .view[data-view="messages"].is-active .messages-chat-header h2 {
    margin: 0 0 6px;
    font-size: 1rem;
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .messages-chat-header .field-hint {
    margin: 0 0 8px;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .messages-chat-header .messages-mobile-back {
    display: none;
  }

  .view[data-view="messages"].is-active .messages-chat-header button:not(.messages-mobile-back) {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .view[data-view="messages"].is-active .messages-thread {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 10px;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 10px 2px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .view[data-view="messages"].is-active .message-bubble {
    max-width: min(80%, 560px);
    padding: 9px 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .message-meta {
    margin-top: 5px;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
  }

  .view[data-view="messages"].is-active .messages-send-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    flex: 0 0 auto;
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
  }

  .view[data-view="messages"].is-active .messages-send-form .field {
    min-width: 0;
    margin: 0;
  }

  .view[data-view="messages"].is-active .messages-send-form textarea {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-height: 42px;
    max-height: 90px;
    padding: 10px 12px;
    font-size: 14px;
    resize: vertical;
  }

  .view[data-view="messages"].is-active .messages-send-form [data-message-count] {
    margin-top: 3px;
    font-size: 0.7rem;
    text-align: right;
  }

  .view[data-view="messages"].is-active .messages-send-form button[type="submit"] {
    align-self: end;
    width: auto;
    min-width: 68px;
    min-height: 38px;
    margin: 0 0 18px;
    padding: 0 12px;
    font-size: 0.82rem;
  }

  .view[data-view="messages"].is-active [data-action="delete-local-conversation"] {
    min-height: 36px;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 0.75rem;
    opacity: 0.8;
  }
}

/* Align the delete action with the block button in the chat header. */
.view[data-view="messages"].is-active .messages-chat-header .messages-delete-conversation { margin-top: 0; }
