@font-face {
  font-family: "MD Nichrome";
  src: url("fonts/MDNichrome-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@property --accent-hue {
  syntax: "<number>";
  inherits: true;
  initial-value: 290;
}

:root {
  --bg: #0e0e12;
  --surface: #15151c;
  --surface-2: #20202a;
  --border: #2f2f3a;
  --text: #f0f0f5;
  --text-muted: #aaa9b8;
  --accent-hue: 290;
  --accent: hsl(var(--accent-hue), 85%, 62%);
  --accent-hover: hsl(var(--accent-hue), 90%, 52%);
  --danger: #e74c3c;
  --success: #2ecc71;
  --owner-mike: linear-gradient(135deg, #2563eb, #06b6d4);
  --owner-kaitlin: linear-gradient(135deg, #c026d3, #ec4899);
  --owner-both: linear-gradient(135deg, #3b82f6, #ec4899);
  --display-font: "MD Nichrome", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: accent-shift 50s linear infinite;
}

@keyframes accent-shift {
  0%   { --accent-hue: 290; }
  100% { --accent-hue: 650; }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}

body {
  background: transparent;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.bg-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: -2;
  pointer-events: none;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(14, 14, 18, 0.5), rgba(14, 14, 18, 0.55)),
    linear-gradient(
      135deg,
      hsla(290, 90%, 55%, 0.55),
      hsla(220, 90%, 60%, 0.55),
      hsla(180, 90%, 55%, 0.55),
      hsla(140, 80%, 55%, 0.55),
      hsla(45,  95%, 60%, 0.55),
      hsla(15,  95%, 60%, 0.55),
      hsla(330, 95%, 60%, 0.55)
    );
  background-size: 100% 100%, 400% 400%;
  animation: tie-dye-flow 35s ease-in-out infinite;
}

@keyframes tie-dye-flow {
  0%   { background-position: 0% 0%, 0% 0%; }
  33%  { background-position: 0% 0%, 100% 50%; }
  66%  { background-position: 0% 0%, 50% 100%; }
  100% { background-position: 0% 0%, 0% 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-video { display: none; }
  .bg-overlay { animation: none; }
  :root { animation: none; }
  .btn-primary, .seg-btn.active { animation: none; }
  .vinyl-card, .collection-table tbody tr { animation: none; }
}

/* On mobile, freeze the continuous CSS animations. They look great on
   desktop but on iOS Safari they cause constant repaints which add
   memory + CPU pressure and accelerate tab eviction. The static
   gradients still show, just don't pan or cycle hue. */
@media (max-width: 600px) {
  .bg-overlay {
    animation: none;
    background-size: 100% 100%, 100% 100%;
    background-position: 0% 0%;
  }
  :root { animation: none; }
  .btn-primary,
  .seg-btn.active,
  .seg-btn.active::after,
  .search-input:focus,
  .sort-select:focus {
    animation: none;
  }
}

.site-header {
  background: transparent;
  border-bottom: 1px solid rgba(47, 47, 58, 0.6);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: padding 0.25s ease;
}

.site-logo img {
  transition: height 0.25s ease;
}

@media (min-width: 601px) {
  .site-header.scrolled {
    padding: 12px 0;
  }
  .site-header.scrolled .site-logo img {
    height: 53px;
  }
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.site-logo {
  margin: 0;
  padding: 0;
  font-size: 0;
  line-height: 0;
  display: flex;
  align-items: center;
}

.site-logo img {
  height: 88px;
  width: auto;
  display: block;
  filter:
    drop-shadow(0 0 18px hsla(var(--accent-hue), 95%, 55%, 0.7))
    drop-shadow(0 0 42px hsla(calc(var(--accent-hue) + 140), 95%, 60%, 0.45));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.record-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.search-input,
.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: var(--display-font);
  letter-spacing: 0.02em;
}

.select-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.select-wrap .sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  width: 100%;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 10px;
  height: 14px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='14' viewBox='0 0 10 14'><path d='M5 0 L10 5 L0 5 Z' fill='%23fff'/><path d='M5 14 L10 9 L0 9 Z' fill='%23fff'/></svg>");
  background-repeat: no-repeat;
  pointer-events: none;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.search-input:focus,
.sort-select:focus {
  outline: none;
  border: 2px solid transparent;
  padding: 9px 17px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(
      135deg,
      hsl(320, 95%, 56%) 0%,
      hsl(195, 95%, 55%) 35%,
      hsl(280, 95%, 58%) 65%,
      hsl(195, 95%, 55%) 100%
    ) border-box;
  background-size: 100% 100%, 300% 300%;
  animation: btn-swirl 8s ease-in-out infinite;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--display-font);
  letter-spacing: 0.03em;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary,
.seg-btn.active {
  background: linear-gradient(
    135deg,
    hsl(320, 95%, 56%) 0%,
    hsl(195, 95%, 55%) 35%,
    hsl(280, 95%, 58%) 65%,
    hsl(195, 95%, 55%) 100%
  );
  background-size: 300% 300%;
  color: #fff;
  animation: btn-swirl 8s ease-in-out infinite;
  position: relative;
}

.seg-btn.active::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 999px;
  padding: 1.5px;
  background: linear-gradient(
    135deg,
    hsl(320, 95%, 65%) 0%,
    hsl(195, 95%, 65%) 35%,
    hsl(280, 95%, 65%) 65%,
    hsl(195, 95%, 65%) 100%
  );
  background-size: 300% 300%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: btn-swirl 8s ease-in-out infinite;
  pointer-events: none;
}

.btn-primary:hover {
  filter: brightness(1.12);
}

@keyframes btn-swirl {
  0%   { background-position: 0% 50%; }
  25%  { background-position: 100% 50%; }
  50%  { background-position: 50% 100%; }
  75%  { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.4);
  margin-right: auto;
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.25);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
  font-size: 0.95rem;
}

.status:empty {
  display: none;
}

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

.vinyl-card {
  background: rgba(21, 21, 28, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  animation: vinyl-fade-in 0.45s ease both;
  animation-delay: calc(var(--stagger, 0) * 28ms);
}

.collection-table tbody tr {
  animation: vinyl-fade-in 0.4s ease both;
  animation-delay: calc(var(--stagger, 0) * 22ms);
}

@keyframes vinyl-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vinyl-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.vinyl-cover {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface-2);
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 14px;
  overflow: hidden;
  position: relative;
}

.vinyl-cover::before {
  content: "\266B";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--border);
}

.vinyl-cover img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

.vinyl-album {
  font-family: var(--display-font);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
  color: #fff;
}

.vinyl-artist {
  font-family: var(--display-font);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.vinyl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.vinyl-tag {
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--display-font);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 12px;
}

.vinyl-tag.owner {
  background: hsla(var(--accent-hue), 85%, 50%, 0.18);
  color: var(--accent);
  font-weight: 700;
}

.vinyl-tag.owner.owner-mike {
  background: var(--owner-mike);
  color: #fff;
}

.vinyl-tag.owner.owner-kaitlin {
  background: var(--owner-kaitlin);
  color: #fff;
}

.vinyl-tag.owner.owner-both {
  background: var(--owner-both);
  color: #fff;
}

.vinyl-notes {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
}

.modal-close:hover {
  color: var(--text);
}

.add-form {
  padding: 24px;
}

.form-row {
  margin-bottom: 16px;
}

.action-modal {
  max-width: 420px;
}

.action-body {
  padding: 20px 24px 24px;
}

.action-artist {
  color: var(--accent);
  font-family: var(--display-font);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

.action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.vinyl-card,
.collection-table tbody tr {
  cursor: pointer;
}

.autocomplete-row {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 260px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow);
}

.autocomplete-results[hidden] {
  display: none;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
}

.autocomplete-item:hover {
  background: var(--surface-2);
}

.autocomplete-item img,
.autocomplete-item .ac-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--surface-2);
}

.autocomplete-item .ac-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.autocomplete-item .ac-primary {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-item .ac-secondary {
  color: var(--text-muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.password-row {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.form-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
}

.form-status.success {
  display: block;
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.form-status.error {
  display: block;
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0 20px;
}

.archive-title {
  font-family: var(--display-font);
  font-weight: 700;
  font-size: clamp(2.75rem, 9vw, 5.5rem);
  letter-spacing: 0.02em;
  line-height: 1;
  margin: 0;
  color: transparent;
  -webkit-text-stroke: 1px #fff;
}

.archive-row .header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.archive-title .archive-fill {
  color: #fff;
  -webkit-text-stroke: 0;
}

/* Segmented controls (owner filter + view toggle) */
.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--display-font);
  letter-spacing: 0.03em;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}

.seg-btn:hover:not(.active) {
  color: var(--text);
}

/* Table view */
.collection-table-wrap {
  background: rgba(21, 21, 28, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.collection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.collection-table thead th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.collection-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.collection-table thead th.sortable:hover {
  color: var(--text);
}

.collection-table thead th.sorted {
  color: var(--text);
}

.sort-arrow {
  display: inline-block;
  font-size: 0.65rem;
  margin-left: 6px;
  opacity: 0.85;
  vertical-align: middle;
}

.collection-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.collection-table tbody tr:last-child td {
  border-bottom: none;
}

.collection-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.collection-table .t-album,
.collection-table .t-artist {
  width: 50%;
}

.collection-table .t-artist {
  font-family: var(--display-font);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.collection-table .t-album {
  font-family: var(--display-font);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.collection-table .t-year {
  color: var(--text-muted);
  font-family: var(--display-font);
  letter-spacing: 0.04em;
  width: 70px;
}

.collection-table .t-owner {
  width: 110px;
}

.collection-table .th-cover,
.collection-table .t-cover {
  width: 56px;
  padding-right: 0;
}

.table-cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.table-cover::before {
  content: "\266B";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--border);
}

.table-cover img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

@media (max-width: 600px) {
  .record-count {
    display: none;
  }
  #add-btn .btn-text {
    display: none;
  }
  #add-btn {
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .search-input {
    grid-column: 1 / -1;
    width: 100%;
  }
  .sort-select {
    min-width: 0;
    padding: 10px 14px;
  }
  #owner-filter,
  #view-toggle {
    width: 100%;
    justify-content: center;
  }
  #view-toggle {
    grid-column: 1 / -1;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    justify-self: center;
  }
  .seg-btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 0.85rem;
    text-align: center;
  }
  .form-row.two-col {
    grid-template-columns: 1fr;
  }
  .collection-table .t-year {
    display: none;
  }
  .collection-table thead th:nth-child(4) {
    display: none;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  .collection-table .t-owner {
    display: none;
  }
  .collection-table thead th:nth-child(5) {
    display: none;
  }
}
