:root {
  --bg: #f7f5ef;
  --panel: #ffffff;
  --panel-muted: #fbfaf6;
  --ink: #25302b;
  --muted: #69746f;
  --line: #ded9cc;
  --accent: #2f6f73;
  --accent-strong: #20545a;
  --accent-soft: #dceeed;
  --warm: #a85638;
  --warm-soft: #f2dfd4;
  --gold: #c5943a;
  --shadow: 0 18px 45px rgba(42, 47, 43, 0.08);
  --radius: 8px;
  --body-fade-start: rgba(247, 245, 239, 0.96);
  --body-fade-end: rgba(247, 245, 239, 1);
  --texture: rgba(47, 111, 115, 0.04);
  --primary-hover: #163f44;
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --row-bg: #ffffff;
  --calendar-outside: #f1eee6;
}

* {
  box-sizing: border-box;
}

body.style-warm {
  --bg: #fff8f1;
  --panel: #fffdf9;
  --panel-muted: #fff3e8;
  --ink: #302620;
  --muted: #76675e;
  --line: #ead1bc;
  --accent: #b95f44;
  --accent-strong: #7e3d2c;
  --accent-soft: #f7dccc;
  --warm: #2f756d;
  --warm-soft: #d9eeeb;
  --gold: #cf9a28;
  --body-fade-start: rgba(255, 248, 241, 0.96);
  --body-fade-end: rgba(255, 248, 241, 1);
  --texture: rgba(185, 95, 68, 0.05);
  --primary-hover: #663022;
  --topbar-bg: rgba(255, 253, 249, 0.88);
  --calendar-outside: #f8ece1;
}

body.style-bold {
  --bg: #f2f6fb;
  --panel: #ffffff;
  --panel-muted: #eef4fa;
  --ink: #111827;
  --muted: #566173;
  --line: #c9d5e3;
  --accent: #0b7285;
  --accent-strong: #12306b;
  --accent-soft: #d8f3f7;
  --warm: #c2410c;
  --warm-soft: #ffedd5;
  --gold: #d97706;
  --body-fade-start: rgba(242, 246, 251, 0.97);
  --body-fade-end: rgba(242, 246, 251, 1);
  --texture: rgba(18, 48, 107, 0.055);
  --primary-hover: #071f52;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --calendar-outside: #e7edf5;
}

body.style-calm {
  --bg: #f4f8f2;
  --panel: #ffffff;
  --panel-muted: #f0f6ec;
  --ink: #23302b;
  --muted: #65746d;
  --line: #cfdcc9;
  --accent: #6b8f71;
  --accent-strong: #385f56;
  --accent-soft: #dfeee2;
  --warm: #7f5a83;
  --warm-soft: #eadff0;
  --gold: #a8873d;
  --body-fade-start: rgba(244, 248, 242, 0.96);
  --body-fade-end: rgba(244, 248, 242, 1);
  --texture: rgba(107, 143, 113, 0.05);
  --primary-hover: #294840;
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --calendar-outside: #edf3e9;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, var(--body-fade-start), var(--body-fade-end)),
    repeating-linear-gradient(90deg, var(--texture) 0, var(--texture) 1px, transparent 1px, transparent 120px);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label.button {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  padding: 22px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar > div {
  min-width: 0;
  max-width: 100%;
}

.topbar h1,
.calendar-header h2,
.section-heading h2,
.notice-card h2,
.book-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.topbar-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.style-link {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--accent-strong);
  background: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.style-link:hover,
.style-link:focus-visible,
.style-link.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 0.94fr) minmax(420px, 1.06fr);
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 34px) 32px;
  max-width: 1500px;
  margin: 0 auto;
}

.left-panel,
.right-panel {
  min-width: 0;
}

.app-shell > *,
.control-strip,
.notice-card,
.book-focus,
.book-cover,
.book-copy {
  min-width: 0;
}

.left-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.announcements-section {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.announcements-section p {
  margin: 8px 0 0;
  color: var(--muted);
}

.right-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.control-strip,
  .notice-card,
  .book-focus,
  .calendar-card,
  .signup-card,
  .signup-list-card,
  .style-preview-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
}

.notice-label,
.eyebrow,
.month-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
}

.notice-times {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.notice-times span,
.pill,
.entry-chip {
  min-width: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 500;
  overflow-wrap: anywhere;
  white-space: normal;
}

.notice-times span {
  display: block;
  max-width: 100%;
  line-height: 1.25;
}

.notice-times strong {
  display: block;
}

.bilingual-line {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.bilingual-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.bilingual-text {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.book-focus {
  padding: 18px;
}

.selected-book-detail {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
}

.book-cover {
  position: relative;
  min-height: 222px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--warm-soft);
  border: 1px solid rgba(168, 86, 56, 0.24);
}

.book-cover img {
  max-width: 100%;
  width: 100%;
  height: 100%;
  min-height: 222px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.book-cover.image-missing img {
  display: none;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: #63331f;
  font-weight: 600;
  line-height: 1.15;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(0deg, rgba(99, 51, 31, 0.08) 0, rgba(99, 51, 31, 0.08) 1px, transparent 1px, transparent 18px),
    var(--warm-soft);
}

.book-cover:not(.image-missing) .cover-fallback {
  display: none;
}

.book-copy {
  min-width: 0;
}

.book-copy h2 {
  margin-top: 4px;
  font-size: clamp(1.35rem, 2.1vw, 2rem);
  line-height: 1.12;
}

.author {
  margin: 6px 0 10px;
  color: var(--muted);
  font-weight: 500;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill-row .bilingual-line {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #eff1e8;
}

.pill {
  background: #eff1e8;
  color: #495047;
}

blockquote {
  margin: 16px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  background: #fffaf0;
  color: #4a3a20;
  font-size: 1rem;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panel-muted);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  font-weight: 500;
}

.training-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.training-details h3 {
  margin: 4px 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.training-details p {
  margin: 4px 0 0;
  color: var(--muted);
}

.training-book-title {
  color: var(--ink) !important;
  font-weight: 600;
}

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

.training-documents a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--accent-strong);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.training-documents a:hover,
.training-documents a:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.training-signup-link {
  width: fit-content;
  text-decoration: none;
}

.training-signup-link.is-disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--panel-muted);
}

.book-list-section,
.calendar-card,
.signup-card,
.signup-list-card,
.announcements-section,
.resources-section,
.style-preview-section {
  padding: 14px;
}

.resources-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.document-grid {
  display: grid;
  gap: 10px;
}

.document-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-muted);
}

.document-card h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
}

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

.document-links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--accent-strong);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.document-links a:hover,
.document-links a:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.style-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.style-preview-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  align-content: end;
  gap: 5px;
  color: #fff;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.style-preview-card span {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
}

.style-preview-card strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.style-preview-card.classic {
  background: linear-gradient(135deg, #20545a, #c5943a);
}

.style-preview-card.warm {
  background: linear-gradient(135deg, #7e3d2c, #cf9a28);
}

.style-preview-card.bold {
  background: linear-gradient(135deg, #12306b, #0b7285);
}

.style-preview-card.calm {
  background: linear-gradient(135deg, #385f56, #7f5a83);
}

.style-preview-card:hover,
.style-preview-card:focus-visible,
.style-preview-card.is-active {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.08rem;
}

#bookCountLabel,
#signupCountLabel {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
}

.book-list {
  display: grid;
  gap: 8px;
}

.book-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: var(--row-bg);
  cursor: pointer;
  text-align: left;
}

.book-row:hover,
.book-row:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.book-row.is-selected {
  background: var(--accent-soft);
  border-color: rgba(47, 111, 115, 0.45);
}

.book-row-cover {
  width: 50px;
  height: 64px;
  border-radius: 6px;
  background: var(--warm-soft);
  display: grid;
  place-items: center;
  color: #7b3e27;
  font-weight: 600;
  font-size: 1.05rem;
}

.book-row-title {
  display: block;
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
}

.book-row-meta {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.book-row-details {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.book-row-details .bilingual-line {
  border-left: 3px solid rgba(197, 148, 58, 0.65);
  padding-left: 8px;
}

.book-row-details .bilingual-text {
  font-size: 0.82rem;
  font-weight: 500;
}

.month-tag {
  align-self: start;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.calendar-header {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  text-align: center;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-row {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
}

.day-cell {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  color: var(--ink);
  padding: 7px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.day-cell:hover,
.day-cell:focus-visible,
.day-cell.is-selected {
  border-color: var(--accent);
  outline: none;
}

.day-cell.is-outside {
  color: #9aa29d;
  background: var(--calendar-outside);
}

.day-cell.has-entry {
  background: #eef7f6;
}

.day-number {
  font-weight: 600;
}

.day-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warm);
  display: inline-block;
}

.day-label {
  color: var(--accent-strong);
  font-size: 0.73rem;
  font-weight: 600;
  line-height: 1.2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.15);
  outline: none;
}

.capacity-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 40px;
  min-width: 0;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
}

.button.primary {
  color: #fff;
  background: var(--accent-strong);
}

.button.primary:hover,
.button.primary:focus-visible {
  background: var(--primary-hover);
}

.button.secondary,
.button.ghost {
  color: var(--accent-strong);
  border-color: var(--line);
  background: #fff;
}

.button.ghost:hover,
.button.ghost:focus-visible,
.button.secondary:hover,
.button.secondary:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.button.full {
  width: 100%;
  margin-top: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-color: var(--line);
  color: var(--accent-strong);
  background: #fff;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.icon-button:disabled {
  cursor: not-allowed;
  color: #a5aba6;
  background: #f1eee6;
  border-color: var(--line);
}

.form-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 500;
}

.signup-list {
  display: grid;
  gap: 8px;
}

.signup-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.signup-item-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.signup-item h3 {
  margin: 0;
  font-size: 0.98rem;
}

.signup-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.entry-chip {
  display: inline-block;
  margin-top: 8px;
  background: var(--warm-soft);
  color: #713820;
}

.delete-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--warm);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}

.delete-button:hover,
.delete-button:focus-visible {
  border-color: var(--warm);
  outline: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: var(--panel-muted);
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar > div {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
  }

  .topbar-actions .button,
  .topbar-actions .style-link {
    width: 100%;
    text-align: center;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 18px 10px;
  }

  .topbar h1 {
    width: min(100%, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    font-size: 1.16rem;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, calc(100vw - 20px));
    min-width: 0;
  }

  .topbar-actions .button,
  .topbar-actions .style-link {
    min-width: 0;
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  .topbar-actions .button {
    grid-column: 1 / -1;
  }

  .app-shell {
    padding: 12px 10px 24px;
  }

  .topbar-actions .button {
    display: block;
  }

  .topbar-actions .button,
  .topbar-actions .style-link {
    font-size: 0.9rem;
    padding-inline: 8px;
  }

  .control-strip,
  .selected-book-detail,
  .form-grid,
  .detail-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .book-focus {
    padding: 14px;
  }

  .book-cover {
    min-height: 230px;
  }

  .book-row {
    grid-template-columns: 48px 1fr;
  }

  .month-tag {
    grid-column: 2;
  }

  .calendar-card,
  .signup-card,
  .signup-list-card,
  .resources-section,
  .style-preview-section {
    padding: 12px;
  }

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

  .weekday-row,
  .calendar-grid {
    gap: 4px;
  }

  .weekday-row span {
    font-size: 0.7rem;
  }

  .day-cell {
    min-height: 62px;
    padding: 5px;
  }

  .day-label {
    display: none;
  }

  .section-heading {
    align-items: flex-start;
  }
}
