/* Pasta Support — dark/gold console wearing the app's face: self-hosted
   Cormorant (CSP: font-src 'self'), warm black, honey gold. */
@font-face {
  font-family: 'Cormorant';
  src: url('/static/fonts/Cormorant-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant';
  src: url('/static/fonts/Cormorant-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant';
  src: url('/static/fonts/Cormorant-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
:root {
  --bg: #060606;
  --panel: #111010;
  --panel-2: #191817;
  --ink: #ede9e2;
  --ink-dim: rgba(237, 233, 226, 0.58);
  --ink-faint: rgba(237, 233, 226, 0.32);
  --gold: #d9a94a;
  --gold-dim: rgba(217, 169, 74, 0.35);
  --line: rgba(237, 233, 226, 0.12);
  --user: #1d2733;
  --tim: #241d10;
  --danger: #c9524a;
  --ok: #6fae72;
  --serif: 'Cormorant', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
a {
  color: var(--gold);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--gold);
}
.brand:hover {
  text-decoration: none;
}
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav a {
  color: var(--ink-dim);
}
.nav a.active {
  color: var(--ink);
}
.nav .who {
  color: var(--ink-faint);
  font-size: 13px;
}
.signout-form {
  margin: 0;
}
.linkbtn {
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.linkbtn:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* --- Flash + banners --- */
.flash {
  margin: 12px 20px;
  padding: 10px 14px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  background: rgba(217, 169, 74, 0.08);
  color: var(--ink);
  font-size: 14px;
}
.signed-out-banner {
  margin: 10px 0;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: rgba(201, 82, 74, 0.12);
}
.content {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

/* --- Buttons --- */
.btn-primary {
  background: var(--gold);
  color: #060606;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover {
  filter: brightness(1.06);
}
.btn-small {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-small:hover {
  border-color: var(--gold-dim);
}
.btn-small:disabled {
  opacity: 0.4;
  cursor: default;
}
.btn-small.danger {
  color: var(--danger);
}
.btn-small.ghost {
  background: none;
}

/* --- Auth cards (login / setup / invite / devices) ---
   Glass over the honey glow; .auth-stage (login) centers full-viewport, the
   other auth pages use .auth-card standalone and inherit the same material. */
.auth-card {
  max-width: 420px;
  width: min(420px, 92vw);
  margin: 8vh auto 0;
  padding: 44px 36px 36px;
  background: rgba(22, 19, 14, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
  backdrop-filter: blur(24px) saturate(1.15);
  border: 1px solid rgba(217, 169, 74, 0.22);
  border-radius: 24px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.auth-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--gold);
  font-size: 32px;
  margin: 0 0 8px;
}
.auth-stage {
  min-height: calc(100svh - 40px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
}
.auth-stage .auth-card {
  margin: 0;
  animation: auth-rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
/* The glow lives behind everything: a honey breath top-left, embers low-right. */
.auth-stage::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 55% at 22% 12%, rgba(217, 169, 74, 0.14), transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 95%, rgba(120, 66, 24, 0.18), transparent 65%),
    var(--bg);
}
.auth-eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 2px;
}
.auth-wordmark {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(52px, 13vw, 64px);
  line-height: 1.05;
  color: var(--ink);
  margin: 0;
}
.auth-tagline {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  color: var(--ink-dim);
  margin: 6px 0 30px;
}
.btn-passkey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 22px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  color: var(--gold);
  background: rgba(217, 169, 74, 0.1);
  border: 1px solid rgba(217, 169, 74, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.btn-passkey:hover {
  background: rgba(217, 169, 74, 0.18);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(217, 169, 74, 0.12);
}
.btn-passkey:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.passkey-glyph {
  flex: none;
  opacity: 0.9;
}
.auth-hint {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 18px 0 0;
}
.auth-foot {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-faint);
  margin: 0;
}
@keyframes auth-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-stage .auth-card {
    animation: none;
  }
  .btn-passkey,
  .btn-passkey:hover {
    transition: none;
    transform: none;
  }
}
.auth-sub {
  color: var(--ink-dim);
  margin: 0 0 24px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  margin-bottom: 18px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-dim);
}
input,
select,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  padding: 9px 11px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
}
.auth-status {
  margin-top: 16px;
  min-height: 20px;
  color: var(--ink-dim);
  font-size: 14px;
}
.auth-status.error {
  color: var(--danger);
}

/* --- Inbox --- */
.page-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 26px;
  color: var(--gold);
  margin: 0 0 18px;
}
.inbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tabs,
.scope-toggle {
  display: flex;
  gap: 8px;
}
.tab,
.scope {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 14px;
}
.tab.active,
.scope.active {
  color: #060606;
  background: var(--gold);
  border-color: var(--gold);
}
.tab:hover,
.scope:hover {
  text-decoration: none;
  border-color: var(--gold-dim);
}
.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}
.session-row.needs-reply {
  border-color: var(--gold-dim);
}
.row-link {
  display: block;
  padding: 12px 16px;
  color: var(--ink);
}
.row-link:hover {
  text-decoration: none;
  background: var(--panel-2);
}
.row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.row-preview {
  font-weight: 500;
}
.needs-reply .row-preview::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 8px;
  vertical-align: middle;
}
.row-time {
  color: var(--ink-faint);
  font-size: 13px;
  white-space: nowrap;
}
.row-sub {
  display: flex;
  gap: 14px;
  margin-top: 5px;
  color: var(--ink-dim);
  font-size: 12px;
  flex-wrap: wrap;
}
.row-waiting {
  color: var(--gold);
}
.empty-row {
  padding: 24px;
  text-align: center;
  color: var(--ink-faint);
}

/* --- Thread --- */
.thread-wrap {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: start;
}
.thread-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.thread-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.status-pill.open {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.thread-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.assign-form,
.state-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.assign-form form,
.state-buttons form {
  margin: 0;
}
.assign-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-dim);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.thread-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.translate-status {
  font-size: 12px;
  color: var(--ink-dim);
}
.translate-status.error {
  color: var(--danger);
}
#message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 78%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.bubble.user {
  align-self: flex-start;
  background: var(--user);
}
.bubble.tim {
  align-self: flex-end;
  background: var(--tim);
}
.bubble-body {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sent-translated {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
  border-top: 1px dashed var(--line);
  padding-top: 5px;
}
.translate-row {
  margin-top: 6px;
}
.translate-one {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.translation {
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink-dim);
  border-left: 2px solid var(--gold-dim);
  padding-left: 8px;
}
.translation.failed {
  color: var(--danger);
  border-color: var(--danger);
}
.bubble-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  gap: 8px;
}
.bubble-meta .author {
  color: var(--gold);
}
.attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.attachment-actions {
  display: flex;
  gap: 10px;
}
.kind-request .bubble-body {
  font-style: italic;
  color: var(--gold);
}
.resolved-banner {
  align-self: center;
  padding: 10px 16px;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 13px;
}

/* --- Composer --- */
.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.composer-input {
  width: 100%;
  resize: vertical;
}
.composer-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lang-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-dim);
}
.lang-input {
  width: 150px;
}
.send-btn {
  margin-left: auto;
}
.composer-note {
  margin-top: 12px;
  color: var(--ink-dim);
  font-style: italic;
}

/* --- Context sidebar --- */
.context-sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.context-sidebar h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 0 0 12px;
}
.context-sidebar dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.context-sidebar dt {
  color: var(--ink-faint);
}
.context-sidebar dd {
  margin: 0;
  word-break: break-word;
}

/* --- Users / Devices --- */
.add-user-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th,
.users-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.users-table th {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.row-actions form {
  margin: 0;
}
.status-badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.status-badge.active {
  color: var(--ok);
  border-color: rgba(111, 174, 114, 0.4);
}
.status-badge.invited {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.status-badge.disabled,
.status-badge.expired {
  color: var(--danger);
  border-color: rgba(201, 82, 74, 0.4);
}
.device-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.device-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.device-date {
  color: var(--ink-faint);
  font-size: 13px;
}

/* --- Responsive: single column on phones --- */
@media (max-width: 720px) {
  .thread-wrap {
    grid-template-columns: 1fr;
  }
  .context-sidebar {
    order: -1;
  }
  .bubble {
    max-width: 90%;
  }
  .content {
    padding: 14px;
  }
  .users-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* --- Media bubbles (Part D): the image IS the bubble — it hugs the media's
   aspect ratio with a slim frame, no dead space. --- */
.bubble.kind-media {
  padding: 4px;
  width: fit-content;
}
.bubble-media {
  display: block;
  width: 100%;
  max-width: 352px;
  border-radius: 11px;
}
.kind-media .bubble-meta {
  margin: 4px 8px 4px;
}
