/* gateway/app/style.css — Streams workspace. Layers on top of the shared
   /gateway/style.css (container, gw-header, gw-brand, btn, gw-footer). Uses
   the same CSS custom properties the shared sheet defines so light/dark and
   typography stay consistent across the gateway pages. */

.btn--sm { padding: 4px 10px; font-size: 0.8rem; }

.app-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line, #d9d4cc);
  border-radius: 10px;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
}
.app-input:focus-visible { outline: 2px solid var(--accent, #c96442); outline-offset: 1px; }

.app-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, #c0392b 12%, transparent);
  color: #a5311f;
  font-size: 0.88rem;
}

/* ---- key gate ---- */
.app-gate { max-width: 620px; margin: 6vh auto 0; }
.app-gate__lede { color: var(--ink-500, #6b6459); font-size: 1.05rem; line-height: 1.55; }
.app-gate__box {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line, #e5e0d8);
  border-radius: 16px;
  background: var(--surface, #fff);
}

/* ---- toolbar ---- */
.app-shell { margin-top: 8px; }
.app-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}
.app-search { flex: 1; }
.app-toolbar__actions { display: flex; gap: 8px; flex-shrink: 0; }
.app-status { min-height: 1.2em; margin: 8px 2px 4px; color: var(--ink-500, #6b6459); font-size: 0.85rem; }

/* ---- body layout ---- */
.app-body { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .app-body { grid-template-columns: 1fr; } }

.app-sidebar {
  position: sticky;
  top: 12px;
  border: 1px solid var(--line, #e5e0d8);
  border-radius: 14px;
  background: var(--surface, #fff);
  padding: 12px;
}
.app-sidebar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.app-sidebar__head h2 { font-size: 0.95rem; margin: 0; }
.app-sidebar__empty { color: var(--ink-500, #6b6459); font-size: 0.85rem; padding: 6px 2px; }

.app-stream-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.app-stream-item { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.app-stream-item.is-disabled { opacity: 0.5; }
.app-stream-item.has-error .app-stream__badge { background: #c0392b; color: #fff; }

.app-stream {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.app-stream:hover { background: color-mix(in srgb, var(--accent, #c96442) 8%, transparent); }
.app-stream.is-active { background: color-mix(in srgb, var(--accent, #c96442) 16%, transparent); font-weight: 600; }
.app-stream--all { width: 100%; margin-bottom: 6px; }

.app-stream__badge {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent, #c96442) 18%, transparent);
  color: var(--beam-700, #8a3d24);
}
/* Merged streams read as a distinct grouping, not a source. */
.app-stream-item.is-merged .app-stream__badge {
  background: color-mix(in srgb, var(--beam-700, #8a3d24) 16%, transparent);
  color: var(--beam-700, #8a3d24);
  font-size: 0.8rem;
  padding: 1px 6px;
}
.app-stream-item.is-merged .app-stream__name { font-style: italic; }
.app-stream__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.app-stream__count { flex-shrink: 0; font-size: 0.75rem; color: var(--ink-500, #6b6459); font-variant-numeric: tabular-nums; }
.app-stream__flag { font-size: 0.68rem; color: var(--ink-500, #6b6459); flex-shrink: 0; }

.app-stream__menu { display: flex; gap: 1px; flex-shrink: 0; }
.app-iconbtn {
  border: 0; background: transparent; cursor: pointer; color: var(--ink-500, #6b6459);
  font-size: 0.85rem; line-height: 1; padding: 4px; border-radius: 6px;
}
.app-iconbtn:hover { background: color-mix(in srgb, var(--accent, #c96442) 12%, transparent); color: inherit; }

/* ---- timeline ---- */
.app-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.app-main__empty { color: var(--ink-500, #6b6459); padding: 40px 8px; text-align: center; }
.app-loadmore { display: block; margin: 14px auto 4px; }

.app-msg {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--line, #e5e0d8);
  border-radius: 12px;
  background: var(--surface, #fff);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.app-msg:hover { border-color: color-mix(in srgb, var(--accent, #c96442) 45%, var(--line, #e5e0d8)); box-shadow: var(--shadow-md, 0 4px 14px rgba(20,16,12,0.08)); }
.app-msg:focus-visible { outline: 2px solid var(--accent, #c96442); outline-offset: 2px; }
.app-msg__body { flex: 1; min-width: 0; }
.app-msg__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.app-msg__source { font-size: 0.72rem; font-weight: 600; color: var(--beam-700, #8a3d24); letter-spacing: 0.02em; }
.app-msg__date { font-size: 0.72rem; color: var(--ink-500, #6b6459); flex-shrink: 0; }
.app-msg__title {
  margin: 0;
  font-family: var(--font-serif, "Newsreader", Georgia, serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: inherit;
}
.app-msg__snippet {
  margin: 5px 0 0; color: var(--ink-500, #6b6459); font-size: 0.9rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.app-msg__meta { margin-top: 8px; font-size: 0.75rem; color: var(--ink-500, #6b6459); font-variant-numeric: tabular-nums; }

.app-msg__thumb {
  position: relative;
  flex-shrink: 0;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink-500, #6b6459) 10%, transparent);
}
.app-msg__thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-msg__thumb-badge {
  position: absolute; inset: auto 4px 4px auto; bottom: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 0.7rem; line-height: 1;
  padding: 3px 5px; border-radius: 5px;
}
@media (max-width: 480px) { .app-msg__thumb { width: 64px; height: 64px; } }

/* ---- preview dialog ---- */
.app-preview {
  border: 1px solid var(--line, #e5e0d8);
  border-radius: 16px;
  padding: 0;
  background: var(--surface, #fff);
  color: inherit;
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
}
.app-preview::backdrop { background: rgba(20, 16, 12, 0.45); }
.app-preview__inner { position: relative; padding: 22px 24px 24px; }
.app-preview__close { position: absolute; top: 12px; right: 12px; font-size: 1rem; }
.app-preview__head { display: flex; gap: 10px; align-items: baseline; margin: 0 30px 6px 0; }
.app-preview__title { margin: 0 0 12px; font-family: var(--font-serif, "Newsreader", Georgia, serif); font-size: 1.4rem; line-height: 1.25; }
.app-preview__gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}
/* A lone image gets the full width instead of a small tile. */
.app-preview__gallery:has(> :only-child) { grid-template-columns: 1fr; }
.app-preview__shot {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink-500, #6b6459) 10%, transparent);
  cursor: pointer;
  color: inherit;
}
.app-preview__shot:focus-visible { outline: 2px solid var(--accent, #c96442); outline-offset: 2px; }
.app-preview__shot img,
.app-preview__shot video { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.app-preview__gallery:has(> .app-preview__shot:only-child) img,
.app-preview__gallery:has(> .app-preview__shot:only-child) video { aspect-ratio: auto; max-height: 440px; object-fit: contain; }

/* Video tiles are stills (poster or first frame) with a play affordance; the
   video itself only plays in the full-window lightbox. */
.app-preview__shot--video video { pointer-events: none; }
.app-preview__playbadge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.1rem;
  padding-left: 3px; /* optically centre the ▶ glyph */
  pointer-events: none;
}
.app-preview__shot--video:hover .app-preview__playbadge { background: rgba(0, 0, 0, 0.72); }

.app-preview__audio { grid-column: 1 / -1; width: 100%; border-radius: 10px; }
.app-preview__content { color: inherit; font-size: 0.96rem; line-height: 1.62; overflow-wrap: anywhere; }
.app-preview__content p { margin: 0 0 0.8em; }
.app-preview__content a { color: var(--accent, #c96442); }
.app-preview__content img { max-width: 100%; height: auto; border-radius: 8px; margin: 8px 0; }
.app-preview__content blockquote { margin: 0 0 0.8em; padding-left: 12px; border-left: 3px solid var(--line, #e5e0d8); color: var(--ink-500, #6b6459); }
.app-preview__content pre { overflow-x: auto; background: color-mix(in srgb, var(--ink-500, #6b6459) 10%, transparent); padding: 10px 12px; border-radius: 8px; }
.app-preview__meta { margin-top: 12px; font-size: 0.8rem; color: var(--ink-500, #6b6459); font-variant-numeric: tabular-nums; }
.app-preview__actions { margin-top: 16px; }
.app-preview__actions .btn[hidden] { display: none; }

/* ---- full-window lightbox ---- */
.app-lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
  color: #fff;
  overflow: hidden;
}
.app-lightbox::backdrop { background: rgba(0, 0, 0, 0.92); }
.app-lightbox__figure {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 0;
}
.app-lightbox__figure img,
.app-lightbox__figure video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
}
.app-lightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.app-lightbox__close:hover { background: rgba(255, 255, 255, 0.28); }
.app-lightbox__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---- dialog ---- */
.app-dialog {
  border: 1px solid var(--line, #e5e0d8);
  border-radius: 16px;
  padding: 0;
  background: var(--surface, #fff);
  color: inherit;
  max-width: 460px;
  width: calc(100% - 32px);
}
.app-dialog::backdrop { background: rgba(20, 16, 12, 0.4); }
.app-dialog__form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.app-dialog__form h3 { margin: 0; }
.app-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; }
.app-field[hidden] { display: none; }
.app-field small { font-weight: 400; color: var(--ink-500, #6b6459); }
.app-field__hint { font-weight: 400; color: var(--ink-500, #6b6459); }

/* Member picker for a merged stream. */
.app-members {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 190px; overflow-y: auto;
  border: 1px solid var(--line, #d9d4cc); border-radius: 10px;
  padding: 6px; background: var(--surface, #fff);
}
.app-member {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 8px; font-weight: 400; cursor: pointer;
}
.app-member:hover { background: color-mix(in srgb, var(--accent, #c96442) 8%, transparent); }
.app-member input { flex-shrink: 0; }
.app-member span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.app-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
