.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

.app-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}

.logo {
  font-size: 2.5rem;
  line-height: 1;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.app-main {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 2rem;
  align-items: start;
  padding-top: 1.75rem;
  flex: 1;
}

@media (max-width: 840px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  position: sticky;
  top: 1rem;
}

@media (max-width: 840px) {
  .sidebar {
    position: static;
  }
}

.book-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  text-align: left;
}

.book-form h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 1rem;
  color: var(--ink);
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.book-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.book-form input[type='text'],
.book-form input[type='number'],
.book-form input[type='search'] {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.book-form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  margin-top: 0.75rem;
  text-transform: none !important;
  font-weight: 500 !important;
  color: var(--ink) !important;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  background: var(--card);
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .btn.primary {
    color: #1c1917;
  }
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn.danger {
  color: var(--danger);
  border-color: transparent;
  background: var(--danger-soft);
}

.btn.danger:hover {
  border-color: var(--danger);
}

.book-list-section {
  text-align: left;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.search {
  font: inherit;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
}

.search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab {
  font: inherit;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-muted);
}

.tab:hover {
  color: var(--ink);
  border-color: var(--ink-muted);
}

.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.empty-state {
  color: var(--ink-muted);
  padding: 2rem 0;
  margin: 0;
}

.book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.book-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.book-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.badge.read {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.unread {
  background: var(--border);
  color: var(--ink-muted);
}

.genre {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.book-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0.25rem 0 0;
  line-height: 1.35;
  color: var(--ink);
}

.book-title-link {
  color: inherit;
  text-decoration: none;
}

.book-title-link:hover {
  text-decoration: underline;
}

.book-card .author {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.book-card .year {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

.app-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.app-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.app-footer code {
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--card);
  border: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-link {
  font: inherit;
  text-decoration: none;
  color: var(--ink-muted);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}

.nav-link:hover {
  color: var(--ink);
  border-color: var(--border);
  background: var(--card);
}

.nav-link.active {
  color: var(--ink);
  font-weight: 600;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.route-outlet {
  flex: 1;
}

.mes-livres-page {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mes-livres-intro {
  text-align: left;
}

.mes-livres-tagline {
  margin: 0;
}

.book-form-story {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.book-form-api {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.book-form-api code {
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.book-form-api-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.search-page {
  text-align: left;
  max-width: 720px;
}

.search-page-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.search-page-lead {
  margin: 0 0 1.25rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1rem;
}

.search-wide {
  flex: 1 1 220px;
  min-width: 0;
}

.search-error {
  color: var(--danger);
  margin: 0 0 1rem;
}

.search-hint {
  color: var(--ink-muted);
  margin: 0;
  font-size: 0.95rem;
}

.ol-results {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ol-result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.ol-result-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 0.35rem;
  color: var(--ink);
}

.ol-result-meta {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.book-detail {
  text-align: left;
  max-width: 520px;
  padding-top: 0.5rem;
}

.book-detail-back {
  display: inline-block;
  margin-bottom: 1rem;
}

.book-detail-missing {
  color: var(--ink-muted);
  margin: 0 0 1rem;
}

.book-detail .badge {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.book-detail-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  margin: 0 0 0.35rem;
  line-height: 1.25;
  color: var(--ink);
}

.book-detail-author {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  color: var(--ink-muted);
}

.book-detail-meta {
  margin: 0 0 1.5rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-detail-meta div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.35rem 1rem;
  margin-bottom: 0.65rem;
}

.book-detail-meta div:last-child {
  margin-bottom: 0;
}

.book-detail-meta dt {
  margin: 0;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.book-detail-meta dd {
  margin: 0;
  font-size: 0.95rem;
}

.book-detail-meta code {
  font-size: 0.85rem;
  word-break: break-all;
}

.book-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-title {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.page-lead {
  margin: 0 0 1.25rem;
  color: var(--ink-muted);
  max-width: 60ch;
}

.form-error {
  color: var(--danger);
  margin: 0 0 1rem;
}

.form-notice {
  margin: 0 0 1rem;
  color: var(--ink);
}

.order-grid,
.promo-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .order-grid,
  .promo-grid {
    grid-template-columns: 1fr;
  }
}

.order-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.panel-title {
  font-family: var(--font-display);
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.order-catalog,
.promo-list,
.order-summary {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.order-catalog-item,
.promo-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
}

.order-catalog-main,
.promo-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.order-book-title,
.promo-code {
  margin: 0;
  font-weight: 700;
}

.order-book-meta,
.promo-meta {
  margin: 0.2rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.qty {
  display: grid;
  gap: 0.25rem;
  align-items: center;
  justify-items: end;
}

.qty-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.qty input,
.promo-input,
.promo-form input {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  width: 7rem;
}

.promo-input {
  width: 100%;
}

.order-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
}

.promo-box {
  margin: 1rem 0;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--paper);
}

.promo-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.promo-hint {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.promo-warn {
  margin: 0.55rem 0 0;
  color: var(--danger);
}

.promo-ok {
  margin: 0.55rem 0 0;
}

.totals {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.9rem;
  margin-bottom: 0.9rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  margin: 0.25rem 0;
  color: var(--ink-muted);
}

.totals-row.total {
  color: var(--ink);
  font-weight: 800;
  margin-top: 0.6rem;
}

.promo-form {
  display: grid;
  gap: 0.75rem;
}

.promo-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.promo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
