.book {
  --book-gap: 0.7rem;
  --book-card: var(--brand-card-bg, Canvas);
  --book-surface: var(--brand-surface, Canvas);
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--book-gap);
  color: var(--brand-text, #0f172a);
}

.book__kicker {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-muted, #64748b);
}

.book__alerts {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.book__ok,
.book__err {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  border-radius: 0.65rem;
}

.book__ok {
  color: #047857;
  background: color-mix(in srgb, #059669 12%, var(--book-card));
}

.book__err {
  color: #b91c1c;
  background: color-mix(in srgb, #b91c1c 10%, var(--book-card));
}

.book__tabs {
  display: none;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.book__tabs button {
  border: 1px solid var(--brand-border, #e2e8f0);
  background: var(--book-card);
  border-radius: 0.65rem;
  padding: 0.55rem 0.4rem;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  color: inherit;
}

.book__tabs button.is-active {
  background: var(--brand-primary);
  color: var(--brand-button-text);
  border-color: transparent;
}

.book__workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) minmax(0, 1.45fr) minmax(14rem, 1.05fr);
  gap: var(--book-gap);
  align-items: stretch;
  overflow: hidden;
}

.book__services,
.book__main,
.book__side-card {
  border: 1px solid var(--brand-border, #e2e8f0);
  border-radius: 1rem;
  background: var(--book-card);
  min-width: 0;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
}

.book__services {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.75rem;
  gap: 0.55rem;
}

.book__section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.book__section-head h4,
.book__ai-draft-head h5 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
}

.book__section-head--tight {
  margin-bottom: 0.45rem;
}

.book__badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary) 12%, var(--book-card));
  white-space: nowrap;
}

.book__service-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.book__service-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--brand-border, #e2e8f0);
  background: color-mix(in srgb, var(--book-surface) 75%, var(--book-card));
  border-radius: 0.85rem;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  color: inherit;
}

.book__service-card.is-active {
  border-color: color-mix(in srgb, var(--brand-primary) 55%, var(--brand-border, #e2e8f0)) !important;
  background: color-mix(in srgb, var(--brand-primary) 12%, var(--book-card)) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 22%, transparent);
}

.book__service-card strong {
  font-size: 0.9rem;
}

.book__service-meta,
.book__service-host,
.book__service-desc,
.book__muted {
  font-size: 0.78rem;
  color: var(--brand-muted, #64748b);
}

.book__service-desc {
  line-height: 1.35;
}

.book__main {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.75rem;
  overflow: auto;
  height: 100%;
}

.book__date input {
  border: 1px solid var(--brand-border, #e2e8f0);
  border-radius: 0.65rem;
  padding: 0.45rem 0.55rem;
  background: var(--book-card);
}

.book__days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.book__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  border: 1px solid var(--brand-border, #e2e8f0);
  background: var(--book-card);
  border-radius: 0.75rem;
  min-height: 3.15rem;
  padding: 0.4rem 0.25rem;
  cursor: pointer;
  color: inherit;
  min-width: 0;
}

.book__day span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brand-muted, #64748b);
}

.book__day strong {
  font-size: 0.78rem;
}

.book__day.is-today {
  border-color: color-mix(in srgb, var(--brand-primary) 45%, var(--brand-border, #e2e8f0));
}

.book__day.is-active {
  background: var(--brand-primary) !important;
  color: var(--brand-button-text) !important;
  border-color: transparent !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 28%, transparent);
}

.book__day.is-active span {
  color: inherit;
  opacity: 0.85;
}

.book__slots-wrap {
  flex: 0 0 auto;
}

.book__slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: 0.4rem;
}

.book__slot {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--brand-border, #e2e8f0);
  background: var(--book-card);
  border-radius: 0.7rem;
  min-height: 2.55rem;
  padding: 0.5rem 0.35rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  color: inherit;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
}

.book__slot:hover {
  border-color: color-mix(in srgb, var(--brand-primary) 45%, var(--brand-border, #e2e8f0));
  background: color-mix(in srgb, var(--brand-primary) 8%, var(--book-card));
}

.book__slot.is-active,
.book__slot[aria-pressed="true"] {
  background: var(--brand-primary) !important;
  color: var(--brand-button-text) !important;
  border-color: transparent !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 28%, transparent);
}

.book__confirm {
  margin-top: auto;
  border-top: 1px solid var(--brand-border, #e2e8f0);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.book__summary {
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem;
  background: color-mix(in srgb, var(--brand-primary) 8%, var(--book-card));
  border: 1px solid color-mix(in srgb, var(--brand-primary) 16%, var(--brand-border, #e2e8f0));
}

.book__summary-line {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
}

.book__label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 0;
}

.book__label textarea,
.book__label select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--brand-border, #e2e8f0);
  border-radius: 0.7rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  background: var(--book-card);
}

.book__label textarea {
  resize: vertical;
}

.book__intake {
  margin-top: 0.35rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--brand-border, #e2e8f0);
}

.book__intake .lms-public-form {
  width: 100%;
}

.book__submit,
.book__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.7rem;
  min-height: 2.55rem;
  padding: 0.6rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  color: var(--brand-button-text);
  background: var(--brand-primary);
}

.book__submit {
  width: 100%;
  min-height: 2.75rem;
  font-size: 0.92rem;
}

.book__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.book__btn--ghost {
  background: var(--book-card);
  color: inherit;
  border: 1px solid var(--brand-border, #e2e8f0);
}

.book__btn--danger {
  background: var(--book-card);
  color: #b91c1c;
  border: 1px solid color-mix(in srgb, #b91c1c 35%, var(--book-card));
}

.book__mine-actions .book__btn {
  flex: 1 1 calc(50% - 0.35rem);
  min-width: 0;
  min-height: 2.45rem;
  font-size: 0.84rem;
}

.book__ai-draft-head .book__btn {
  min-height: 2.2rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.book__empty-main {
  margin: auto;
  text-align: center;
  padding: 2rem 1rem;
}

.book__side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

.book__side-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

.book__panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.75rem;
  gap: 0.55rem;
  flex: 1 1 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.book__panel--mine {
  border-bottom: 1px solid var(--brand-border, #e2e8f0);
}

.book__panel--ai {
  background: color-mix(in srgb, var(--book-surface) 55%, var(--book-card));
}

.book__mine-list,
.book__ai-scroll {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.book__mine-card {
  border: 1px solid var(--brand-border, #e2e8f0);
  border-radius: 0.8rem;
  padding: 0.65rem 0.7rem;
  background: var(--book-card);
}

.book__mine-card h5 {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.book__history {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--brand-border, #e2e8f0);
}

.book__history .book__section-head h5 {
  margin: 0;
  font-size: 0.8rem;
}

.book__history-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.55rem;
  background: color-mix(in srgb, var(--book-surface) 70%, var(--book-card));
  font-size: 0.75rem;
}

.book__history-row small {
  color: var(--brand-muted, #64748b);
  text-align: right;
}

.book__when {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand-muted, #64748b);
}

.book__mine-actions,
.book__ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.book__ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.book__ai-actions .book__submit {
  grid-column: 1 / -1;
  min-height: 2.75rem;
}

.book__ai-actions .book__btn {
  width: 100%;
  min-height: 2.55rem;
}

.book__ai-draft {
  border-radius: 0.8rem;
  padding: 0.65rem;
  background: color-mix(in srgb, var(--brand-primary) 8%, var(--book-card));
  border: 1px solid color-mix(in srgb, var(--brand-primary) 18%, var(--brand-border, #e2e8f0));
}

.book__ai-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.book__ai-draft pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-word;
  max-height: 12rem;
  overflow: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Dock fill */
#lms-hw-root .lms-tools__panel--book > .lms-tools__header--compact {
  margin-bottom: 0.55rem;
}

#lms-hw-root .lms-tools__panel--book > .lms-tools__header--compact h2 {
  font-size: 1.05rem;
}

#lms-hw-root .lms-tools__livewire--fill > .book {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 1100px) {
  .book__workspace {
    grid-template-columns: minmax(12rem, 1fr) minmax(0, 1.4fr);
    grid-template-rows: minmax(0, 1fr) minmax(14rem, 0.85fr);
  }

  .book__side {
    grid-column: 1 / -1;
    height: auto;
    min-height: 14rem;
  }

  .book__side-card {
    flex-direction: row;
    height: 100%;
  }

  .book__panel--mine {
    border-bottom: 0;
    border-right: 1px solid var(--brand-border, #e2e8f0);
    flex: 1 1 50%;
  }

  .book__panel--ai {
    flex: 1 1 50%;
  }
}

@media (max-width: 820px) {
  .book__tabs {
    display: grid;
  }

  .book__workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    overflow: auto;
  }

  .book__services,
  .book__main,
  .book__side {
    display: none;
    height: auto;
  }

  .book__services.is-mobile-active,
  .book__main.is-mobile-active {
    display: flex;
  }

  .book__side.is-mobile-active {
    display: flex;
    min-height: 18rem;
  }

  .book__side-card {
    flex-direction: column;
  }

  .book__panel {
    display: none;
    border: 0 !important;
  }

  .book__panel.is-mobile-active {
    display: flex;
    flex: 1 1 auto;
    min-height: 16rem;
  }

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

  .book__service-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .book__service-grid,
  .book__ai-actions {
    grid-template-columns: 1fr;
  }

  .book__days {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
