:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #dbdbdb;
  --text: #262626;
  --muted: #8e8e8e;
  --accent: #0095f6;
  --error: #ed4956;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #121212;
    --border: #363636;
    --text: #f5f5f5;
    --muted: #a8a8a8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.logo {
  font: 600 24px/1 "Segoe Script", "Brush Script MT", cursive;
  color: var(--text);
  text-decoration: none;
  margin: 0;
}

main {
  max-width: 935px;
  margin: 0 auto;
  padding: 24px 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1px;
}

.login {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 350px;
  margin: 48px auto;
  padding: 40px;
  text-align: center;
}

.login .logo { margin-bottom: 24px; font-size: 36px; }

input {
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button {
  padding: 7px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 600 14px/18px inherit;
  cursor: pointer;
}

button.link {
  background: none;
  color: var(--text);
  padding: 0;
}

.error { color: var(--error); margin: 0 0 8px; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 48px 0; }

.menu { display: flex; align-items: center; gap: 16px; }
.menu a { color: var(--text); font-weight: 600; text-decoration: none; }
.menu form { margin: 0; }

h1 { font-size: 20px; margin: 0 0 16px; }

select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button.secondary { background: var(--border); color: var(--text); }
button.danger { background: var(--error); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.inline-form .error { flex-basis: 100%; margin: 0; }

.table-wrap { overflow-x: auto; }

.users { width: 100%; border-collapse: collapse; }
.users th, .users td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.users th { color: var(--muted); font-weight: 600; }
.users form { display: flex; gap: 8px; margin: 4px 0 0; }
.users td > form:first-child { margin-top: 0; }
.users input { width: 140px; }

h2 { font-size: 16px; margin: 24px 0 12px; }
button:disabled { opacity: .5; cursor: default; }

.quota { flex-basis: 100%; margin: 0; }

.profile-list { list-style: none; margin: 0; padding: 0; }
.profile-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.profile-list li:last-child { border-bottom: 0; }
.profile-list a { color: var(--text); font-weight: 600; text-decoration: none; }
.profile-list form { margin: 0 0 0 auto; }

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text);
  font-size: 12px;
}
.status-active { background: #58c32233; }
.status-pending { background: #0095f633; }
.status-not_found, .status-private_needs_admin, .status-unavailable { background: #ed495633; }

.profile-header { padding: 16px 0; }

.small { font-size: 12px; }
h1 a { color: inherit; text-decoration: none; }

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  padding: 16px;
  margin-bottom: 24px;
}
.stacked-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.stacked-form label.check { flex-direction: row; align-items: center; font-weight: 400; }
.stacked-form button { align-self: flex-start; }

.status-account-active { background: #58c32233; }
.status-account-cooldown { background: #f5a62333; }
.status-account-needs_action { background: #ed495633; }

/* Profile page */
.profile-header { display: flex; gap: 32px; align-items: flex-start; padding: 16px 0 32px; }
.avatar { flex: none; border-radius: 50%; overflow: hidden; background: var(--border); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-large { width: 150px; height: 150px; }
.profile-info { min-width: 0; }
.profile-title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.profile-title h1 { margin: 0; font-size: 20px; font-weight: 400; }
.profile-title form { margin: 0; }
.counters { display: flex; gap: 24px; list-style: none; padding: 0; margin: 16px 0; }
.full-name { font-weight: 600; margin: 0; }
.bio { white-space: pre-line; margin: 4px 0; }

.profile-history { margin: 0 16px 16px; }
.profile-history summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.snapshots { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.snapshot { display: flex; gap: 12px; align-items: flex-start; }
.snapshot .avatar { width: 44px; height: 44px; flex: none; }
.snapshot .bio { margin: 0; }

.tabs { display: flex; justify-content: center; gap: 48px; border-top: 1px solid var(--border); margin-bottom: 4px; }
.tab { padding: 14px 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; text-decoration: none; border-top: 1px solid transparent; margin-top: -1px; }
.tab.active { color: var(--text); border-top-color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; display: block; aspect-ratio: 3 / 4; background: var(--border); overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-reels .tile, .grid-stories .tile { aspect-ratio: 9 / 16; }
.grid-day { grid-column: 1 / -1; margin: 16px 0 4px; font-size: 14px; font-weight: 600; }
.tile-icon { position: absolute; top: 8px; right: 8px; color: #fff; font-size: 18px; text-shadow: 0 0 4px rgba(0, 0, 0, .6); }
.grid-more { grid-column: 1 / -1; height: 1px; }
.badge-deleted { position: absolute; left: 8px; bottom: 8px; padding: 2px 6px; border-radius: 4px; background: rgba(237, 73, 86, .9); color: #fff; font-size: 11px; font-weight: 600; }
.badge-deleted.static { position: static; }
.slide { position: relative; }

/* Post */
.post-dialog { padding: 0; border: 0; border-radius: 4px; max-width: min(1100px, 96vw); width: 100%; background: var(--surface); color: var(--text); }
.post-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-close { position: fixed; top: 12px; right: 16px; background: none; color: #fff; font-size: 32px; z-index: 2; }
.post { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); }
.post-page .post { border: 1px solid var(--border); background: var(--surface); }
.carousel { position: relative; background: #000; }
.carousel-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; margin: 0; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; max-height: 90vh; }
.slide img, .slide video { max-width: 100%; max-height: 90vh; height: auto; object-fit: contain; }
.carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, .8); color: #000; font-size: 20px; }
.carousel-arrow.prev { left: 8px; }
.carousel-arrow.next { right: 8px; }
.carousel-dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; }
.carousel-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.carousel-dots span.active { background: #fff; }
.post-side { padding: 16px; border-left: 1px solid var(--border); overflow-y: auto; max-height: 90vh; }
.caption { white-space: pre-line; margin-top: 0; }
.credits { font-weight: 600; margin-top: 0; }
.credits a { color: var(--text); text-decoration: none; }
.caption-history summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.caption-revision { border-left: 2px solid var(--border); padding-left: 8px; margin-top: 8px; }
.post-links { display: flex; flex-wrap: wrap; gap: 12px; }
.post-links a { color: var(--accent); text-decoration: none; }

/* Stories */
.story-dialog { padding: 0; border: 0; background: transparent; overflow: visible; max-width: none; max-height: none; }
.story-dialog::backdrop { background: rgba(0, 0, 0, .9); }
.story-player {
  position: relative;
  height: min(90dvh, 860px);
  aspect-ratio: 9 / 16;
  max-width: 100vw;
  margin: 0 auto;
  border-radius: 8px;
  background: #000;
  color: #fff;
}
.story-page .story-player { height: min(calc(100dvh - 96px), 860px); margin-top: 16px; }
.story { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: inherit; }
/* display: flex above would otherwise beat the hidden attribute. */
.story[hidden], .story-time[hidden], .story-control[hidden] { display: none; }
.story img, .story video { width: 100%; height: 100%; object-fit: contain; }
.story-zone { position: absolute; top: 64px; bottom: 0; width: 50%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.story-zone.prev { left: 0; }
.story-zone.next { right: 0; }
.story-top { position: absolute; top: 0; left: 0; right: 0; padding: 8px 8px 16px; border-radius: 8px 8px 0 0; background: linear-gradient(rgba(0, 0, 0, .45), transparent); }
.story-progress { display: flex; gap: 4px; }
.story-progress span { flex: 1; height: 2px; background: rgba(255, 255, 255, .35); border-radius: 1px; overflow: hidden; }
.story-progress i { display: block; width: 0; height: 100%; background: #fff; }
.story-bar { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.story-time { margin-right: auto; font-size: 13px; text-shadow: 0 0 4px rgba(0, 0, 0, .6); }
.story-control { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; }
.story-control:hover, .story-control:focus-visible { background: rgba(255, 255, 255, .15); }
.story-control svg { width: 22px; height: 22px; fill: currentColor; }
.story-control .icon-play, .story-control[aria-pressed="true"] .icon-pause { display: none; }
.story-control[aria-pressed="true"] .icon-play { display: block; }
[data-story-mute] .icon-muted, [data-story-mute][aria-pressed="true"] .icon-sound { display: none; }
[data-story-mute][aria-pressed="true"] .icon-muted { display: block; }
.story-arrow {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  color: #262626;
  cursor: pointer;
  transition: background-color .15s, scale .15s;
}
.story-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.story-arrow.prev { right: calc(100% + 20px); }
.story-arrow.next { left: calc(100% + 20px); }
.story-arrow:hover, .story-arrow:focus-visible { background: #fff; scale: 1.1; }
.story-arrow[hidden] { display: none; }

@media (max-width: 735px) {
  .story-dialog { width: 100%; height: 100%; margin: 0; }
  .story-player { width: 100%; height: 100dvh; aspect-ratio: auto; border-radius: 0; }
  .story-page .story-player { height: calc(100dvh - 56px); margin-top: 0; }
  .story-top { border-radius: 0; }
  .story-dialog .story-bar { padding-right: 60px; }
  .story-arrow { display: none; }
}

@media (max-width: 735px) {
  main { padding: 0 0 24px; }
  .profile-header { gap: 16px; padding: 16px; }
  .avatar-large { width: 77px; height: 77px; }
  .counters { gap: 16px; font-size: 13px; }
  .tabs { gap: 32px; }
  .grid { gap: 2px; }
  .post { grid-template-columns: 1fr; }
  .post-side { border-left: 0; border-top: 1px solid var(--border); max-height: none; }
  .post-dialog { max-width: 100vw; max-height: 100vh; margin: 0; border-radius: 0; }
}

.banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #e1306c;
}

.storage { padding: 16px; }

.storage-numbers { margin: 0 0 8px; }

.storage-bar {
  height: 8px;
  background: var(--border);
  overflow: hidden;
}

.storage-bar i { display: block; height: 100%; background: #e1306c; }

.tile-missing,
.media-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px;
  color: var(--muted);
  text-align: center;
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.status-done { background: #58c32233; }
.status-queued, .status-deferred { background: #0095f633; }
.status-running { background: #f5a62333; }
.status-failed { background: #ed495633; }

.grid-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 96px;
  color: var(--text);
  text-decoration: none;
}

.highlight-cover { width: 96px; height: 96px; }

.highlight-title {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.avatar-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 72px;
  color: var(--text);
  text-decoration: none;
}

.avatar-link .small { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-medium { display: block; width: 64px; height: 64px; }

.avatar.has-stories { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #e1306c; }

.danger-zone { margin: 24px 0; }

.danger-zone summary { color: var(--error); cursor: pointer; }

