:root {
  color-scheme: dark;
  --ink: #fffaf5;
  --muted: #cbb9aa;
  --green: #c28a62;
  --green-dark: #855331;
  --green-soft: #3a2a20;
  --paper: #171310;
  --white: #261d17;
  --line: #49372b;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 64px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgb(23 19 16 / 94%);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  color: var(--green);
  background: #3a2a20;
  border-radius: 11px;
}

.brand-mark svg {
  width: 25px;
}

.brand-name {
  font-family: "Manrope", sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.8px;
}

.brand-name > span {
  color: var(--green);
}

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

.library {
  padding-top: 38px;
}

.first-visit-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  margin-bottom: 22px;
  background: #30241c;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 26px rgb(34 24 17 / 18%);
}

.first-visit-notice[hidden] {
  display: none;
}

.first-visit-copy {
  min-width: 0;
}

.first-visit-copy h2 {
  margin-bottom: 7px;
  font: 700 16px/1.35 "Manrope", sans-serif;
}

.first-visit-copy p {
  max-width: 72ch;
  margin: 0;
  color: #eadfd5;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.notice-dismiss {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 13px;
  color: var(--ink);
  background: #3a2a20;
  border: 1px solid #6b4d38;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.notice-dismiss:hover {
  border-color: var(--green);
  background: #493426;
}

.notice-dismiss:focus-visible {
  outline: 3px solid #f0c39a;
  outline-offset: 3px;
}

.library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 21px;
}

.section-kicker {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1.45px;
}

.library-heading h1 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.9px;
}

.library-count {
  padding-bottom: 3px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  height: 55px;
  align-items: center;
  gap: 13px;
  padding: 0 17px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
  border-color: var(--green);
  outline: 3px solid #f0c39a;
  outline-offset: 3px;
}

.search-box:focus-within input {
  outline: none;
}

.search-box > svg {
  width: 19px;
  flex: 0 0 auto;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  height: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.search-box input::placeholder {
  color: #d2c1b2;
}

.search-box kbd {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  color: #e6d9ce;
  background: #34271e;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 19px 0 21px;
}

.category-chip {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: #eadfd5;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.category-chip:hover {
  border-color: var(--green);
}

.category-chip.is-active {
  color: #171310;
  background: var(--green);
  border-color: var(--green);
}

.chip-count {
  color: var(--muted);
  font-size: 11px;
}

.category-chip.is-active .chip-count {
  color: #171310;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.utility-card {
  position: relative;
  display: flex;
  min-height: 181px;
  flex-direction: column;
  padding: 18px 18px 15px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgb(34 58 45 / 2%);
  transition: border-color 140ms ease;
}

.utility-card:hover {
  border-color: #8e6548;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.utility-icon {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  font-size: 18px;
  color: #f0d7b8;
  background: #493426;
}

.utility-card h2 {
  margin: 15px 0 5px;
  font-family: "Manrope", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.25px;
}

.utility-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.card-link {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: auto;
  min-height: 44px;
  color: var(--green);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.card-link:hover {
  color: #e5b68f;
}

.card-link:focus-visible,
.category-chip:focus-visible,
.reset-button:focus-visible,
.brand:focus-visible {
  outline: 3px solid #f0c39a;
  outline-offset: 3px;
}

.card-link svg {
  width: 13px;
}

.loading-card,
.error-state {
  display: flex;
  min-height: 130px;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 20px;
  color: var(--muted);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12px;
}

.empty-state {
  padding: 37px 20px 40px;
  text-align: center;
}

.empty-state h2,
.error-state h2 {
  margin: 0 0 6px;
  font-family: "Manrope", sans-serif;
  font-size: 15px;
}

.error-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.reset-button {
  min-height: 44px;
  margin-top: 15px;
  padding: 8px 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.reset-button:hover {
  color: #fffaf5;
  background: var(--green-dark);
}

.error-state {
  flex-direction: column;
  gap: 5px;
  padding: 24px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .page-shell {
    width: min(100% - 40px, 680px);
  }

  .utility-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: calc(100% - 32px);
  }

  .topbar {
    height: 70px;
  }

  .library-heading {
    align-items: flex-start;
  }

  .first-visit-notice {
    flex-direction: column;
    gap: 15px;
    padding: 17px;
  }

  .notice-dismiss {
    width: 100%;
  }

  .library-heading h1 {
    font-size: 24px;
  }

  .library-count {
    padding-top: 21px;
    white-space: nowrap;
    font-size: 11px;
  }

  .search-box {
    height: 51px;
    gap: 9px;
    padding: 0 12px;
  }

  .search-box input {
    font-size: 13px;
  }

  .category-list {
    gap: 7px;
    padding: 15px 0 18px;
  }

  .category-chip {
    min-height: 44px;
    gap: 7px;
    padding: 0 9px;
    font-size: 12px;
  }

  .utility-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .utility-card {
    min-height: 164px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
