:root {
  color-scheme: light;
  --ink: #19213a;
  --muted: #68718a;
  --paper: #edf1fa;
  --card: #ffffff;
  --broadcast: #304fce;
  --broadcast-dark: #223a9e;
  --signal: #f06449;
  --review: #f5b84c;
  --review-soft: #fff0c7;
  --checked-soft: #dfe6ff;
  --line: #cbd3e5;
  --shadow: rgba(25, 33, 58, 0.14);
  --display: "Arial Narrow", "Avenir Next Condensed", "Roboto Condensed", system-ui, sans-serif;
  --body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --utility: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 31px, rgba(48, 79, 206, 0.06) 32px, transparent 33px),
    var(--paper);
  background-size: 32px 100%;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--broadcast);
  font-family: var(--utility);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--broadcast);
  color: white;
  z-index: 50;
}

.boot p {
  margin: 0;
  font-family: var(--utility);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tape-loader,
.auth-mark {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 92px;
  height: 58px;
  padding: 12px;
  border: 4px solid currentColor;
  border-radius: 8px;
}

.tape-loader span,
.auth-mark span {
  width: 24px;
  height: 24px;
  border: 5px dotted currentColor;
  border-radius: 50%;
  animation: spin 1.8s linear infinite;
}

.tape-loader span:last-child {
  animation-direction: reverse;
}

.auth-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: space-between;
  padding: max(40px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 88% 12%, rgba(245, 184, 76, 0.88) 0 10%, transparent 10.3%),
    linear-gradient(150deg, var(--paper) 0 67%, var(--checked-soft) 67%);
}

.auth-panel {
  width: min(100%, 480px);
  margin: auto;
}

.auth-mark {
  margin-bottom: 40px;
  color: var(--broadcast);
  transform: rotate(-4deg);
  box-shadow: 7px 7px 0 var(--review);
}

.auth-mark span {
  animation: none;
}

.auth-panel h1 {
  max-width: 390px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3rem, 14vw, 5.5rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 0.86;
  text-transform: uppercase;
}

.auth-copy {
  max-width: 390px;
  margin: 24px 0 28px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.google-button {
  min-height: 44px;
}

.auth-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-message.error {
  color: #9c2f20;
}

.auth-footnote {
  margin: 50px 0 0;
  font-family: var(--utility);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: max(10px, env(safe-area-inset-top)) max(18px, calc((100vw - 900px) / 2)) 10px;
  border-bottom: 1px solid rgba(25, 33, 58, 0.12);
  background: rgba(255, 255, 255, 0.91);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-lockup p,
.brand-lockup span {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup p {
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.brand-lockup span {
  display: block;
  max-width: 180px;
  color: var(--muted);
  font-size: 0.67rem;
}

.mini-cassette {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 42px;
  height: 29px;
  padding: 6px;
  border: 2px solid var(--broadcast);
  border-radius: 4px;
  background: var(--checked-soft);
  transform: rotate(-3deg);
}

.mini-cassette i {
  width: 9px;
  height: 9px;
  border: 2px dotted var(--broadcast);
  border-radius: 50%;
}

.text-button,
.close-button {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--broadcast);
  font-size: 0.78rem;
  font-weight: 800;
}

.main-shell {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 20px 16px calc(50px + env(safe-area-inset-bottom));
}

.command-deck {
  display: grid;
  gap: 12px;
  margin-bottom: 28px;
}

.draw-card,
.add-card {
  position: relative;
  min-height: 128px;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  text-align: left;
}

.draw-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 22px;
  background: var(--broadcast);
  color: white;
  box-shadow: 0 9px 24px rgba(48, 79, 206, 0.24);
}

.draw-card::before,
.draw-card::after {
  position: absolute;
  left: 0;
  width: 100%;
  height: 8px;
  background: radial-gradient(circle, var(--paper) 2.5px, transparent 3px) 0 0 / 16px 8px repeat-x;
  content: "";
  opacity: 0.9;
}

.draw-card::before {
  top: 3px;
}

.draw-card::after {
  bottom: 3px;
}

.draw-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 3px;
}

.draw-copy small,
.draw-copy em,
.add-card small {
  font-style: normal;
}

.draw-copy small {
  font-family: var(--utility);
  font-size: 0.63rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.draw-copy strong {
  max-width: 210px;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.95;
  text-transform: uppercase;
}

.draw-copy em {
  margin-top: 6px;
  color: #dbe2ff;
  font-size: 0.71rem;
}

.draw-reels,
.large-reels {
  display: flex;
  gap: 10px;
}

.draw-reels i,
.large-reels i {
  display: block;
  border: 7px dotted currentColor;
  border-radius: 50%;
}

.draw-reels i {
  width: 42px;
  height: 42px;
  opacity: 0.88;
}

.add-card {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 86px;
  padding: 18px 20px;
  border: 2px solid var(--ink);
  background: var(--review);
  box-shadow: 5px 5px 0 var(--ink);
}

.add-card strong,
.add-card small {
  display: block;
}

.add-card strong {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 900;
  text-transform: uppercase;
}

.add-card small {
  margin-top: 2px;
  font-size: 0.72rem;
}

.add-glyph {
  display: grid;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  place-items: center;
  font-family: var(--utility);
  font-size: 1.7rem;
  line-height: 1;
}

.queue-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 30px var(--shadow);
}

.queue-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.queue-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.queue-title-row h2,
.sheet-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  text-transform: uppercase;
}

.result-summary {
  margin: 0 0 2px;
  color: var(--muted);
  font-family: var(--utility);
  font-size: 0.67rem;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  margin: 18px 0 12px;
}

.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 58px 0 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
  appearance: none;
}

.search-field input:focus {
  border-color: var(--broadcast);
  outline: 3px solid rgba(48, 79, 206, 0.16);
}

.search-icon {
  position: absolute;
  left: 16px;
  z-index: 1;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.search-icon::after {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
}

.search-field button {
  position: absolute;
  right: 8px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--broadcast);
  font-size: 0.7rem;
  font-weight: 800;
}

.queue-controls {
  display: grid;
  gap: 10px;
}

.filter-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.filter-switch button {
  min-height: 40px;
  padding: 5px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.filter-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
  box-shadow: 0 2px 8px rgba(25, 33, 58, 0.2);
}

.sort-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 4px 5px 4px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.sort-field span {
  color: var(--muted);
  font-family: var(--utility);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sort-field select {
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 750;
}

.sort-field select:focus {
  outline: 3px solid rgba(48, 79, 206, 0.16);
}

.show-list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  background: var(--line);
  list-style: none;
}

.show-card {
  position: relative;
  min-width: 0;
  background: var(--card);
}

.show-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 14px;
  background-color: var(--broadcast);
  background-image: radial-gradient(circle, white 2px, transparent 2.4px);
  background-position: center 4px;
  background-size: 8px 13px;
  content: "";
}

.show-card.needs-review::before {
  background-color: var(--review);
}

.show-card button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 92px;
  padding: 16px 17px 16px 30px;
  border: 0;
  background: transparent;
  text-align: left;
}

.show-card button:active,
.draw-card:active,
.add-card:active {
  transform: translateY(1px);
}

.show-copy {
  min-width: 0;
}

.show-status {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 5px 2px;
  border: 1px solid currentColor;
  color: var(--broadcast);
  font-family: var(--utility);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

.needs-review .show-status {
  color: #8a5500;
  background: var(--review-soft);
}

.show-title {
  display: block;
  overflow-wrap: anywhere;
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 850;
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.show-date {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--utility);
  font-size: 0.6rem;
}

.wantability-reel {
  align-self: center;
  display: grid;
  width: 48px;
  height: 48px;
  border: 5px dotted var(--broadcast);
  border-radius: 50%;
  background: var(--checked-soft);
  color: var(--ink);
  place-items: center;
  font-family: var(--utility);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.needs-review .wantability-reel {
  border-color: #b16d00;
  background: var(--review-soft);
}

.list-status {
  padding: 44px 24px;
  background: white;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.load-more {
  width: calc(100% - 32px);
  min-height: 48px;
  margin: 16px;
  border: 1px solid var(--broadcast);
  border-radius: 9px;
  background: white;
  color: var(--broadcast);
  font-weight: 800;
}

dialog {
  color: var(--ink);
}

.sheet-dialog,
.draw-dialog {
  width: min(calc(100% - 20px), 540px);
  max-height: min(88vh, 720px);
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--card);
  box-shadow: 0 -16px 50px rgba(25, 33, 58, 0.22);
}

dialog::backdrop {
  background: rgba(18, 24, 43, 0.58);
  backdrop-filter: blur(3px);
}

.sheet-grip {
  width: 42px;
  height: 5px;
  margin: 10px auto 2px;
  border-radius: 3px;
  background: var(--line);
}

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

.sheet-form {
  display: grid;
  gap: 17px;
  padding: 20px;
}

.sheet-form label:not(.check-row) {
  display: grid;
  gap: 7px;
}

.sheet-form label > span:first-child {
  font-size: 0.76rem;
  font-weight: 800;
}

.sheet-form input[type="text"],
.sheet-form input[type="number"] {
  width: 100%;
  min-height: 49px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
}

.sheet-form input:focus {
  border-color: var(--broadcast);
  outline: 3px solid rgba(48, 79, 206, 0.15);
}

.field-note,
.form-error {
  margin: -4px 0 0;
  font-size: 0.73rem;
  line-height: 1.45;
}

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

.form-error {
  padding: 10px;
  border-left: 4px solid var(--signal);
  background: #fff0ed;
  color: #8d2c20;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 400;
}

.check-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--broadcast);
}

.primary-button {
  min-height: 50px;
  padding: 11px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--broadcast);
  color: white;
  font-weight: 850;
  box-shadow: 0 5px 12px rgba(48, 79, 206, 0.22);
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px calc(22px + env(safe-area-inset-bottom));
}

.secondary-actions button,
.draw-actions button:not(.primary-button) {
  min-height: 46px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  font-size: 0.76rem;
  font-weight: 800;
}

.secondary-actions .danger-button {
  border-color: #e4a49a;
  color: #a23122;
}

.draw-dialog {
  min-height: 430px;
  padding: 30px 24px calc(24px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 8%, var(--review) 0 13%, transparent 13.3%),
    var(--broadcast);
  color: white;
  text-align: center;
}

.draw-dialog .eyebrow {
  color: #dce3ff;
}

.draw-close {
  position: absolute;
  top: 12px;
  right: 18px;
  color: white;
}

.large-reels {
  justify-content: center;
  margin: 50px 0 26px;
}

.large-reels i {
  width: 64px;
  height: 64px;
  color: #dce3ff;
}

.draw-dialog h2 {
  max-width: 430px;
  margin: 0 auto;
  font-family: var(--display);
  font-size: clamp(2.1rem, 10vw, 3.7rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.95;
  text-transform: uppercase;
}

.draw-dialog > p:not(.eyebrow) {
  margin: 16px 0 26px;
  color: #dce3ff;
  font-family: var(--utility);
  font-size: 0.72rem;
}

.draw-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.draw-actions .primary-button {
  background: var(--review);
  color: var(--ink);
  box-shadow: none;
}

.draw-actions button:not(.primary-button) {
  border-color: rgba(255, 255, 255, 0.48);
  background: transparent;
  color: white;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: 70;
  max-width: 480px;
  min-height: 48px;
  margin: auto;
  padding: 14px 16px;
  border-left: 6px solid var(--review);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: 0 12px 30px rgba(25, 33, 58, 0.28);
  font-size: 0.82rem;
}

.toast.error {
  border-left-color: var(--signal);
}

@media (min-width: 700px) {
  .main-shell {
    padding-top: 30px;
  }

  .command-deck {
    grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr);
  }

  .add-card {
    min-height: 128px;
  }

  .queue-header {
    padding: 24px;
  }

  .queue-controls {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 0.42fr);
  }

  .sheet-dialog,
  .draw-dialog {
    margin: auto;
    border-radius: 20px;
  }
}

@media (max-width: 370px) {
  .draw-reels {
    display: none;
  }

  .filter-switch button {
    font-size: 0.65rem;
  }

  .show-title {
    font-size: 1.06rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .app-view:not([hidden]) .command-deck,
  .app-view:not([hidden]) .queue-panel {
    animation: rise 420ms ease-out both;
  }

  .app-view:not([hidden]) .queue-panel {
    animation-delay: 80ms;
  }

  dialog[open] {
    animation: sheet-in 220ms ease-out both;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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