* {
  box-sizing: border-box;
}

html {
  background: var(--color-page);
  color: var(--color-ink);
  font-family: var(--font-family);
  line-height: 1.8;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(40, 95, 214, 0.32);
  outline-offset: 2px;
}

.site-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-4);
  height: var(--header-height);
  justify-content: space-between;
  padding: 0 var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  color: white;
  display: inline-flex;
  flex: 0 0 40px;
  font-size: 1.35rem;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

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

.brand small {
  color: var(--color-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.top-nav {
  display: none;
}

.auth-entry {
  background: var(--color-primary);
  border: 0;
  border-radius: var(--radius-md);
  color: white;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 800;
  min-height: 38px;
  padding: 0.4rem 0.7rem;
}

.page-shell {
  margin: 0 auto;
  max-width: var(--container);
  padding: var(--space-4);
}

.search-panel,
.page-title {
  background: linear-gradient(135deg, var(--color-primary-soft), #ffffff);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: grid;
  gap: var(--space-5);
  padding: var(--space-5);
}

body:not([data-page="home"]) .page-title {
  display: none;
}

.eyebrow {
  color: var(--color-primary);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 var(--space-2);
}

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

h1 {
  font-size: 1.55rem;
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

h2 {
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

.lead {
  color: var(--color-muted);
  margin-bottom: 0;
}

.search-form {
  display: grid;
  gap: var(--space-2);
}

.search-form label {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.search-row {
  display: grid;
  gap: var(--space-2);
}

.search-row input,
.filter-bar input,
.filter-bar select {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-ink);
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  width: 100%;
}

.filter-search {
  align-items: stretch;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  min-width: 0;
  overflow: hidden;
}

.filter-search:focus-within {
  outline: 3px solid rgba(40, 95, 214, 0.16);
  outline-offset: 2px;
}

.filter-search input {
  border: 0;
  border-radius: 0;
  min-width: 0;
}

.filter-search input:focus {
  outline: 0;
}

.search-row button {
  background: var(--color-primary);
  border: 0;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 700;
  min-height: 46px;
  padding: 0.65rem 1rem;
}

.filter-bar button {
  background: var(--color-primary);
  border: 0;
  border-radius: 0;
  color: white;
  font-weight: 800;
  min-height: 46px;
  padding: 0.65rem 1.05rem;
  white-space: nowrap;
}

.quick-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  margin-top: var(--space-4);
}

.quick-card,
.item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.quick-card {
  display: grid;
  gap: var(--space-1);
  min-height: 112px;
  padding: var(--space-4);
}

.quick-card span,
.item-card .meta {
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 700;
}

.quick-card strong {
  font-size: 1.05rem;
}

.quick-card small,
.item-card p {
  color: var(--color-muted);
}

.primary-card {
  background: var(--color-primary);
  color: white;
}

.primary-card span,
.primary-card small {
  color: rgba(255, 255, 255, 0.82);
}

.content-layout {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.section-heading {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading a {
  color: var(--color-primary);
  font-size: 0.86rem;
  font-weight: 700;
}

.item-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.item-list:empty::before {
  color: var(--color-muted);
  content: "در حال آماده‌سازی اطلاعات...";
  display: block;
  padding: var(--space-4);
}

.list-status {
  color: var(--color-muted);
  font-size: 0.86rem;
  min-height: 2rem;
  padding: var(--space-3) 0;
  text-align: center;
}

.list-sentinel {
  height: 1px;
}

.item-card {
  color: inherit;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
}

.item-card.has-media {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 76px;
}

.item-content {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.item-title {
  color: var(--color-ink);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.7;
}

.item-summary {
  color: var(--color-muted);
  font-size: 0.84rem;
  line-height: 1.75;
}

.item-image {
  aspect-ratio: 1;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: block;
  height: 76px;
  object-fit: cover;
  width: 76px;
}

[data-list="more"] .item-card.has-media {
  grid-template-columns: minmax(0, 1fr) 56px;
}

[data-list="more"] .item-image {
  border-radius: 14px;
  height: 56px;
  object-fit: contain;
  width: 56px;
}

.detail-view {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
}

.detail-view p {
  margin-bottom: 0;
}

.detail-body {
  line-height: 1.9;
  white-space: pre-line;
}

.detail-fields {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: grid;
  gap: var(--space-2);
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  margin: 0;
  padding: var(--space-3);
}

.detail-fields dt {
  color: var(--color-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.detail-fields dd {
  margin: 0;
}

.detail-field-link {
  color: var(--color-primary);
  direction: ltr;
  display: inline-block;
  font-weight: 900;
  text-decoration: none;
}

.detail-field-link:hover {
  text-decoration: underline;
}

.detail-image {
  aspect-ratio: 16 / 7;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: block;
  object-fit: cover;
  width: 100%;
}

.back-link {
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 800;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  align-items: center;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-muted);
  display: inline-flex;
  font-size: 0.68rem;
  justify-content: center;
  line-height: 1;
  min-height: 1.45rem;
  padding: 0 0.55rem;
  text-align: center;
  white-space: nowrap;
}

.filter-bar {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.bottom-nav {
  align-items: stretch;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--color-border);
  bottom: 0;
  box-shadow: 0 -8px 24px rgba(21, 42, 38, 0.08);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: var(--bottom-nav-height);
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  left: 0;
  z-index: 30;
}

.bottom-nav > a,
.bottom-nav > span {
  align-items: center;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  display: flex;
  font-size: 0.82rem;
  font-weight: 700;
  justify-content: center;
  margin: 0 0.18rem;
  min-width: 0;
  padding: var(--space-1);
  text-align: center;
}

.bottom-nav a.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.bottom-nav a.center-item {
  background: var(--color-primary);
  color: white;
  transform: translateY(-8px);
  box-shadow: var(--shadow-soft);
  margin: 0 0.24rem;
}

.bottom-nav a.center-item.is-active {
  background: var(--color-primary-dark);
}

.bottom-nav .is-disabled,
.top-nav .nav-disabled {
  color: #a8afad;
  cursor: not-allowed;
  opacity: 0.62;
}

.auth-modal {
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  max-width: 420px;
  padding: 0;
  width: calc(100% - 2rem);
}

.auth-modal::backdrop {
  background: rgba(12, 22, 20, 0.42);
}

.auth-box {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  position: relative;
}

.modal-close {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-muted);
  height: 34px;
  left: var(--space-4);
  position: absolute;
  top: var(--space-4);
  width: 34px;
}

.auth-step {
  display: none;
  gap: var(--space-3);
}

.auth-step.is-active {
  display: grid;
}

.auth-step label {
  color: var(--color-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.auth-step input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: 46px;
  padding: 0.65rem 0.85rem;
}

.auth-step input.has-error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(189, 47, 47, 0.12);
}

.field-error {
  color: var(--color-danger);
  font-size: 0.8rem;
  line-height: 1.7;
  margin: -0.35rem 0 0;
  min-height: 1.35rem;
}

.primary-action {
  background: var(--color-primary);
  border: 0;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 800;
  min-height: 46px;
  padding: 0.65rem 1rem;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-action.is-locked {
  cursor: not-allowed;
}

.link-action {
  background: transparent;
  border: 0;
  color: var(--color-primary);
  font-weight: 800;
  min-height: 40px;
}

.toast-region {
  display: grid;
  gap: var(--space-2);
  left: var(--space-4);
  max-width: min(360px, calc(100% - 2rem));
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  z-index: 60;
}

.toast {
  background: var(--color-ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  color: white;
  font-size: 0.88rem;
  padding: 0.7rem 0.9rem;
}

.toast-success {
  background: var(--color-success);
}

.toast-error {
  background: var(--color-danger);
}

@media (min-width: 560px) {
  .search-row {
    grid-template-columns: 1fr auto;
  }

  .filter-bar {
    grid-template-columns: 1fr 180px 180px;
  }

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

@media (min-width: 800px) {
  body {
    padding-bottom: 0;
  }

  .site-header {
    padding: 0 var(--space-6);
  }

  .top-nav {
    align-items: center;
    display: flex;
    gap: var(--space-2);
  }

  .auth-entry {
    order: 3;
  }

  .top-nav a,
  .top-nav .nav-disabled {
    border-radius: var(--radius-md);
    color: var(--color-muted);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.45rem 0.7rem;
  }

  .top-nav a.is-active,
  .top-nav a:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
  }

  .top-nav .nav-disabled,
  .top-nav .nav-disabled:hover {
    background: transparent;
    color: #a8afad;
  }

  .page-shell {
    padding: var(--space-6);
  }

  .search-panel {
    align-items: end;
    grid-template-columns: 1.2fr 0.8fr;
    padding: var(--space-8);
  }

  body:not([data-page="home"]) .page-title {
    display: grid;
  }

  h1 {
    font-size: 2rem;
  }

  .quick-grid {
    grid-template-columns: repeat(4, 1fr);
  }

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

  .item-card.has-media {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .item-image {
    height: 88px;
    width: 88px;
  }

  [data-list="more"] .item-card.has-media {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  [data-list="more"] .item-image {
    height: 64px;
    width: 64px;
  }

  .bottom-nav {
    display: none;
  }
}

@media (min-width: 1100px) {
  .item-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-layout .item-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
