/* Share Circle Useful Loop system — source: design output/share circle/tokens.css */
:root {
  --brand-signature: #315b73;
  --brand-companion: #df7638;
  --brand-signal: #e4c83d;
  --brand-support: #4b7972;
  --brand-ground: #e9e2d2;
  --color-background: #f7f3e9;
  --color-surface: #ffffff;
  --color-border: #d6d0c4;
  --color-text-muted: #667177;
  --color-text: #202c31;
  --color-focus: var(--brand-signal);
  --font-display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --font-body: "Atkinson Hyperlegible Next", system-ui, sans-serif;

  /* Compatibility aliases keep the existing interaction styles on the approved system. */
  --gray-0: var(--color-surface);
  --gray-50: var(--color-background);
  --gray-100: #eee9df;
  --gray-200: var(--color-border);
  --gray-400: #899197;
  --gray-600: var(--color-text-muted);
  --gray-800: var(--brand-signature);
  --gray-900: var(--color-text);
  --accent: var(--brand-companion);
  --accent-hover: #bf5f2e;
  --accent-contrast: var(--color-text);
  --status-available-bg: #e2eeeb;
  --status-available-fg: #315b55;
  --status-requested-bg: #f7e4d9;
  --status-requested-fg: #9c4d26;
  --status-reserved-bg: #e4edf1;
  --status-reserved-fg: var(--brand-signature);
  --status-checked_out-bg: #eee9df;
  --status-checked_out-fg: var(--color-text-muted);

  --radius-card: 16px;
  --radius-control: 8px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }
h1, h2, h3, .item-title, .section-title { font-family: var(--font-display); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Branded shell ===== */
.site-header {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 22px;
  display: flex;
  align-items: center;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; color: var(--color-text); text-decoration: none; }
.brand-lockup img { width: 48px; height: 48px; }
.brand-lockup strong { display: block; }
.brand-lockup strong { font-size: 1.05rem; }
.bottom-nav { display: none; }

/* ===== Buttons — only ONE filled/accent style exists, used once per screen ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-control);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 44px; /* touch target */
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 800;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: var(--gray-200);
  color: var(--gray-800);
}
.btn-ghost:hover { background: var(--gray-100); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== Right-edge quick action tabs ===== */
.edge-actions {
  position: fixed;
  right: 0;
  top: var(--space-5);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: 62px;
}
.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 16px 0 0 16px;
  color: var(--gray-900);
  cursor: pointer;
  box-shadow: -4px 5px 0 rgba(54, 79, 107, 0.18);
  transform-origin: right center;
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}
.nav-link img { width: 32px; height: 32px; object-fit: contain; }
.edge-tab-add { background: var(--brand-companion); }
.edge-tab-profile { background: var(--brand-support); color: #fff; }
.edge-tab-search { background: var(--brand-signature); color: #fff; }
.nav-link:hover {
  filter: saturate(1.1);
  box-shadow: -7px 7px 0 rgba(54, 79, 107, 0.16);
  transform: translateX(-8px) scale(1.03);
}
.nav-link:active { transform: translateX(-3px) scale(0.97); }
.nav-link:focus-visible { outline: 3px solid var(--gray-900); outline-offset: -5px; }
.nav-link.open { transform: translateX(-8px); }

main#app { max-width: 1200px; margin: 0 auto; padding: var(--space-5) var(--space-4); }

.search-popover {
  position: fixed;
  top: var(--space-5);
  right: 72px;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: min(520px, calc(100vw - 96px));
  padding: var(--space-2);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-control);
  background: var(--gray-0);
  box-shadow: 0 12px 28px rgba(54, 79, 107, 0.16);
}
.search-popover input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--gray-900);
}
.search-popover input:focus-visible,
.search-close:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gray-600);
  font-size: 1.4rem;
  cursor: pointer;
}
.search-close img { width: 24px; height: 24px; object-fit: contain; }
.search-close:hover { background: var(--gray-100); color: var(--gray-900); }

/* ===== Marketplace grid (layout-grid skill) ===== */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.empty-state {
  padding: var(--space-6);
  text-align: center;
  color: var(--gray-600);
}

/* ===== Item card (component-spec: ItemCard) ===== */
.item-card {
  background: var(--gray-0);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.item-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.08); transform: translateY(-2px); }
.item-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-request {
  position: relative;
  width: auto;
  min-width: 160px;
  align-self: center;
  margin: var(--space-2) auto 0;
  padding: 8px 0 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  outline-offset: 5px;
  touch-action: manipulation;
  user-select: none;
  overflow: visible;
  transition: filter 250ms;
}
.card-request-shadow,
.card-request-edge {
  position: absolute;
  inset: 8px 0 0;
  border-radius: 12px;
}
.card-request-shadow {
  background: rgba(0, 0, 0, 0.22);
  transform: translateY(3px);
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}
.card-request-edge { background: linear-gradient(to left, #a94e25 0%, #c96630 8%, #c96630 92%, #a94e25 100%); }
.card-request-front {
  position: relative;
  display: block;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--brand-companion);
  color: var(--accent-contrast);
  font-weight: 700;
  transform: translateY(-5px);
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.4, 1);
}
.card-request:hover { filter: brightness(1.06); }
.card-request:hover .card-request-front {
  transform: translateY(-7px);
  transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}
.card-request:hover .card-request-shadow {
  transform: translateY(5px);
  transition: transform 250ms cubic-bezier(0.3, 0.7, 0.4, 1.5);
}
.card-request:active .card-request-front { transform: translateY(-1px); transition-duration: 34ms; }
.card-request:active .card-request-shadow { transform: translateY(1px); transition-duration: 34ms; }
.card-request:focus-visible { outline: 3px solid var(--gray-800); }

.item-photo {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: var(--brand-ground);
}
.item-photo img { width: 100%; height: 100%; object-fit: cover; }
.item-photo img.asset-photo { object-fit: contain; padding: 10px; }
.item-photo.dimmed { filter: grayscale(0.6) opacity(0.7); }

.item-body { padding: var(--space-3) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.item-title { font-weight: 700; font-size: 1rem; }

.status-pill {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.status-pill.available { background: var(--status-available-bg); color: var(--status-available-fg); }
.status-pill.requested { background: var(--status-requested-bg); color: var(--status-requested-fg); }
.status-pill.reserved { background: var(--status-reserved-bg); color: var(--status-reserved-fg); }
.status-pill.checked_out { background: var(--status-checked_out-bg); color: var(--status-checked_out-fg); }

/* ===== Family badge — the one identity signature that repeats everywhere ===== */
.family-avatar {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--avatar-color);
  border-radius: 50%;
  background: var(--gray-0);
  color: var(--gray-800);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--gray-0);
}
.family-avatar.large {
  width: 64px;
  height: 64px;
  font-size: 0.9rem;
  border-width: 4px;
}
.family-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--gray-800); }
.family-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--gray-0);
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 20, 24, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-5) var(--space-4);
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--gray-0);
  border-radius: var(--radius-card);
  max-width: 560px;
  max-height: calc(100dvh - 48px);
  width: 100%;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.modal-close { background: none; border: none; line-height: 1; cursor: pointer; color: var(--gray-400); padding: 4px; width: 44px; height: 44px; }
.modal-close img { width: 24px; height: 24px; object-fit: contain; }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Contextual panels: right drawer on desktop, bottom sheet on mobile. */
body.panel-open,
body.modal-open { overflow: hidden; }
.panel-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(20, 20, 24, 0.45);
  z-index: 40;
}
.side-panel {
  width: min(480px, 100vw);
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--gray-0);
  box-shadow: -12px 0 32px rgba(20, 20, 24, 0.14);
  padding: var(--space-5);
}
.panel-header {
  position: sticky;
  top: calc(var(--space-5) * -1);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) 0 var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--gray-0);
  border-bottom: 1px solid var(--gray-100);
}
.panel-header h2 { font-size: 1.2rem; }
.panel-close {
  width: 44px;
  height: 44px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gray-600);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { background: var(--gray-100); color: var(--gray-900); }
.panel-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel-close img { width: 24px; height: 24px; object-fit: contain; }
.side-panel .section-card { max-width: none; padding: 0; border: 0; background: transparent; }

/* ===== Month calendar ===== */
.month-calendar { display: flex; flex-direction: column; gap: var(--space-2); }
.calendar-header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: var(--space-2); }
.calendar-header h3 { text-align: center; font-size: 1rem; }
.calendar-nav {
  width: 44px;
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: 50%;
  background: var(--gray-0);
  color: var(--gray-800);
  cursor: pointer;
}
.calendar-nav img { width: 26px; height: 26px; object-fit: contain; }
.calendar-nav:disabled { opacity: 0.3; cursor: default; }
.calendar-nav:focus-visible,
.calendar-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.calendar-weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.calendar-weekdays span {
  color: var(--gray-600);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}
.calendar-day {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-0);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  gap: 3px;
  font-size: 0.82rem;
  color: var(--gray-800);
}
.calendar-day.outside { border-color: transparent; background: transparent; }
.calendar-day:disabled { color: var(--gray-400); cursor: default; opacity: 0.55; }
.calendar-day.reserved { background: var(--gray-100); opacity: 1; }
.calendar-day.reserved .family-dot { width: 7px; height: 7px; }
.calendar-day.selected { border-color: var(--accent); background: var(--status-available-bg); }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--gray-800); font-weight: 800; }

/* ===== Forms (form-design) ===== */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 0.88rem; }
.field .hint { font-weight: 400; color: var(--gray-400); font-size: 0.78rem; }
.field input[type="text"],
.field input[type="file"],
.field textarea {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--gray-200);
  background: var(--gray-0);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 72px; }
.form-actions { display: flex; gap: var(--space-3); }
.section-card {
  background: var(--gray-0);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  max-width: 560px;
}

.confirm-banner {
  background: var(--status-available-bg);
  color: var(--status-available-fg);
  border-radius: var(--radius-control);
  padding: var(--space-4);
  font-weight: 600;
}

/* ===== Profile ===== */
.profile-header { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.profile-calendar { margin-bottom: var(--space-4); }
.profile-calendar .calendar-day.has-activity {
  border-color: var(--accent);
  background: var(--status-available-bg);
  font-weight: 700;
}
.activity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-hover); }
.profile-day-detail {
  min-height: 72px;
  padding: var(--space-3);
  border-radius: var(--radius-control);
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 0.86rem;
}
.profile-day-detail h2 { margin-bottom: var(--space-2); color: var(--gray-800); font-size: 0.92rem; }
.profile-activity { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; border-top: 1px solid var(--gray-200); }
.profile-activity strong { color: var(--gray-900); }
h2.section-title { font-size: 1rem; color: var(--gray-600); margin: var(--space-5) 0 var(--space-3); text-transform: uppercase; letter-spacing: 0.04em; }
.request-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  background: var(--gray-0); border: 1px solid var(--gray-200); border-radius: var(--radius-control);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.owned-list { display: flex; flex-direction: column; gap: var(--space-2); }
.owned-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: var(--space-2) 0; border-bottom: 1px solid var(--gray-100);
  border-top: 0; border-left: 0; border-right: 0;
  background: transparent;
  color: var(--gray-900);
  text-align: left;
  cursor: pointer;
}
.owned-row:hover { color: var(--accent-hover); }
.owned-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Responsive (responsive-design skill) ===== */
@media (max-width: 640px) {
  .site-header { padding: 18px 14px 14px; }
  main#app { padding: var(--space-4) var(--space-3); }
  .edge-actions { display: none; }
  .search-popover { top: auto; right: var(--space-3); bottom: 84px; left: var(--space-3); width: auto; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
  .modal { max-height: calc(100dvh - 24px); padding: var(--space-4); }
  .modal-backdrop { padding: var(--space-3); }
  .panel-backdrop { align-items: flex-end; }
  .side-panel {
    width: 100%;
    height: auto;
    max-height: 92dvh;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    padding: var(--space-4) var(--space-3) 0;
  }
  .side-panel::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--gray-200);
  }
  .panel-header {
    top: calc(var(--space-4) * -1);
    padding: var(--space-3) 0 var(--space-3);
    margin-bottom: var(--space-4);
  }
  .panel-content { padding-bottom: var(--space-5); }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 140px; }
  .bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; padding: 0 12px max(0px, env(safe-area-inset-bottom)); pointer-events: none; }
  .bottom-nav .nav-button { min-height: 68px; padding: 10px 8px 12px; display: grid; place-items: center; border: 0; border-radius: 22px 22px 0 0; color: #fff; background: var(--tab-color); box-shadow: 6px 6px 0 rgba(32, 44, 49, .18); font-size: 0; pointer-events: auto; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease; }
  .bottom-nav .nav-button img { width: 38px; height: 38px; object-fit: contain; }
  .bottom-nav .tab-search { --tab-color: var(--brand-signature); }
  .bottom-nav .tab-add { --tab-color: var(--brand-companion); color: var(--color-text); }
  .bottom-nav .tab-profile { --tab-color: var(--brand-support); }
  .bottom-nav .nav-button:hover { transform: translateY(-5px); box-shadow: 8px 8px 0 rgba(32, 44, 49, .16); }
  .bottom-nav .nav-button:active, .bottom-nav .nav-button.open { transform: translateY(3px); box-shadow: 4px 4px 0 rgba(32, 44, 49, .2); }
  .bottom-nav .nav-button:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
}

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