/* Equal card slots keep titles on one line and actions in their own space. */
.app-shell, main, .card-main, .card-content, .card-footer,
.card-footer-right, .eighth-main, .eighth-body, .eighth-bottom-right,
.reader-heading {
  min-width: 0;
}

.hizb-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-main {
  flex: 1 1 auto;
  max-width: 100%;
}
.cards-grid .card-main {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  height: 136px;
  min-height: 136px;
  padding: 16px 18px;
}
.cards-grid .card-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 20px 50px 20px;
  align-content: center;
  gap: 0;
}
.cards-grid .card-eyebrow {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  gap: 8px;
}
.cards-grid .card-eyebrow > span { flex: 0 0 auto; white-space: nowrap; }
.cards-grid .hizb-title, .eighth-card .eighth-title {
  display: block;
  min-width: 0;
  height: 50px;
  min-height: 50px;
  margin: 0;
  font-size: 26px;
  line-height: 50px;
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
}
.cards-grid .card-meta, .eighth-card .eighth-meta {
  height: 20px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
}
.card-eyebrow, .card-meta, .eighth-label, .eighth-meta {
  overflow-wrap: anywhere;
}
.card-footer {
  flex: 0 0 auto;
  height: 56px;
  min-height: 56px;
  margin-top: auto;
  padding: 8px 12px;
  flex-wrap: nowrap;
  gap: 8px;
}
.card-footer .eighth-hint {
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
.card-footer-right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  max-width: 100%;
  gap: 8px;
}
.card-open {
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  font-size: 11px;
  line-height: 1.8;
  white-space: nowrap;
  gap: 6px;
}
.card-footer .save-button, .eighth-bottom .save-button {
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  height: 36px;
}

/* The main column can shrink independently of the action column. */
.list-view .hizb-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 144px;
  align-items: stretch;
}
.list-view .card-main {
  width: 100%;
  min-width: 0;
  height: 116px;
  min-height: 116px;
}
.list-view .card-content {
  display: grid;
  grid-template-columns: minmax(0, 120px) minmax(0, 1fr) minmax(0, 140px);
  grid-template-rows: 50px;
  gap: 12px;
}
.list-view .card-eyebrow, .list-view .card-meta {
  grid-area: auto;
}
.list-view .card-eyebrow {
  display: block;
  height: auto;
  line-height: 1.8;
}
.list-view .hizb-title { font-size: 27px; }
.list-view .card-footer {
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 14px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  justify-content: center;
}
.list-view .card-footer-right {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.list-view .card-open {
  max-width: 100%;
  min-height: 40px;
  text-align: start;
  justify-content: center;
}
.list-view .card-open .icon {
  display: inline-block;
  width: 15px;
  height: 15px;
}
.list-view .save-button {
  margin: 0;
}

.eighth-card { display: flex; flex-direction: column; min-width: 0; }
.eighth-main {
  max-width: 100%;
  height: 136px;
  min-height: 136px;
  flex: 0 0 auto;
  align-items: center;
  padding: 16px;
}
.eighth-body {
  display: grid;
  grid-template-rows: 18px 50px 20px 14px;
  min-width: 0;
}
.eighth-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  line-height: 18px;
}
.eighth-body .partial-label { margin: 0; line-height: 14px; }
.eighth-bottom {
  height: 56px;
  min-height: 56px;
  margin-top: auto;
  padding: 8px 14px;
  flex-wrap: nowrap;
  gap: 8px;
}
.eighth-bottom-right {
  flex-wrap: nowrap;
  gap: 8px;
}
.read-action, .done-button {
  min-height: 36px;
  max-width: 100%;
  white-space: nowrap;
}
.eighths-heading, .section-heading, .hero-stats { flex-wrap: wrap; }
.eighths-heading { gap: 8px; }
.section-tools { flex-shrink: 0; }
.eighths-heading h2 { min-width: 0; }

.detail-pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
}
.detail-pager .pager-button, .reader-bottom .pager-button {
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  justify-content: center;
  flex-wrap: wrap;
}
.detail-pager > span { text-align: center; }
.reader-heading h2 { overflow-wrap: anywhere; }
.reader-tools {
  flex-shrink: 0;
  flex-wrap: wrap;
}
.reader-tools > button { min-width: 36px; min-height: 36px; }
.reader-bottom { flex-wrap: wrap; }
.reader-bottom .pager-button { flex: 1 1 100px; }
.reader-bottom .done-button { justify-content: center; }
.reader-bottom .primary-button {
  order: 1;
  flex: 1 1 100%;
  white-space: normal;
}

@media (max-width: 1190px) {
  .list-view .card-main { height: 136px; min-height: 136px; }
  .list-view .card-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 20px 50px 20px;
    gap: 0;
  }
  .list-view .card-eyebrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 20px;
    min-height: 0;
    padding: 0;
    line-height: 20px;
  }
  .list-view .card-eyebrow > span { display: inline; }
}

@media (max-width: 760px) {
  .cards-grid.list-view .hizb-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .list-view .card-main {
    padding: 16px;
  }
  .list-view .card-footer {
    height: 56px;
    min-height: 56px;
    padding: 8px 14px;
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }
  .list-view .card-footer-right {
    flex-direction: row;
    justify-content: space-between;
    gap: 12px;
  }
  .list-view .card-open { justify-content: flex-start; }
  .card-open, .read-action, .done-button { min-height: 40px; }
  .card-footer .save-button, .eighth-bottom .save-button {
    flex-basis: 40px; min-width: 40px; width: 40px; height: 40px;
  }
  .eighth-bottom .save-button { width: 40px; height: 40px; }
}

@media (max-width: 540px) {
  .cards-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .cards-grid .card-main {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 13px;
    padding: 16px;
  }
  .cards-grid .number-seal {
    float: none;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    margin: 0;
    font-size: 17px;
  }
  .cards-grid .card-eyebrow {
    font-size: 10px;
  }
  .cards-grid .card-eyebrow > span { display: inline; font-size: 9px; }
  .cards-grid .hizb-title {
    clear: none;
    font-size: 26px;
  }
  .cards-grid .card-meta { font-size: 10px; }
  .cards-grid .card-footer { padding: 8px 14px; }
  .reader-toolbar {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: start;
    gap: 8px 12px;
  }
  .reader-heading { grid-column: 2; grid-row: 1; }
  .reader-tools {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    justify-content: flex-start;
    gap: 6px;
  }
}

@media (max-width: 360px) {
  .eighth-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 40px 40px;
    height: 96px;
    min-height: 96px;
    gap: 0;
  }
  .eighth-bottom .read-action { justify-content: center; }
  .eighth-bottom-right { justify-content: space-between; }
}

@media (max-width: 400px) {
  .search-panel { display: grid; grid-template-columns: minmax(0, 1fr); }
  .juz-select { width: 100%; max-width: none; }
  .division-switch button { flex-wrap: wrap; }
}

@media (max-height: 500px) {
  .reader-toolbar, .reader-bottom { position: static; }
}
