:root {
  --bg: #101214;
  --bg-elev: #181b1f;
  --bg-hover: #22262c;
  --text: #ececec;
  --muted: #8f969e;
  --border: #2c3239;
  --accent: #ea5d30;
  --accent-text: #1a0c08;
  --brand-slate: #32404b;
  --danger: #c45c5c;
  --danger-text: #1a0808;
  --input: #0c0e11;
  --radius: 6px;
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Outfit", "Figtree", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.wrap {
  flex: 1 0 auto;
  width: 100%;
}

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

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* App bar — brand centered */
header.appbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.appbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-top: 0.95rem;
  padding-bottom: 0.95rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  text-decoration: none;
  line-height: 0;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.92;
}

.brand-logo {
  display: block;
  height: 2.35rem;
  width: auto;
}

.nav {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.nav a {
  color: var(--muted);
}

.nav a:hover {
  color: var(--text);
}

.nav-start {
  justify-content: flex-start;
}

.nav-end {
  justify-content: flex-end;
}

.nav-user {
  color: var(--text);
}

.navform {
  display: inline;
  margin: 0;
}

.nav-spacer {
  display: inline-block;
  width: 1px;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding-top: 1rem;
  padding-bottom: 1.15rem;
}

.footer-mark {
  display: block;
  height: 1.65rem;
  width: auto;
  opacity: 0.9;
}

.footer-copy {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

h1 {
  font-family: var(--display);
  font-size: 1.55rem;
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

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

.error {
  color: var(--danger);
  margin: 0.75rem 0;
}

.flash {
  color: var(--accent);
  margin: 0.75rem 0;
}

.auth-panel,
.account-panel {
  max-width: 420px;
  margin: 2rem auto 0;
  text-align: left;
}

.auth-logo {
  display: block;
  height: 2.75rem;
  width: auto;
  margin: 0 0 1.1rem;
}

.auth-panel h1,
.account-panel h1 {
  text-align: left;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"] {
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  font: inherit;
}

button,
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.btn:hover {
  filter: brightness(1.05);
  text-decoration: none;
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

button.danger,
.btn.danger {
  background: var(--danger);
  color: var(--danger-text);
}

button.secondary,
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.compact {
  padding: 0.35rem 0.7rem;
  font-size: 0.88rem;
}

/* Library */
.library {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.outliner {
  position: sticky;
  top: 1rem;
  border-right: 1px solid var(--border);
  padding-right: 0.9rem;
  min-height: 10rem;
}

.outliner-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.outliner-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.42rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
}

.outliner-link:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.outliner-link.active {
  background: var(--bg-hover);
  color: var(--accent);
}

.outliner-link .count {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.outliner-game {
  margin-top: 0.55rem;
}

.outliner-link.game {
  font-weight: 600;
}

.outliner-folders {
  margin-left: 0.55rem;
  border-left: 1px solid var(--border);
  padding-left: 0.35rem;
}

.outliner-link.folder {
  font-size: 0.88rem;
  color: var(--muted);
}

.outliner-link.folder.active {
  color: var(--accent);
}

.library-main {
  min-width: 0;
}

.library-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.library-header h1 {
  margin-bottom: 0;
}

.library-count {
  margin: 0;
  font-size: 0.88rem;
  white-space: nowrap;
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.batch-select-all {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.batch-count {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}

.replay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.15rem;
}

.replay-card {
  position: relative;
  min-width: 0;
}

.card-select {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
  display: flex;
  margin: 0;
  padding: 0.2rem;
  background: rgba(16, 18, 20, 0.72);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.card-select input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.card-link {
  display: grid;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.card-link:hover {
  text-decoration: none;
}

.card-link:hover .video-thumb {
  border-color: var(--accent);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0c0f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.thumb-badge {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.thumb-badge.private {
  color: var(--muted);
  background: rgba(16, 18, 20, 0.82);
  border: 1px solid var(--border);
}

.replay-author {
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}

.replay-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-top: 0.12rem;
}

.meta .replay-stats {
  margin-top: 0.15rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.video-thumb .thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  background: #0a0c0f;
}

.replay-meta {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.jacket-wrap {
  width: 48px;
  height: 48px;
}

.jacket {
  width: 48px;
  height: 48px;
  object-fit: cover;
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.jacket.placeholder {
  display: block;
  background: var(--bg-hover);
}

.replay-info {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.replay-title {
  font-weight: 600;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-diff {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
}

.replay-sub {
  font-size: 0.8rem;
}

.replay-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}

.detail {
  max-width: 1120px;
  margin: 0 auto;
}

.meta {
  display: grid;
  gap: 0.3rem;
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.25rem;
  align-items: start;
}

.watch-main {
  min-width: 0;
}

video.player {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.prose {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.replay-description,
.owner-panel {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.comments {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  max-height: min(82vh, 820px);
  padding: 0.85rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.comments h2 {
  margin: 0;
  font-size: 1rem;
}

.comment-scroll {
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 0.15rem;
}

.description-empty {
  margin: 0.85rem 0 0;
}

.compact-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.55rem;
  justify-items: start;
}

.compact-form label {
  width: 100%;
}

.compact-form textarea {
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
  width: 100%;
  max-width: 36rem;
  min-height: 2.6rem;
}

.compact-form > button,
.compact-form .btn {
  width: auto;
  justify-self: start;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  width: 100%;
  max-width: 36rem;
}

.form-row .check-label {
  margin: 0;
  padding: 0;
}

.comments .compact-form textarea {
  max-width: none;
}

.comment-form {
  margin: 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.comment-empty {
  margin: 0.35rem 0 0;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.comment {
  display: grid;
  gap: 0.35rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.comment-head {
  display: flex;
  gap: 0.65rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.comment-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.comment-replies {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0 0 0 0.75rem;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 0.75rem;
}

.comment-replies .comment-replies {
  padding-left: 0.65rem;
}

.comment.is-reply {
  padding-bottom: 0.55rem;
  border-bottom: none;
}

.reply-hint {
  margin: 0;
  font-size: 0.82rem;
}

.comment-actions {
  max-width: none;
}

.mention-wrap {
  position: relative;
}

.mention-suggest {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 10rem;
  overflow: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.mention-suggest li {
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
}

.mention-suggest li.is-active,
.mention-suggest li:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.nav-inbox {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.inbox-badge {
  display: inline-block;
  min-width: 1.15rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

.inbox-panel {
  max-width: 720px;
  margin: 0 auto;
}

.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.inbox-header h1 {
  margin: 0;
}

.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.inbox-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.inbox-item.unread {
  border-color: var(--accent);
}

.inbox-link {
  color: inherit;
  text-decoration: none;
  display: grid;
  gap: 0.25rem;
}

.inbox-link:hover {
  text-decoration: none;
}

.inbox-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: baseline;
}

.inbox-title {
  font-weight: 600;
}

.inbox-body {
  margin: 0;
  font-size: 0.9rem;
}

.inbox-mark {
  margin: 0;
}

code.key {
  display: block;
  word-break: break-all;
  background: var(--input);
  border: 1px solid var(--border);
  padding: 0.65rem;
  border-radius: var(--radius);
  margin: 0.5rem 0 1rem;
  font-size: 0.85rem;
}

.empty {
  color: var(--muted);
  margin-top: 1.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-panel {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  gap: 1.4rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
}

.admin-create {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.admin-create h2,
.admin-panel h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}

.admin-create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
}

.admin-create-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-create-form input[type="text"],
.admin-create-form input[type="password"],
.admin-action-stack input[type="password"] {
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  min-width: 10rem;
  font: inherit;
}

.check-label {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  color: var(--text) !important;
  padding-bottom: 0.35rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tr.is-blocked td {
  opacity: 0.72;
}

.admin-user {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}

.admin-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.badge.danger {
  color: var(--danger);
}

.badge.muted-badge {
  color: var(--muted);
}

.admin-actions {
  min-width: 11rem;
}

.admin-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  list-style: none;
}

.admin-details summary::-webkit-details-marker {
  display: none;
}

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

.admin-action-stack {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

@media (max-width: 760px) {
  .wrap {
    padding: 1rem;
  }

  .appbar-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.65rem;
    text-align: center;
  }

  .nav-start,
  .nav-end {
    justify-content: center;
    width: 100%;
  }

  .brand {
    order: -1;
  }

  .brand-logo {
    height: 2.6rem;
  }

  .library {
    grid-template-columns: 1fr;
    gap: 1.1rem;
  }

  .outliner {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 0.85rem;
  }

  .outliner-folders {
    display: flex;
    flex-wrap: wrap;
    border-left: none;
    margin-left: 0;
    padding-left: 0;
    gap: 0.25rem;
  }

  .library-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .batch-bar {
    position: sticky;
    top: 0;
    z-index: 3;
  }

  .replay-grid {
    grid-template-columns: 1fr;
  }

  .card-select {
    top: 0.7rem;
    left: 0.7rem;
    padding: 0.35rem;
  }

  .card-select input {
    width: 1.15rem;
    height: 1.15rem;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-create-form {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-create-form input[type="text"],
  .admin-create-form input[type="password"] {
    min-width: 0;
    width: 100%;
  }

  .watch-layout {
    grid-template-columns: 1fr;
  }

  .comments {
    max-height: min(60vh, 520px);
  }
}
