/* ============ Reset-ish ============ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}
body {
  min-height: 100svh;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--c-text);
  background-color: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
img,
svg {
  display: block;
  max-width: 100%;
}
h1,
h2,
h3 {
  font-family: var(--font-head);
  line-height: 1.15;
}
h1 {
  font-size: var(--step-3);
}
h2 {
  font-size: var(--step-1);
}
a {
  color: var(--c-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid var(--c-link);
  outline-offset: 2px;
  border-radius: 6px;
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  background: var(--c-white);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-m);
  transition: top 0.2s;
}
.skip-link:focus {
  top: 1rem;
}
.muted {
  color: var(--c-text-soft);
}
.center {
  text-align: center;
}
.link {
  color: var(--c-link);
  font-weight: 600;
  font-size: var(--step--1);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1;
  padding: 0.75em 1.2em;
  min-height: 44px;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.btn--primary {
  background-color: var(--c-red-dark);
  color: var(--c-white);
}
.btn--primary:hover {
  background-color: var(--c-red-darker);
  color: var(--c-white);
}
.btn--secondary {
  border-color: var(--c-red-dark);
  color: var(--c-red-dark);
  background: transparent;
}
.btn--secondary:hover {
  background-color: var(--c-red-dark);
  color: var(--c-white);
}
.btn--ghost {
  border-color: var(--c-border);
  color: var(--c-text);
  background: var(--c-white);
}
.btn--ghost:hover {
  background: var(--c-panel);
  color: var(--c-text);
}
.btn--small {
  min-height: 38px;
  padding: 0.5em 1em;
  font-size: var(--step--1);
}
.btn--large {
  font-size: var(--step-1);
  padding: 0.9em 1.5em;
}
.btn--block {
  width: 100%;
}

/* ============ Forms ============ */
.field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 1rem;
}
.field label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--step--1);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.7em 0.9em;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  background-color: var(--c-white);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--c-link);
}
.field--check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.field--check input {
  width: auto;
}
.hint {
  font-size: var(--step--1);
  color: var(--c-text-soft);
  margin-top: 0.25rem;
}

/* ============ Flash ============ */
.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin-bottom: 1rem;
}
.flash--success {
  background: var(--c-green-soft);
  color: var(--c-green);
}
.flash--error {
  background: var(--c-amber-soft);
  color: var(--c-red-dark);
}
.flash--info {
  background: var(--c-panel);
  color: var(--c-text);
}

/* ============ Status pills ============ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--step--1);
  padding: 0.3em 0.8em;
  border-radius: var(--radius-pill);
}
.status::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background-color: currentColor;
}
.status--available {
  background: var(--c-green-soft);
  color: var(--c-green);
}
.status--borrowed {
  background: var(--c-amber-soft);
  color: var(--c-amber);
}
.badge {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--step--1);
  padding: 0.2em 0.6em;
  border-radius: var(--radius-pill);
}
.badge--ok {
  background: var(--c-green-soft);
  color: var(--c-green);
}
.badge--muted {
  background: var(--c-panel);
  color: var(--c-text-soft);
}

/* ============ App shell ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(251, 243, 222, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
}
.app-header__inner {
  width: min(100% - 2rem, 1080px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  gap: 1rem;
}
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: var(--step-1);
  color: var(--c-text);
}
.app-brand:hover {
  text-decoration: none;
}
.app-brand__mark {
  display: inline-flex;
}
.app-brand__mark img {
  width: 26px;
  height: 26px;
  display: block;
}
.app-nav-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.app-nav-group {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.app-nav-group--account {
  gap: 1rem;
}
.app-nav-divider {
  width: 1px;
  height: 20px;
  background: var(--c-border);
  flex: none;
}
.app-nav-top__link {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--c-text);
  font-size: var(--step-0);
}
.app-nav-top__link:hover {
  color: var(--c-red-dark);
  text-decoration: none;
}
.app-nav-top__link.is-active {
  color: var(--c-red-dark);
}
.app-logout {
  margin: 0;
}
.app-logout__btn {
  background: none;
  border: none;
  color: var(--c-text-soft);
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
}
.app-logout__btn:hover {
  color: var(--c-red-dark);
}

.app-main {
  width: min(100% - 2rem, 1080px);
  margin-inline: auto;
  padding-block: 1.5rem 2rem;
}

/* Bottom nav (mobile) */
.app-nav-bottom {
  display: none;
}
@media (max-width: 800px) {
  .app-nav-top {
    display: none;
  }
  .app-nav-bottom {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    background: rgba(251, 243, 222, 0.97);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--c-border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-nav-bottom__link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0.25rem;
    color: var(--c-text-soft);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 0.7rem;
  }
  .app-nav-bottom__link:hover {
    text-decoration: none;
  }
  .app-nav-bottom__link svg {
    width: 24px;
    height: 24px;
  }
  .app-nav-bottom__link.is-active {
    color: var(--c-red-dark);
  }
  body.app {
    padding-bottom: 72px;
  }
}

/* ============ Page bits ============ */
.page-head {
  margin-bottom: 1.5rem;
}
.page-head h1 {
  margin-bottom: 0.2rem;
}
.panel {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: clamp(1rem, 3vw, 1.75rem);
  box-shadow: var(--shadow-s);
  margin-bottom: 1.5rem;
}
.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.empty {
  color: var(--c-text-soft);
  padding: 0.5rem 0;
}
.back-link {
  margin-bottom: 1rem;
}

/* ============ Dashboard ============ */
.loan-list,
.res-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.loan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--c-bg);
  border-radius: var(--radius);
}
.loan-item__name {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--c-text);
}
.loan-item__due {
  font-size: var(--step--1);
  color: var(--c-text-soft);
}
.loan-item__due.is-overdue {
  color: var(--c-red-dark);
  font-weight: 700;
}
.res-list__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.res-chip {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--step--1);
  padding: 0.2em 0.7em;
  border-radius: var(--radius-pill);
  color: var(--c-white);
}
.res-chip--ponk {
  background: var(--c-green);
}
.res-chip--workshop {
  background: var(--c-red-dark);
}

/* ============ Filters / chips ============ */
.filters {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--step--1);
  padding: 0.4em 0.9em;
  border-radius: var(--radius-pill);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  color: var(--c-text);
}
.chip:hover {
  text-decoration: none;
  border-color: var(--c-red-dark);
}
.chip.is-active {
  background: var(--c-red-dark);
  color: var(--c-white);
  border-color: var(--c-red-dark);
}
.chip--ghost.is-active {
  background: var(--c-text);
  border-color: var(--c-text);
}

/* ============ Inventory grid ============ */
.inv-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}
.inv-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s;
}
.inv-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-m);
}
.inv-card--big {
  border-color: var(--c-red);
  border-width: 2px;
}
/* Media (photo or placeholder) — also the link to detail */
.inv-card__media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--c-bg-deep);
  overflow: hidden;
}
.inv-card__media:hover {
  text-decoration: none;
}
.inv-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.inv-card__ph {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--c-border);
}
.inv-card__ph svg {
  width: 38%;
  max-width: 64px;
  height: auto;
}
.inv-card__top {
  position: absolute;
  inset: 0.5rem 0.5rem auto 0.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  pointer-events: none;
}
.inv-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1rem 1rem;
  flex: 1;
}
.inv-card__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: var(--step-1);
  line-height: 1.15;
  color: var(--c-text);
}
.inv-card__name:hover {
  color: var(--c-red-dark);
  text-decoration: none;
}
.inv-card__add {
  margin-top: auto;
}
.cat-tag {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.9);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-s);
}
.big-flag {
  color: var(--c-red);
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.9);
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-s);
}

/* ============ Detail ============ */
.detail__head {
  margin-bottom: 1rem;
  display: grid;
  gap: 0.5rem;
}
.detail__head h1 {
  margin: 0;
}
.detail__desc {
  font-size: var(--step-1);
  margin-bottom: 1rem;
}
.detail__meta {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 0.5rem;
}
.detail__meta li {
  padding: 0.6rem 0.9rem;
  background: var(--c-panel);
  border-radius: var(--radius);
}
.detail__actions {
  max-width: 420px;
}

/* ============ Calendar ============ */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}
.cal-day {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  min-height: 110px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.cal-day.is-today {
  border-color: var(--c-red);
  box-shadow: inset 0 0 0 1px var(--c-red);
}
.cal-day__head {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.cal-day__dow {
  font-family: var(--font-head);
  font-weight: 700;
}
.cal-day__date {
  font-size: 0.72rem;
  color: var(--c-text-soft);
}
.cal-free {
  font-size: 0.72rem;
  color: var(--c-green);
  font-weight: 700;
}
.cal-block {
  position: relative;
  font-size: 0.72rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  color: var(--c-white);
  display: grid;
  gap: 1px;
}
.cal-block--ponk {
  background: var(--c-green);
}
.cal-block--workshop {
  background: var(--c-red-dark);
}
.cal-block__time {
  font-weight: 700;
}
.cal-block__who {
  opacity: 0.95;
}
.cal-block__note {
  opacity: 0.85;
  font-style: italic;
}
.cal-block__cancel {
  position: absolute;
  top: 2px;
  right: 2px;
}
.cal-block__cancel button {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: var(--c-white);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  font-size: 0.7rem;
}
@media (max-width: 720px) {
  .cal-week {
    grid-template-columns: 1fr;
  }
  .cal-day {
    min-height: auto;
    flex-direction: row;
    align-items: flex-start;
  }
  .cal-day__head {
    flex-direction: row;
    gap: 0.4rem;
    min-width: 90px;
  }
  .cal-day__body {
    flex: 1;
    display: grid;
    gap: 0.3rem;
  }
}
.res-form {
  max-width: 520px;
}

/* ============ Board ============ */
.board-form textarea {
  width: 100%;
  padding: 0.7em 0.9em;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  resize: vertical;
  margin-bottom: 0.5rem;
}
.board-form textarea:focus {
  outline: none;
  border-color: var(--c-link);
}
.board-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.board-photo {
  cursor: pointer;
  font-weight: 600;
  color: var(--c-text-soft);
}
.board-photo input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.board-form__status {
  font-size: var(--step--1);
  color: var(--c-text-soft);
  margin-top: 0.4rem;
}
.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
}
.post {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-s);
}
.post__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.post__author {
  font-family: var(--font-head);
  font-weight: 700;
}
.post__time {
  font-size: 0.72rem;
  color: var(--c-text-soft);
}
.post__photo {
  display: block;
  margin-top: 0.6rem;
}
.post__photo img {
  border-radius: var(--radius);
  max-height: 360px;
  width: auto;
}

/* ============ Tables / admin ============ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-0);
}
.table th,
.table td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.table th {
  font-family: var(--font-head);
  font-size: var(--step--1);
  color: var(--c-text-soft);
}
.adder {
  margin-bottom: 1.25rem;
}
.adder > summary {
  display: inline-flex;
  list-style: none;
  margin-bottom: 0.75rem;
}
.adder > summary::-webkit-details-marker {
  display: none;
}
.admin-form {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.5rem 0 1rem;
}
.admin-form--row {
  background: var(--c-panel);
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.75rem;
}
.row-edit summary {
  cursor: pointer;
}

/* ============ Auth (login) ============ */
body.is-bare {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--c-bg);
}
.bare-main {
  width: 100%;
  max-width: 420px;
}
.auth-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  box-shadow: var(--shadow-m);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: var(--step-1);
  color: var(--c-text);
  margin-bottom: 1rem;
}
.auth-brand:hover {
  text-decoration: none;
}
.auth-brand__mark {
  display: inline-flex;
}
.auth-brand__mark img {
  width: 34px;
  height: 34px;
  display: block;
}
.auth-title {
  font-size: var(--step-2);
  margin-bottom: 0.4rem;
}
.auth-sub {
  color: var(--c-text-soft);
  margin-bottom: 1.5rem;
}
.auth-foot {
  margin-top: 1.25rem;
  font-size: var(--step--1);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ===== Inventory cell (card + add-to-cart) ===== */
.inv-cell { display: block; }

/* ===== Cart ===== */
.cart-list { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: .5rem; }
.cart-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-white); }
.cart-item.is-unavailable { opacity: .7; }
.cart-item__name { font-weight: 700; }
.cart-item__meta { display: block; font-size: .85rem; color: var(--c-text-soft); }
.cart-item__warn { color: var(--c-red-dark); }
.cart-checkout { border-top: 1px solid var(--c-border); padding-top: 1rem; }

/* ===== Nav badge ===== */
.nav-badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem;
  padding: 0 .35rem; margin-left: .35rem; border-radius: 999px; background: var(--c-red-dark);
  color: #fff; font-size: .72rem; font-weight: 700; line-height: 1; }
.app-nav-bottom .nav-badge { position: absolute; top: 4px; right: 50%; transform: translateX(120%); margin: 0; }
.app-nav-bottom__link { position: relative; }

/* ===== Order group (dashboard) ===== */
.order-group { border: 1px solid var(--c-border); border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .75rem; }
.order-group__return { margin-top: .5rem; text-align: right; }

/* ===== Item availability calendar ===== */
.item-cal { margin-top: 1.5rem; }
.item-cal__busy { color: var(--c-red-dark); font-weight: 700; font-size: .85rem; }
.item-cal__past { color: var(--c-text-soft); font-size: .8rem; }

/* ===== Language switch (member app) ===== */
.lang-switch { display: inline-flex; align-items: center; gap: .15rem; border-radius: var(--radius-pill); }
.lang-switch__item { display: inline-flex; align-items: center; justify-content: center; min-width: 2.1em;
  padding: .25em .5em; font-family: var(--font-head); font-weight: 700; font-size: .8rem; line-height: 1;
  border-radius: var(--radius-pill); text-decoration: none; color: var(--c-text-soft);
  transition: color .15s ease, background-color .15s ease; }
.lang-switch__item:hover { color: var(--c-red-dark); }
.lang-switch__item.is-active { color: #fff; background-color: var(--c-red-dark); }
.lang-switch--bottom { display: none; }
@media (max-width: 720px) {
  .app-nav-top .lang-switch { display: none; }
  .lang-switch--bottom { display: inline-flex; flex-direction: column; gap: .1rem; align-self: center; }
  .lang-switch--bottom .lang-switch__item { min-width: 0; padding: .15em .4em; font-size: .7rem; }
}
