:root {
  --ink: #000000;
  --paper: #F2E8D6;
  --gold: #ECBE1D;
  --flame: #FA4A17;
  --ocean: #4F6C87;
  --olive: #9E8033;
  --maroon: #4F1A17;
  --panel: #ece5d6;
  --panel-2: #f5efe4;
  --muted: #655d4d;
  --danger: #a3322a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "DM Sans", "Avenir Next", "Segoe UI", sans-serif;
  background: var(--paper);
  min-height: 100vh;
}

/* --- Brand geometric frame shapes (lines only, black) --- */

.bg-orb {
  position: fixed;
  width: 140px;
  height: 140px;
  border: 2px solid rgba(0, 0, 0, 0.18);
  z-index: 0;
  pointer-events: none;
  background: none;
}

.bg-orb::before,
.bg-orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}

.bg-orb::after {
  transform: rotate(-28deg);
}

.orb-a {
  left: 24px;
  top: 200px;
  background: none;
}

.orb-b {
  right: 32px;
  top: 200px;
  background: none;
}

/* --- Header --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.2);
  background: var(--gold);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Syne", "Avenir Next Condensed", sans-serif;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
}

.tagline {
  margin: 4px 0 0;
  color: rgba(0, 0, 0, 0.6);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* --- Navigation tabs --- */

.nav-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 24px;
  background: var(--maroon);
  border-bottom: 2px solid rgba(0, 0, 0, 0.2);
}

.tab {
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--paper);
  padding: 14px 24px;
  border-radius: 0;
  cursor: pointer;
  font-family: "Syne", sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 130ms ease, border-color 130ms ease;
}

.tab:hover {
  color: #ffffff;
  background: none;
  transform: none;
  border-bottom-color: rgba(242, 232, 214, 0.4);
}

.tab.active {
  color: #ffffff;
  background: none;
  border-bottom-color: var(--flame);
}

/* --- Auth chip --- */

.auth-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.auth-chip span {
  color: rgba(0, 0, 0, 0.7);
}

.auth-chip button {
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.25);
  padding: 5px 10px;
  font-size: 12px;
}

/* --- Main content area --- */

main {
  position: relative;
  z-index: 1;
  padding: 22px;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- Panels --- */

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 0;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}

/* --- Buttons --- */

button {
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: transform 130ms ease, background-color 130ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #ffffff;
}

/* --- Search form --- */

.search-form {
  display: grid;
  grid-template-columns: 1fr 140px 160px auto;
  gap: 10px;
  padding: 14px;
}

.search-form button {
  background: var(--maroon);
  color: var(--paper);
  border-color: var(--maroon);
  font-weight: 700;
  font-family: "Syne", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.search-form button:hover {
  background: #3a1210;
  transform: translateY(-1px);
  color: #ffffff;
}

input,
select {
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 0;
  padding: 10px;
  background: #fffdf7;
  color: var(--ink);
  font-family: inherit;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--flame);
  outline-offset: 1px;
}

/* --- Status --- */

.status {
  min-height: 24px;
  color: var(--muted);
  margin: 14px 4px;
  font-weight: 500;
}

/* --- Views --- */

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 260ms ease;
}

/* --- Auth gate (full-page sign-in overlay) --- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  display: none;
}

.auth-gate:not([hidden]) {
  display: flex;
}

.auth-gate::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 260px;
  background: var(--gold);
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
}

.auth-gate > div {
  position: relative;
  z-index: 1;
}

.auth-gate .auth-branding {
  text-align: center;
  margin-bottom: 28px;
}

.auth-gate .auth-branding h1 {
  font-size: clamp(40px, 6vw, 72px);
}

.auth-gate .auth-branding .tagline {
  margin: 8px 0 0;
  font-size: 13px;
}

.auth-panel {
  max-width: 420px;
  width: 100%;
  padding: 36px;
  text-align: center;
}

.auth-panel h2 {
  margin-bottom: 8px;
  font-weight: 700;
}

.auth-panel .card-meta {
  margin-bottom: 20px;
}

.auth-panel #google-signin-button {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.auth-panel #auth-error {
  margin-top: 12px;
  color: var(--danger);
}

/* --- Animations --- */

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Provider sections --- */

.provider-section {
  margin-top: 24px;
  opacity: 0;
  transform: translateY(8px);
  animation: section-in 280ms ease forwards;
}

@keyframes section-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.provider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.provider-header h2 {
  text-transform: uppercase;
  font-size: 18px;
  font-weight: 700;
}

.provider-badge {
  background: var(--maroon);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
}

/* --- Card grid --- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 0;
  overflow: hidden;
  background: #faf5ec;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
}

.media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #ddd3bf;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
}

.media img,
.media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 170ms ease;
}

.media:hover video {
  opacity: 1;
}

.save-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--maroon);
  border: 2px solid rgba(242, 232, 214, 0.8);
  color: var(--paper);
  font-size: 18px;
  padding: 0;
}

.save-btn:hover {
  background: var(--flame);
  transform: scale(1.1);
}

.card-body {
  padding: 10px;
}

.card-title {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 7px;
}

.card-meta {
  color: var(--muted);
  font-size: 12px;
}

/* --- Collections --- */

.collections-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
}

.inline-form {
  display: flex;
  gap: 8px;
}

.collection-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  background: #f3ecdd;
}

.link {
  color: var(--ocean);
  text-decoration: none;
  font-weight: 700;
}

.link:hover {
  text-decoration: underline;
}

.danger {
  color: var(--paper);
  background: var(--danger);
  border-color: rgba(0, 0, 0, 0.2);
}

/* --- Dialog --- */

dialog {
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: #f9f3e8;
  color: var(--ink);
  padding: 24px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

/* --- Search layout with sidebar --- */

.search-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 110px;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 500;
}

.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-dot.active {
  background: #2d8a4e;
}

.source-dot.pending {
  background: var(--olive);
}

.source-name {
  flex: 1;
}

.source-status-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #2d8a4e;
}

.source-status-label.pending {
  color: var(--olive);
}

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

/* --- Responsive --- */

@media (max-width: 900px) {
  .search-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: start;
    gap: 10px;
  }

  .auth-chip {
    width: 100%;
    justify-content: space-between;
  }

  .nav-bar {
    padding: 0 16px;
  }

  .tab {
    flex: 1;
    text-align: center;
    padding: 12px 16px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .collections-header {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form {
    flex-direction: column;
  }

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

  .sidebar {
    position: static;
    display: flex;
    gap: 16px;
  }

  .sidebar-section {
    flex: 1;
    margin-bottom: 0;
  }

  .orb-a,
  .orb-b {
    display: none;
  }
}
