:root {
  color-scheme: light;
  --bg: #edf1f5;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --ink: #181c22;
  --muted: #64707d;
  --line: #d4dbe4;
  --accent: #d74f2a;
  --accent-dark: #a9361d;
  --mint: #1f9d83;
  --blue: #316bcf;
  --gold: #d49b25;
  --shadow: 0 18px 60px rgba(29, 38, 50, .14);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(29, 38, 50, .045) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(29, 38, 50, .04) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .74;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgba(29, 38, 50, .12);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  color: var(--muted);
  font-size: .78rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button,
.primary-button,
.icon-button,
.segmented button,
.user-menu-button,
.user-menu-list button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
}

.ghost-button,
.primary-button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 0 rgba(29, 38, 50, .18);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  font-weight: 900;
}

.icon-button.danger {
  color: #9d2018;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 5px 10px 5px 6px;
  font-weight: 800;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--mint);
  color: #fff;
}

.user-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: none;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.user-menu-button[aria-expanded="true"] + .user-menu-list,
.user-menu:hover .user-menu-list,
.user-menu:focus-within .user-menu-list {
  display: grid;
  gap: 6px;
}

.user-menu-list button {
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.auth-view,
.dashboard {
  padding: clamp(22px, 5vw, 52px);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: clamp(24px, 5vw, 58px);
  align-items: center;
  max-width: 1160px;
  min-height: calc(100vh - 180px);
  margin: 0 auto;
}

.auth-copy {
  max-width: 730px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 920px;
  margin-bottom: 16px;
  font-size: clamp(2.3rem, 6vw, 5.4rem);
  line-height: .95;
  letter-spacing: 0;
}

.auth-copy p:not(.eyebrow) {
  max-width: 630px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.55;
}

.auth-card,
.add-panel,
.collection-panel,
.settings-dialog form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(29, 38, 50, .05);
}

.segmented button {
  min-height: 38px;
  font-weight: 900;
}

.segmented button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 76px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 107, 207, .16);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--mint);
  font-size: .88rem;
  font-weight: 800;
}

.form-message.error {
  color: #a62b22;
}

.dashboard {
  max-width: 1500px;
  margin: 0 auto;
}

.dashboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}

.dashboard-head h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 5vw, 4.2rem);
}

.head-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 10px;
}

.head-metrics div {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
}

.head-metrics span {
  display: block;
  font-size: 1.3rem;
  font-weight: 950;
}

.head-metrics small {
  color: var(--muted);
  font-weight: 800;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.add-panel {
  position: sticky;
  top: 92px;
  padding: 18px;
}

.add-panel form {
  display: grid;
  gap: 14px;
}

.form-head h2,
.dialog-head h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.form-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.file-input input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-input span {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 11px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.collection-panel {
  min-height: 620px;
  padding: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 170px 150px;
  gap: 10px;
  margin-bottom: 14px;
}

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

.item-card {
  display: grid;
  grid-template-rows: 186px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 24px rgba(29, 38, 50, .08);
}

.item-image {
  min-height: 0;
  background: #e2e8f0;
}

.item-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 186px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #fff;
}

.placeholder span {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, .82);
  border-radius: 8px;
  font-weight: 950;
}

.placeholder small {
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.placeholder-game {
  background: linear-gradient(135deg, #2f6f9f, #d74f2a);
}

.placeholder-card {
  background: linear-gradient(135deg, #7f3f98, #d49b25);
}

.placeholder-console {
  background: linear-gradient(135deg, #263238, #1f9d83);
}

.placeholder-accessory {
  background: linear-gradient(135deg, #8b3f2f, #316bcf);
}

.placeholder-other {
  background: linear-gradient(135deg, #5b6068, #c05d35);
}

.item-body {
  display: grid;
  gap: 11px;
  padding: 13px;
}

.item-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.item-title-row h3 {
  margin: 6px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(31, 157, 131, .14);
  color: #126b5a;
  font-size: .72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.item-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.item-card input,
.item-card textarea {
  background: #fbfcfe;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.settings-dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(24, 28, 34, .46);
}

.settings-dialog form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row input {
  width: 20px;
  height: 20px;
}

menu {
  display: flex;
  justify-content: end;
  margin: 0;
  padding: 0;
}

.compact-view .item-card {
  grid-template-columns: 106px 1fr;
  grid-template-rows: auto;
}

.compact-view .item-image,
.compact-view .placeholder {
  min-height: 100%;
  height: 100%;
}

.compact-view .item-fields,
.compact-view .wide-field {
  display: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .auth-panel,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    min-height: auto;
  }

  .add-panel {
    position: static;
  }

  .dashboard-head {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 64px;
  }

  .brand small,
  .ghost-button {
    display: none;
  }

  .auth-view,
  .dashboard {
    padding: 18px 12px 28px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .head-metrics,
  .toolbar,
  .field-row,
  .item-fields {
    grid-template-columns: 1fr;
  }

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