/* ==========================================================================
   Book Bazaar - design system + page styles
   Ek hi stylesheet teeno pages ke liye. Koi framework, koi build step nahi.
   ========================================================================== */

/* --------------------------------------------------------------- 1. tokens */

:root {
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --bg: #f6f6fb;
  --bg-soft: #eeedf6;
  --surface: #ffffff;
  --surface-2: #f3f2f9;
  --border: #e2e0ee;
  --border-strong: #cdcade;
  --text: #16151f;
  --muted: #6a6880;

  --brand: #5b4bd6;
  --brand-ink: #ffffff;
  --brand-soft: #ece9fc;
  --brand-strong: #4336b8;

  --accent: #e08a1e;
  --accent-soft: #fdf1dc;

  --ok: #1d9a6c;
  --ok-soft: #e1f6ec;
  --warn: #c98100;
  --warn-soft: #fdf3dd;
  --danger: #d9442f;
  --danger-soft: #fde9e5;
  --info: #2b6fd4;
  --info-soft: #e6effc;

  /* "ink" = soft background par likhne wale rang. Base rang chhote text ke liye
     WCAG AA (4.5:1) pass nahi karte, isliye text ke liye yeh gehre version. */
  --ok-ink: #0f7049;
  --warn-ink: #8a5a06;
  --danger-ink: #b22f1c;
  --info-ink: #1f5fbd;
  --accent-ink-text: #8a5a06;
  --danger-btn: #c0392b;
  --wa-btn: #0e7a3b;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(22, 21, 31, 0.06), 0 1px 3px rgba(22, 21, 31, 0.04);
  --shadow: 0 4px 14px rgba(22, 21, 31, 0.08);
  --shadow-lg: 0 18px 48px rgba(22, 21, 31, 0.18);

  --maxw: 1180px;
  --header-h: 64px;
}

html[data-theme="dark"] {
  --bg: #111019;
  --bg-soft: #171622;
  --surface: #1b1a26;
  --surface-2: #232231;
  --border: #302e40;
  --border-strong: #413e55;
  --text: #f1f0f8;
  --muted: #a3a0b8;

  --brand: #8b7cf6;
  --brand-ink: #14121f;
  --brand-soft: #27234a;
  --brand-strong: #a394ff;

  --accent: #f0ab4a;
  --accent-soft: #35290f;

  --ok: #43c491;
  --ok-soft: #14301f;
  --warn: #e8ae46;
  --warn-soft: #332611;
  --danger: #f2705a;
  --danger-soft: #371a15;
  --info: #70a4f0;
  --info-soft: #152338;

  /* dark theme me soft background gehre hain, isliye yahan bright rang hi theek hain */
  --ok-ink: #43c491;
  --warn-ink: #e8ae46;
  --danger-ink: #f2705a;
  --info-ink: #70a4f0;
  --accent-ink-text: #f0ab4a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #111019;
    --bg-soft: #171622;
    --surface: #1b1a26;
    --surface-2: #232231;
    --border: #302e40;
    --border-strong: #413e55;
    --text: #f1f0f8;
    --muted: #a3a0b8;

    --brand: #8b7cf6;
    --brand-ink: #14121f;
    --brand-soft: #27234a;
    --brand-strong: #a394ff;

    --accent: #f0ab4a;
    --accent-soft: #35290f;

    --ok: #43c491;
    --ok-soft: #14301f;
    --warn: #e8ae46;
    --warn-soft: #332611;
    --danger: #f2705a;
    --danger-soft: #371a15;
    --info: #70a4f0;
    --info-soft: #152338;

    --ok-ink: #43c491;
    --warn-ink: #e8ae46;
    --danger-ink: #f2705a;
    --info-ink: #70a4f0;
    --accent-ink-text: #f0ab4a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

/* ----------------------------------------------------------------- 2. base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

/* Browser ka default [hidden] rule bahut kamzor hai: koi bhi `display` set karne wali
   class use override kar deti hai (cart badge, drawer, scrim). Isliye yahan pin kar rahe hain. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem);
}
h2 {
  font-size: 1.3rem;
}
h3 {
  font-size: 1.08rem;
}

p {
  margin: 0 0 0.9em;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px;
}

.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  left: 12px;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.86rem;
}
.strong {
  font-weight: 650;
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------- 3. header */

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.06rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover {
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), var(--brand-strong));
  color: var(--brand-ink);
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav__link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 560;
  font-size: 0.94rem;
}
.nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav__link.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.nav-toggle {
  display: none;
}

/* --------------------------------------------------------------- 4. layout */

main {
  display: block;
  padding-bottom: 54px;
}

.section {
  margin-top: 26px;
}

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card--pad {
  padding: 18px;
}

.banner {
  margin: 14px 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.9rem;
}
.banner--warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--text);
}
.banner--info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
}

/* ----------------------------------------------------------------- 5. hero */

.hero {
  margin-top: 22px;
  padding: 26px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%);
  border: 1px solid var(--border);
}

.hero__title {
  margin-bottom: 6px;
}

.hero__sub {
  color: var(--muted);
  max-width: 54ch;
  margin-bottom: 16px;
}

.hero__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 220px;
}
.search input[type="search"] {
  /* input[type="search"] ki base rule baad me aati hai, isliye yahan specificity chahiye */
  padding-left: 38px;
}
.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.stats-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}
.stats-row > div {
  font-size: 0.86rem;
  color: var(--muted);
}
.stats-row b {
  display: block;
  font-size: 1.15rem;
  color: var(--text);
}

/* -------------------------------------------------------------- 6. buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 620;
  font-size: 0.93rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover {
  filter: brightness(1.06);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--soft {
  background: var(--brand-soft);
  color: var(--brand);
}

.btn--danger {
  background: var(--danger-btn);
  color: #fff;
}

.btn--wa {
  background: var(--wa-btn);
  color: #fff;
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 6px 11px;
  font-size: 0.85rem;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
}

/* --------------------------------------------------------------- 7. badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge--new {
  background: var(--ok-soft);
  color: var(--ok-ink);
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
}
.badge--likenew {
  background: var(--info-soft);
  color: var(--info-ink);
  border-color: color-mix(in srgb, var(--info) 32%, transparent);
}
.badge--good {
  background: var(--accent-soft);
  color: var(--accent-ink-text);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}
.badge--fair {
  background: var(--surface-2);
  color: var(--muted);
}
.badge--brand {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
}
.badge--danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}
.badge--warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}
.badge--ok {
  background: var(--ok-soft);
  color: var(--ok-ink);
  border-color: color-mix(in srgb, var(--ok) 32%, transparent);
}

/* -------------------------------------------------------------- 8. filters */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filters .field {
  margin: 0;
  flex: 1 1 150px;
  min-width: 140px;
}

.filters__reset {
  margin-left: auto;
}

.chip-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 560;
  cursor: pointer;
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

/* ----------------------------------------------------------- 9. book cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.book {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.book:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.cover {
  display: block;
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  overflow: hidden;
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover--generated {
  display: grid;
  place-items: center;
  background: linear-gradient(
    150deg,
    hsl(var(--cover-hue, 250) 62% 56%),
    hsl(calc(var(--cover-hue, 250) + 38) 55% 38%)
  );
}
.cover__initials {
  font-size: 2.3rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}
.cover__spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 10px;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.18);
}

.book__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 13px 0;
  flex: 1;
}

.book__title {
  display: -webkit-box;
  font-size: 0.97rem;
  font-weight: 680;
  line-height: 1.32;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book__author {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: auto;
  padding-top: 8px;
}
.price {
  font-size: 1.12rem;
  font-weight: 760;
  letter-spacing: -0.02em;
}
.price-mrp {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: line-through;
}
.price-off {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ok-ink);
}

.book__actions {
  display: flex;
  gap: 7px;
  padding: 11px 13px 13px;
}
.book__actions .btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 0.86rem;
}

/* ---------------------------------------------------------- 10. empty/misc */

.empty {
  text-align: center;
  padding: 46px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}
.empty__icon {
  font-size: 2.1rem;
  margin-bottom: 8px;
}
.empty h3 {
  color: var(--text);
}

.result-count {
  font-size: 0.88rem;
  color: var(--muted);
}

/* --------------------------------------------------------------- 11. forms */

.field {
  display: block;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  font-size: 0.86rem;
  font-weight: 620;
  margin-bottom: 5px;
}
.field__label .req {
  color: var(--danger);
}

.field__hint {
  display: block;
  font-size: 0.79rem;
  color: var(--muted);
  margin-top: 4px;
}

.field__error {
  display: block;
  font-size: 0.79rem;
  color: var(--danger);
  margin-top: 4px;
  min-height: 1em;
}

input[type="text"],
input[type="search"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.93rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
textarea {
  min-height: 86px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 14px;
}
.form-grid .field--wide {
  grid-column: 1 / -1;
}

.input-prefix {
  display: flex;
  align-items: stretch;
}
.input-prefix__tag {
  display: grid;
  place-items: center;
  padding: 0 10px;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-prefix input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.checkbox {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 0.89rem;
}
.checkbox input {
  width: auto;
  margin-top: 3px;
}

/* ------------------------------------------------------------- 12. drawer */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform 0.24s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.drawer.is-open {
  transform: translateX(0);
}

.drawer__scrim {
  position: fixed;
  inset: 0;
  background: rgba(14, 13, 22, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 55;
}
.drawer__scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer__head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
}

.drawer__foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.cart-line {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.cart-line:last-child {
  border-bottom: 0;
}
.cart-line .cover {
  aspect-ratio: 3 / 4;
  border-radius: 7px;
}
.cart-line__title {
  font-size: 0.9rem;
  font-weight: 640;
  line-height: 1.3;
}
.cart-line__sub {
  font-size: 0.79rem;
  color: var(--muted);
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 6px;
}
.qty button {
  width: 26px;
  height: 26px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  line-height: 1;
}
.qty button:hover {
  background: var(--border);
}
.qty span {
  min-width: 28px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 650;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 11px;
  font-size: 0.93rem;
}
.total-row b {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

/* ------------------------------------------------------------- 13. dialogs */

dialog.dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 56px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.dialog--sm {
  width: min(420px, calc(100vw - 28px));
}
dialog.dialog--lg {
  width: min(720px, calc(100vw - 28px));
}
dialog::backdrop {
  background: rgba(14, 13, 22, 0.5);
  backdrop-filter: blur(2px);
}

.dialog__body {
  padding: 20px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.dialog__head h2,
.dialog__head h3 {
  margin: 0;
}
.dialog__close {
  margin-left: auto;
  background: none;
  border: 0;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.dialog__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.confirm__title {
  margin-bottom: 6px;
}
.confirm__text {
  color: var(--muted);
  margin: 0;
}

.detail {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 18px;
}
.detail .cover {
  border-radius: var(--radius-sm);
}
.detail__desc {
  white-space: pre-wrap;
}
.seller-box {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.success {
  text-align: center;
  padding: 8px 4px;
}
.success__tick {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 1.7rem;
}
.success__id {
  display: inline-block;
  margin: 6px 0 12px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------- 14. table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
  min-width: 680px;
}

thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--surface-2);
}

td .btn-row {
  gap: 6px;
}

.cell-title {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 220px;
}
.cell-title .cover {
  width: 34px;
  flex: 0 0 34px;
  border-radius: 5px;
}
.cell-title .cover__initials {
  font-size: 0.85rem;
}

select.status-select {
  padding: 5px 8px;
  font-size: 0.84rem;
  width: auto;
  min-width: 118px;
}

/* ---------------------------------------------------------------- 15. tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 9px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-panel[hidden] {
  display: none;
}

/* ---------------------------------------------------------- 16. stat cards */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 13px;
}

.stat {
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat__label {
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 650;
}
.stat__value {
  font-size: 1.75rem;
  font-weight: 780;
  letter-spacing: -0.03em;
  margin-top: 3px;
}
.stat__foot {
  font-size: 0.8rem;
  color: var(--muted);
}

/* --------------------------------------------------------------- 17. login */

.login-wrap {
  max-width: 400px;
  margin: 8vh auto 0;
}
.login-wrap .card--pad {
  padding: 24px;
}
.login-lock {
  font-size: 1.9rem;
  margin-bottom: 6px;
}

/* ------------------------------------------------------------- 18. listing */

.listing-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.listing-row:last-child {
  border-bottom: 0;
}
.listing-row .cover {
  aspect-ratio: 3 / 4;
  border-radius: 6px;
}
.listing-row .cover__initials {
  font-size: 0.95rem;
}

.preview-card {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-top: 20px;
}

/* --------------------------------------------------------------- 19. toast */

.toast-host {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 24px));
}

.toast {
  padding: 10px 16px;
  border-radius: 999px;
  background: #1d1c28;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 560;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  max-width: 100%;
  text-align: center;
}
.toast--ok {
  background: #14714f;
}
.toast--err {
  background: #a8311f;
}
.toast.is-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------------------------------------- 20. footer */

.footer {
  margin-top: 46px;
  padding: 22px 0 30px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 0.86rem;
  color: var(--muted);
}
.footer__inner {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------- 21. responsive */

@media (max-width: 860px) {
  .split {
    grid-template-columns: 1fr;
  }
  .preview-card {
    position: static;
  }
  .detail {
    grid-template-columns: 110px 1fr;
    gap: 14px;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }
  .nav-toggle {
    display: grid;
  }
  .nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav.is-open {
    display: flex;
  }
  .nav__link {
    padding: 11px 12px;
  }
  .hero {
    padding: 20px 18px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  .cover__initials {
    font-size: 1.7rem;
  }
  .book__actions {
    flex-direction: column;
  }
  .filters__reset {
    margin-left: 0;
  }
  .detail {
    grid-template-columns: 1fr;
  }
  .detail .cover {
    max-width: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .header,
  .footer,
  .book__actions,
  .filters,
  .toast-host {
    display: none !important;
  }
}

/* ------------------------------------------------------- 22. extra pieces */

.book__trigger {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.book__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

input[type="range"] {
  width: 100%;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--brand);
  cursor: pointer;
}

input[type="file"] {
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  font-size: 0.89rem;
  margin: 0;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  font-weight: 560;
}

.order-items {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.order-items li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.89rem;
}
.order-items li:last-child {
  border-bottom: 0;
}

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

/* ------------------------------------------------- 23. cover photo uploader */

.uploader {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.uploader__preview {
  width: 62px;
  flex: 0 0 62px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.uploader__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.uploader__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------- 24. checkout item breakdown */

.checkout-items__head {
  margin: 0 0 2px;
  font-size: 0.92rem;
}

.checkout-items {
  margin-bottom: 14px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
}
.checkout-items .cart-line {
  grid-template-columns: 46px 1fr auto;
  padding: 10px 0;
}
.checkout-items .cover {
  border-radius: 6px;
}
.checkout-items .cover__initials {
  font-size: 0.95rem;
}

/* Photo chuni ho to URL field band ho jaata hai - wo dikhna bhi chahiye */
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.75;
}
