/* ==========================================================================
   KIPPER — smokehouse ledger
   Palette: North Sea green depths, smoked-amber fish, chalk on slate.
   Type:    Bevan (woodtype display) / Karla (body) / IBM Plex Mono (ledger)
   ========================================================================== */

:root {
  --sea:       #12312e;   /* deep North Sea green — page background   */
  --sea-deep:  #0b211f;   /* darker panels, bars                      */
  --sea-line:  #1e453f;   /* card borders, dividers                   */
  --chalk:     #e9e0cc;   /* primary text                             */
  --brine:     #7ea69a;   /* secondary text                           */
  --amber:     #e8a33d;   /* smoked kipper amber — accent             */
  --amber-hot: #f4b95c;
  --danger:    #c4553b;

  --display: "Bevan", "Rockwell", serif;
  --body:    "Karla", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
  --pad: 16px;
  --topbar-h: 46px;
  --tabbar-h: calc(58px + env(safe-area-inset-bottom));
  --sheet-peek: 52px; /* collapsed vote-sheet height; keep in sync with SHEET_PEEK in app.js */
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none; /* no accidental pull-to-refresh; state survives refresh anyway */
}
body {
  margin: 0;
  background: var(--sea);
  color: var(--chalk);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: .02em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
[hidden] { display: none !important; }

/* ---------- eyebrow / ledger labels ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--brine);
}

/* ================= LOGIN ================= */
.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(360px, 100%); text-align: center; }
.login-fish { width: 96px; height: 60px; color: var(--amber); margin-bottom: 4px; }
.brand {
  font-family: var(--display);
  font-size: 52px;
  margin: 0;
  color: var(--chalk);
  text-shadow: 3px 3px 0 var(--sea-deep);
}
.strapline { color: var(--brine); margin: 6px 0 28px; }
.login-card form { text-align: left; display: grid; gap: 6px; }
.login-card label { font-family: var(--mono); font-size: 12px; color: var(--brine); }
.login-card input {
  background: var(--sea-deep);
  border: 1px solid var(--sea-line);
  border-radius: var(--radius);
  color: var(--chalk);
  padding: 12px;
  margin-bottom: 8px;
}
.login-card input:focus-visible,
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.form-error { color: var(--danger); font-size: 14px; }

/* ================= SHELL ================= */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px var(--pad);
  background: var(--sea-deep);
  border-bottom: 1px solid var(--sea-line);
}
.topbar-brand { font-family: var(--display); font-size: 18px; color: var(--amber); }
.topbar-user { font-family: var(--mono); font-size: 12px; color: var(--brine); }
.linklike {
  background: none; border: none; padding: 0;
  color: var(--brine); text-decoration: underline; font: inherit;
}

#main {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--pad) var(--pad) 120px;
}

.view-title { font-size: 26px; margin: 8px 0 2px; }
.view-sub { color: var(--brine); margin: 0 0 18px; font-size: 14px; }

/* ================= CARDS ================= */
.card {
  position: relative;
  background: var(--sea-deep);
  border: 1px solid var(--sea-line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-title { font-size: 18px; font-weight: 700; margin: 2px 0 4px; }
.card-people { font-family: var(--mono); font-size: 12px; color: var(--brine); margin-bottom: 8px; }
.card-people b { color: var(--amber); font-weight: 500; }
.card-story { margin: 0 0 10px; white-space: pre-wrap; }
.card-date { font-family: var(--mono); font-size: 11px; color: var(--brine); white-space: nowrap; }
.card-media { width: 100%; border-radius: 6px; margin-bottom: 10px; display: block; max-height: 340px; object-fit: contain; background: #000; }

/* ================= FISH RATING ================= */
.fish-row { display: inline-flex; gap: 3px; vertical-align: middle; }
.fish-row svg { width: 24px; height: 15px; color: var(--sea-line); }
.fish-row svg.lit { color: var(--amber); }
.fish-score { font-family: var(--mono); font-size: 13px; color: var(--chalk); margin-left: 6px; }
.fish-score small { color: var(--brine); }

.rate-box { border-top: 1px dashed var(--sea-line); margin-top: 10px; padding-top: 10px; }
.rate-fishes { display: flex; gap: 6px; margin: 6px 0 8px; }
.rate-fishes button {
  background: none; border: none; padding: 4px;
  color: var(--sea-line);
  transition: transform .08s ease;
}
.rate-fishes button svg { width: 34px; height: 22px; }
.rate-fishes button.lit { color: var(--amber); }
.rate-fishes button:active { transform: scale(1.2); }
.rate-comment {
  width: 100%; background: var(--sea); border: 1px solid var(--sea-line);
  border-radius: 6px; color: var(--chalk); padding: 8px; resize: vertical;
}
.rate-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.rate-note { font-family: var(--mono); font-size: 11px; color: var(--brine); }

.ratings-list { margin: 8px 0 0; padding: 0; list-style: none; }
.ratings-list li { font-size: 14px; padding: 4px 0; border-top: 1px dashed var(--sea-line); }
.ratings-list .who { font-family: var(--mono); font-size: 12px; color: var(--brine); }
.ratings-list li.mine .who { color: var(--amber); }
.ratings-show-all { display: block; margin-top: 6px; font-size: 12px; font-family: var(--mono); }

/* ================= BUTTONS ================= */
.btn {
  border: none; border-radius: var(--radius);
  padding: 11px 18px; font-weight: 700; font-size: 15px;
}
.btn-primary { background: var(--amber); color: var(--sea-deep); }
.btn-primary:hover { background: var(--amber-hot); }
.btn-ghost {
  background: none; color: var(--brine);
  border: 1px solid var(--sea-line);
}
.btn-danger-ghost { background: none; border: none; color: var(--danger); font-size: 13px; padding: 4px; }
.btn-danger { background: var(--danger); color: #fff; }

.admin-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.fab {
  position: fixed; right: 18px; bottom: 86px; z-index: 20;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--amber); color: var(--sea-deep);
  border: none; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  transition: opacity .2s ease;
}
/* out of the way while a vote sheet is up — it overlaps the sheet's controls */
body.fab-hidden .fab { opacity: 0; pointer-events: none; }

/* ================= TABS ================= */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--sea-deep);
  border-top: 1px solid var(--sea-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: none; border: none;
  font-family: var(--mono); font-size: 11px; line-height: 1.3;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--brine);
  padding: 12px 4px;
  border-top: 3px solid transparent;
}
.tab.active { color: var(--amber); border-top-color: var(--amber); }
.tab, .fab, .btn { -webkit-user-select: none; user-select: none; }
.tab:active { color: var(--chalk); }
.btn-primary:active { transform: scale(.97); }

/* ================= PILLS / SEGMENTS ================= */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.pill {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase;
  background: none; color: var(--brine);
  border: 1px solid var(--sea-line); border-radius: 999px;
  padding: 6px 14px;
}
.pill.active { background: var(--amber); color: var(--sea-deep); border-color: var(--amber); }

/* ================= TABLES (people board) ================= */
.board-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.board-table th {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brine);
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--sea-line);
}
.board-table td { padding: 10px 6px; border-bottom: 1px dashed var(--sea-line); }
.board-table td.num { font-family: var(--mono); }
.board-rank { font-family: var(--display); color: var(--amber); }

/* ================= AWARDS ================= */
.award-hero {
  text-align: center;
  border: 2px solid var(--amber);
  border-radius: var(--radius);
  padding: 22px 16px;
  margin-bottom: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(232,163,61,.12), transparent 70%),
    var(--sea-deep);
}
.award-hero .eyebrow { color: var(--amber); }
.award-hero h2 { font-size: 24px; margin: 8px 0 4px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.podium-slot {
  background: var(--sea-deep); border: 1px solid var(--sea-line);
  border-radius: var(--radius); padding: 10px; text-align: center; font-size: 13px;
}
.podium-slot .place { font-family: var(--display); font-size: 22px; color: var(--amber); }
.honours { display: grid; gap: 10px; }
.honour {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--sea-deep); border: 1px solid var(--sea-line);
  border-radius: var(--radius); padding: 12px 14px;
}
.honour b { color: var(--amber); }

/* ================= FORMS (log a kipper) ================= */
.log-form { display: grid; gap: 12px; }
.log-form label { font-family: var(--mono); font-size: 12px; color: var(--brine); display: block; margin-bottom: 4px; }
.log-form input[type=text], .log-form input[type=datetime-local],
.log-form select, .log-form textarea {
  width: 100%; background: var(--sea-deep);
  border: 1px solid var(--sea-line); border-radius: var(--radius);
  color: var(--chalk); padding: 11px;
}
.log-form input[type=datetime-local] { color-scheme: dark; }
.log-form textarea { min-height: 96px; resize: vertical; }
.file-label {
  display: block; border: 1px dashed var(--brine); border-radius: var(--radius);
  padding: 14px; text-align: center; color: var(--brine); cursor: pointer;
}
.file-label input { display: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ================= THE DATES ================= */
.dates-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 18px;
}
.dates-head .view-sub { margin-bottom: 0; }
.dates-head .btn { white-space: nowrap; }
#event-form-slot .log-form.card { margin-bottom: 18px; }
.event-main { display: flex; gap: 14px; }
.event-datebox {
  flex-shrink: 0; align-self: flex-start;
  width: 62px;
  display: grid; justify-items: center; gap: 1px;
  background: var(--sea);
  border: 1px solid var(--sea-line);
  border-radius: var(--radius);
  padding: 8px 4px;
}
.event-dow {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--brine);
}
.event-day { font-family: var(--display); font-size: 26px; line-height: 1.05; color: var(--amber); }
.event-month {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--chalk);
}
.event-body { min-width: 0; flex: 1; }
.event-body .card-title { margin-top: 0; }
.event-when { font-family: var(--mono); font-size: 12px; color: var(--amber); margin-bottom: 6px; }
.event-attendees {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 12px;
}
.attendee-chip {
  font-family: var(--mono); font-size: 11px; color: var(--chalk);
  border: 1px solid var(--sea-line); border-radius: 999px;
  padding: 3px 10px; white-space: nowrap;
}
.event-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--sea-line);
}
.event-actions .btn { padding: 8px 14px; font-size: 14px; }
.event-actions .event-manage { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.event-past { opacity: .55; }

/* ================= SETTINGS (the wheelhouse) ================= */
.settings-heading {
  font-family: var(--mono); font-size: 11px; font-weight: 400;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--brine);
  margin: 22px 0 8px;
}
.profile-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}
.profile-fish { width: 56px; height: 35px; color: var(--amber); }
.profile-name { font-family: var(--display); font-size: 22px; }
.profile-username { font-family: var(--mono); font-size: 12px; color: var(--brine); }
.role-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brine);
  border: 1px solid var(--sea-line); border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  align-self: start;
}
.role-badge.role-admin {
  color: var(--sea-deep);
  background: var(--amber);
  border-color: var(--amber);
}
.profile-role-note { grid-column: 1 / -1; margin: 0; }
.log-form.card { margin-bottom: 0; }

.pref-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; cursor: pointer;
}
.pref-text { display: grid; gap: 2px; }
.pref-title { font-weight: 700; }

/* toggle switch */
.switch {
  appearance: none; -webkit-appearance: none;
  flex-shrink: 0;
  width: 46px; height: 26px;
  border-radius: 999px;
  background: var(--sea);
  border: 1px solid var(--sea-line);
  position: relative;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brine);
  transition: transform .15s ease, background .15s ease;
}
.switch:checked { background: var(--amber); border-color: var(--amber); }
.switch:checked::after { transform: translateX(20px); background: var(--sea-deep); }

/* per-category notification toggles, greyed while the master switch is off */
#notify-cats {
  display: grid; gap: 14px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--sea-line);
  transition: opacity .15s ease;
}
.prefs-disabled { opacity: .45; pointer-events: none; }

/* ================= MISC ================= */
.empty {
  text-align: center; color: var(--brine); padding: 40px 12px;
}
.empty svg { width: 64px; height: 40px; color: var(--sea-line); display: block; margin: 0 auto 10px; }

#toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%) translateY(20px);
  background: var(--amber); color: var(--sea-deep);
  font-weight: 700; padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  z-index: 50; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= REELS FEED ================= */
body.feed-mode #main { max-width: none; padding: 0; }

.reel-scroller {
  position: fixed;
  left: 0; right: 0;
  top: var(--topbar-h); bottom: var(--tabbar-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  background: #000;
}
.reel {
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  position: relative;
  overflow: hidden;
  background: #000;
}
.reel-media,
.reel-media video,
.reel-media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.reel-nomedia {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  overflow: hidden; /* must NOT be a scroll container — it would trap the feed's scroll */
  padding: 24px 24px 38dvh; /* keep the hero text clear of the overlay */
  text-align: center;
  background: radial-gradient(circle at 50% 20%, var(--sea-line), var(--sea-deep));
}
.reel-nomedia p {
  color: var(--chalk); white-space: pre-wrap; max-width: 480px; margin: 0;
  font-size: 21px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 14; -webkit-box-orient: vertical;
  overflow: hidden;
}
.reel-nomedia-fish { width: 110px; height: 68px; color: var(--sea-line); }
.reel-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  padding: 14px;
  max-height: 72%;
  overflow-y: auto; /* default overscroll so scrolling chains through to the feed */
  background: linear-gradient(transparent, rgba(11, 33, 31, .92) 40%);
}
/* keep overlay content clear of the collapsed sheet's peek bar */
.reel.has-sheet .reel-overlay { padding-bottom: calc(var(--sheet-peek) + 12px); }
.reel-title { font-size: 20px; margin: 0 0 2px; }
.reel-story {
  margin: 0 0 8px;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.reel-story.expanded { display: block; -webkit-line-clamp: none; }
.reel-comments-toggle {
  display: block;
  background: none; border: none; padding: 6px 0;
  font-family: var(--mono); font-size: 12px;
  color: var(--brine);
}
.reel-comments { max-height: 30dvh; overflow-y: auto; }

/* ---------- vote sheet (swipeable rating panel) ---------- */
.vote-dim {
  position: absolute; inset: 0; z-index: 2;
  background: rgba(4, 14, 13, .78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.reel.vote-open .vote-dim { opacity: 1; pointer-events: auto; }
.vote-dim.dragging { transition: none; }

.vote-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  background: var(--sea-deep);
  border-top: 1px solid var(--sea-line);
  border-radius: 16px 16px 0 0;
  padding: 0 14px 14px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .35);
  transform: translateY(calc(100% - var(--sheet-peek)));
  transition: transform .25s ease;
  touch-action: none; /* drags move the sheet, not the feed scroller */
}
.reel.vote-open .vote-sheet { transform: none; }
.vote-sheet.dragging { transition: none; }
.vote-sheet.done { transform: translateY(100%); }

.vote-sheet-handle {
  display: grid; justify-items: center; gap: 6px;
  width: 100%; height: var(--sheet-peek);
  background: none; border: none;
  padding: 10px 0 4px;
}
.vote-sheet-handle .grip {
  width: 44px; height: 4px;
  border-radius: 999px;
  background: var(--sea-line);
}

.vote-sheet-body { display: grid; gap: 8px; }
.vote-sheet .rate-comment { touch-action: auto; }

/* ================= THE CHAT ================= */
body.chat-mode #fab { display: none; }

.chat {
  position: fixed;
  left: 0; right: 0;
  top: var(--topbar-h); bottom: var(--tabbar-h);
  display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 12px 8px;
}
.chat-hello {
  text-align: center; color: var(--brine);
  font-family: var(--mono); font-size: 11px;
  padding: 14px 24px 6px;
}
.chat-hello svg { width: 44px; height: 28px; color: var(--sea-line); display: block; margin: 0 auto 6px; }

.chat-day { text-align: center; margin: 14px 0 4px; }
.chat-day span {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brine);
  background: var(--sea-deep); border: 1px solid var(--sea-line);
  border-radius: 999px; padding: 3px 12px;
}

.msg { display: flex; flex-direction: column; align-items: flex-start; margin: 2px 0; }
.msg.mine { align-items: flex-end; }
.msg.group-start { margin-top: 10px; }
.msg-sender { font-family: var(--mono); font-size: 11px; color: var(--brine); margin: 0 0 2px 12px; }
.msg-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--sea-deep);
  border: 1px solid var(--sea-line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}
.msg.theirs .msg-bubble { border-bottom-left-radius: 5px; }
.msg.mine .msg-bubble {
  background: var(--amber); color: var(--sea-deep);
  border-color: var(--amber);
  border-bottom-right-radius: 5px;
}
.msg-time {
  font-family: var(--mono); font-size: 10px;
  opacity: .6; margin-left: 8px;
  white-space: nowrap;
}

.chat-inputbar {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 10px;
  background: var(--sea-deep);
  border-top: 1px solid var(--sea-line);
}
#chat-input {
  flex: 1;
  background: var(--sea);
  border: 1px solid var(--sea-line);
  border-radius: 18px;
  color: var(--chalk);
  padding: 9px 14px;
  resize: none;
  max-height: 120px;
  line-height: 1.35;
}
.chat-send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--amber); color: var(--sea-deep);
  border: none;
  display: grid; place-items: center;
}
.chat-send svg { width: 24px; height: 15px; }
.chat-send[disabled] { opacity: .5; }

/* ---------- chat upgrade: media, meta, mentions, states ---------- */
.msg { animation: msg-in .18s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }

.msg-bubble { display: flex; flex-direction: column; }
.msg-text { display: block; }
.msg-media {
  display: block;
  max-width: 100%; max-height: 320px;
  width: auto; border-radius: 10px;
  margin: -1px 0 2px; cursor: zoom-in;
  background: var(--sea);
}
video.msg-media { cursor: default; }
.msg-meta { display: flex; align-items: center; gap: 5px; align-self: flex-end; margin-top: 2px; }
.msg-status { font-family: var(--mono); font-size: 10px; opacity: .7; }
.msg.mine .msg-status { color: var(--sea-deep); }
.msg.failed .msg-status { color: var(--danger); opacity: 1; font-weight: 700; }
.msg.failed { cursor: pointer; }
.msg.pending .msg-bubble { opacity: .72; }

.msg-progress { height: 3px; border-radius: 3px; background: rgba(0,0,0,.25); margin: 2px 0 4px; overflow: hidden; }
.msg-progress i { display: block; height: 100%; background: var(--sea-deep); transition: width .15s ease; }
.msg.theirs .msg-progress i { background: var(--amber); }

.mention {
  color: var(--amber); font-weight: 700;
  background: rgba(232,163,61,.12); border-radius: 5px; padding: 0 3px;
}
.msg.mine .mention { color: var(--sea-deep); background: rgba(11,33,31,.14); }

/* selection mode */
.chat-scroll.selecting .msg { cursor: pointer; }
.msg.selected .msg-bubble { outline: 2px solid var(--amber); outline-offset: 2px; }

/* older-history spinner at the top of the scroller */
.chat-top { height: 0; display: grid; place-items: center; overflow: hidden; transition: height .15s ease; }
.chat-top.loading { height: 30px; }
.chat-top-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--sea-line); border-top-color: var(--amber);
  animation: spin .7s linear infinite; opacity: 0;
}
.chat-top.loading .chat-top-spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* "new messages" pill */
.chat-jump {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 6px;
  background: var(--amber); color: var(--sea-deep);
  border: none; border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  animation: msg-in .18s ease-out;
}

/* composer attach button + preview */
.chat-attach-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  background: var(--sea); color: var(--brine);
  border: 1px solid var(--sea-line); font-size: 24px; line-height: 1;
  display: grid; place-items: center;
}
.chat-attach {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--sea-deep);
  border-top: 1px solid var(--sea-line);
}
.chat-attach img, .chat-attach video { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.chat-attach-name { flex: 1; font-size: 13px; color: var(--brine); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-x {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--sea); color: var(--chalk); border: 1px solid var(--sea-line);
}

/* selection action bar (covers the composer while selecting) */
.chat-selectbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--sea-deep); border-top: 1px solid var(--sea-line);
}
.chat-selectbar #select-count { flex: 1; font-family: var(--mono); font-size: 13px; color: var(--brine); }
.btn-sm { padding: 8px 14px; font-size: 14px; }

/* @mention autocomplete popup */
.mention-pop {
  position: absolute; left: 10px; right: 10px; bottom: 66px; z-index: 8;
  background: var(--sea-deep); border: 1px solid var(--sea-line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.mention-item {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  padding: 9px 14px; background: none; border: none; text-align: left;
  color: var(--chalk); font-size: 14px;
}
.mention-item span { font-family: var(--mono); font-size: 12px; color: var(--brine); }
.mention-item.active, .mention-item:hover { background: var(--sea-line); }

/* attached-from-chat indicator on the Create Kipper form */
.chat-attached {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border: 1px solid var(--sea-line); border-radius: var(--radius);
  background: var(--sea-deep);
}
.chat-attached img, .chat-attached video { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
.chat-attached span { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--brine); }

/* ---------- reusable bottom action sheet ---------- */
.sheet-overlay { position: fixed; inset: 0; z-index: 60; }
.sheet-dim { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .18s ease; }
.sheet-overlay.open .sheet-dim { opacity: 1; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: var(--sea-deep); border-top: 1px solid var(--sea-line);
  border-radius: 16px 16px 0 0;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  display: grid; gap: 6px;
  transform: translateY(100%); transition: transform .2s cubic-bezier(.22,.61,.36,1);
}
.sheet-overlay.open .sheet-panel { transform: translateY(0); }
.sheet-item {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--sea); border: 1px solid var(--sea-line);
  color: var(--chalk); font-size: 15px; font-weight: 600;
}
.sheet-item.primary { background: var(--amber); color: var(--sea-deep); border-color: var(--amber); }
.sheet-cancel { background: none; border: none; color: var(--brine); }

/* ---------- image lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.92);
  display: grid; place-items: center;
  opacity: 0; transition: opacity .18s ease;
  touch-action: none;
}
.lightbox.open { opacity: 1; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  touch-action: none; will-change: transform; user-select: none;
}
.lightbox-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.4); color: #fff; border: none; font-size: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .msg, .chat-jump { animation: none; }
  .chat-top-spinner { animation: none; }
}

@media (min-width: 700px) {
  .tabbar { position: sticky; max-width: 640px; margin: 0 auto; border: 1px solid var(--sea-line); border-radius: var(--radius) var(--radius) 0 0; }
  .fab { right: calc(50vw - 320px + 18px); }
  body.feed-mode .tabbar, body.chat-mode .tabbar { position: fixed; }
  .reel-scroller { max-width: 640px; margin: 0 auto; }
}

/* ================= SWIPE NAV + SKELETONS ================= */
/* Reserve horizontal pans for the swipe gesture; vertical stays native scroll.
   touch-action doesn't inherit, so each scroll container is listed. The vote
   sheet keeps touch-action:none (above); .rate-comment keeps auto (above). */
.view, .reel-scroller, .reel, .reel-overlay, .chat-scroll { touch-action: pan-y; }
.view { min-height: 40vh; } /* stop skeleton→content jumping the tabbar shadow */

.view.dragging, .reel-scroller.dragging, .chat.dragging { transition: none; will-change: transform; }
.view.snapping, .reel-scroller.snapping, .chat.snapping { transition: transform .2s cubic-bezier(.22,.61,.36,1); }
.view.enter-left, .reel-scroller.enter-left, .chat.enter-left    { animation: view-in-left  .18s ease-out; }
.view.enter-right, .reel-scroller.enter-right, .chat.enter-right { animation: view-in-right .18s ease-out; }
@keyframes view-in-left  { from { transform: translateX(-26px); opacity: .35; } }
@keyframes view-in-right { from { transform: translateX(26px);  opacity: .35; } }

.skeleton-wrap { padding-top: 8px; }
.skeleton {
  background: linear-gradient(100deg, var(--sea-deep) 30%, var(--sea-line) 50%, var(--sea-deep) 70%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-title { height: 26px; width: 55%; margin: 8px 0 14px; }
.skeleton-line  { height: 12px; width: 90%; margin-bottom: 10px; border-radius: 6px; }
.skeleton-card  { height: 96px; margin-bottom: 14px; }
.skeleton-feed {
  position: fixed; left: 0; right: 0; top: var(--topbar-h); bottom: var(--tabbar-h);
  display: grid; place-items: center; background: #000;
}
.skeleton-feed svg { width: 90px; height: 56px; color: var(--sea-line); animation: shimmer-fade 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes shimmer-fade { 0%,100% { opacity: .3; } 50% { opacity: .7; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
