/* Themes copied from PeerTube 8.2.4. The selector names match PeerTube's own
   (:root[data-pt-theme=...]), and "default" is an alias of light beige, as it
   is in PeerTube. Values that PeerTube derives at runtime (the -350/-400/-450
   ramp steps) are written out here as single values. */

:root,
:root[data-pt-theme="default"],
:root[data-pt-theme="peertube-core-light-beige"] {
  --is-dark: 0;
  --primary: #ff8f37;
  --on-primary: hsl(0 14% 2%);
  --fg: hsl(0 14% 2%);
  --muted: hsl(0 9% 51%);
  --bg: hsl(250 5% 96%);
  --bg-secondary: hsl(0 12% 72%);
  --input-bg: hsl(0 19% 89%);
  --line: hsl(0 13% 81%);
  --surface: hsl(0 13% 92%);
}

:root[data-pt-theme="peertube-core-dark-brown"] {
  --is-dark: 1;
  --primary: #fd9c50;
  --on-primary: #111;
  --fg: hsl(0 10% 96%);
  --muted: hsl(0 8% 66%);
  --bg: hsl(0 14% 7%);
  --bg-secondary: hsl(0 14% 22%);
  --input-bg: hsl(0 14% 18%);
  --line: hsl(0 14% 22%);
  --surface: hsl(0 14% 11%);
}

:root {
  --input-border-radius: 4px;
  --menu-border-radius: 14px;
  --red: #dc3545;
}

/* The browser rule for [hidden] loses to any class that sets display, so
   every JS-hidden row needs this. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

h1 { font-size: 1.05rem; font-weight: 600; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 0; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.error { color: var(--red); font-size: 0.85rem; margin-top: 0.25rem; }

.view { min-height: 100vh; }
.view-in { max-width: 420px; margin: 0 auto; padding: 0.7rem 0.7rem 1.5rem; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-sm { min-width: 0; }
.brand-text { min-width: 0; }
.logo {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 6px; object-fit: contain; background: var(--input-bg);
}
.brand-sm .logo { width: 26px; height: 26px; }
.instance-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- login ---------- */
.login { max-width: 340px; margin: max(4vh, 1rem) auto; }
.login .brand { margin-bottom: 1rem; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--menu-border-radius);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.5rem;
}
.card > .muted:first-of-type { margin: 0.15rem 0 0.8rem; }

/* ---------- fold-out section ---------- */
details.card { padding: 0; }
details.card > summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.55rem 0.8rem; cursor: pointer; list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: "\25B8"; color: var(--muted); font-size: 0.9rem;
}
details.card[open] > summary::after { content: "\25BE"; }
details.card > summary:hover { color: var(--primary); }
.fold-body { padding: 0 0.8rem 0.7rem; }
.fold-body > .muted:first-child { margin-bottom: 0.8rem; }

.note {
  background: var(--input-bg);
  border-inline-start: 3px solid var(--primary);
  border-radius: 0;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
}

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in {
  max-width: 420px; margin: 0 auto; padding: 0.4rem 0.7rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
}
.topbar-right { display: flex; align-items: center; gap: 0.4rem; flex: 0 0 auto; }

.pill { font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: var(--input-border-radius); }
.pill-off { background: var(--input-bg); color: var(--muted); }
.pill-live { background: var(--red); color: #fff; }

.live-switch {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.5rem;
}
.live-switch .field-inline { flex: 1; min-width: 0; }
.link { color: var(--primary); font-size: 0.85rem; white-space: nowrap; }

/* ---------- fields ---------- */
.field { display: block; margin-bottom: 0.65rem; }
.field > span, .field-label { display: block; margin-bottom: 0.2rem; }
.field-inline { display: flex; align-items: center; gap: 0.5rem; margin: 0; min-width: 0; }
.field-inline > span { margin: 0; flex: 0 0 auto; }
.field-narrow { max-width: 220px; }
.field:last-child, .check:last-child { margin-bottom: 0; }

input, select, textarea, button { font: inherit; }

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  color: var(--fg);
  background: var(--input-bg);
  border: 1px solid var(--input-bg);
  border-radius: var(--input-border-radius);
  padding: 0.2rem 0.7rem;
}
textarea { padding: 0.4rem 0.7rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 0.8rem; }

.check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; cursor: pointer; }
.check input { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--primary); }

.thumb-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.thumb-actions { min-width: 0; }
.thumb-actions .btn { padding: 0.2rem 0.6rem; }
.thumb {
  width: 96px; height: 54px; flex: 0 0 auto;
  border-radius: var(--input-border-radius);
  background: var(--input-bg) center / cover no-repeat;
}
.copy-row { display: flex; gap: 0.4rem; }
.copy-row input { font-family: ui-monospace, monospace; font-size: 0.85rem; }

/* ---------- buttons ---------- */
.btn {
  font-weight: 700;
  padding: 0.2rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--input-border-radius);
  background: var(--input-bg);
  color: var(--fg);
  cursor: pointer;
}
.btn:hover { background: var(--bg-secondary); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-quiet { background: transparent; color: var(--muted); font-weight: 400; }
.btn-quiet:hover { background: var(--input-bg); color: var(--fg); }
.btn-block { width: 100%; margin-top: 0.3rem; }
.btn-icon { padding: 0.2rem 0.5rem; }
.btn[aria-busy="true"] { opacity: 0.6; }

.actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed; inset-inline: 0.9rem; bottom: 0.9rem;
  max-width: 340px; margin-inline: auto;
  background: var(--fg); color: var(--bg);
  padding: 0.45rem 0.9rem; border-radius: var(--input-border-radius);
  text-align: center; z-index: 20;
}
.toast[data-kind="error"] { background: var(--red); color: #fff; }

@media (min-width: 560px) {
  .view-in, .topbar-in { max-width: 520px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

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