:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d2433;
  background: #f5f6f8;
  line-height: 1.6;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
}

button,
select,
input { font: inherit; }

button { min-height: 44px; }

button:focus-visible,
summary:focus-visible,
input:focus-visible + span {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.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;
}

.app-shell {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.app-header { margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 3.5rem); line-height: 1.1; }
.lead { margin: 12px 0 0; }

.screen-heading { margin-bottom: 20px; }
.screen-heading h2,
.source-info h2 { margin: 0; }

.screen-heading p:not(.screen-kicker),
.source-info p,
.shelf-heading p,
.collection-description,
.practice-origin,
.practice-empty {
  margin: 4px 0 0;
  color: #596273;
  font-size: .92rem;
}

.screen-kicker,
.panel-kicker {
  margin: 0 0 4px;
  color: #596273;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

button {
  border: 1px solid #1d2433;
  border-radius: 10px;
  padding: 10px 16px;
  background: #1d2433;
  color: #fff;
  cursor: pointer;
}

button.secondary,
button.text-button {
  background: transparent;
  color: #1d2433;
}

button.secondary { border-color: #aeb5c0; }

button.text-button {
  min-height: auto;
  padding: 3px 0;
  border: 0;
  border-radius: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.compact {
  min-height: 40px;
  padding: 7px 12px;
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.practice-set-panel,
.card-shelf {
  border-radius: 18px;
}

.practice-set-panel {
  padding: 22px;
  background: #fff;
  border: 2px solid #1d2433;
  box-shadow: 0 8px 28px rgba(28, 36, 51, .07);
}

.practice-set-panel .panel-kicker {
  color: #1d2433;
}

.practice-set-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.practice-set-heading h3,
.shelf-heading h3 {
  margin: 0;
}

.practice-set-heading h3 {
  font-size: 1.45rem;
}

.practice-origin {
  margin-top: 10px;
}

.practice-empty {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed #b8bec8;
  border-radius: 12px;
  text-align: center;
}

.practice-groups {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.practice-group {
  padding-top: 14px;
  border-top: 1px solid #e3e6eb;
}

.practice-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.practice-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.practice-group-heading h4 {
  margin: 0;
  font-size: .98rem;
}

.practice-group-heading .text-button {
  flex: 0 0 auto;
  font-size: .78rem;
}

.practice-card-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.practice-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 10px;
  border-color: #c7ccd4;
  border-radius: 999px;
  background: #f7f8fa;
  color: #1d2433;
}

.practice-card-chip:hover {
  border-color: #1d2433;
}

.chip-remove {
  color: #6b7280;
  font-size: 1.05rem;
  line-height: 1;
}

.start-practice-button {
  width: 100%;
  min-height: 56px;
  margin-top: 20px;
  font-weight: 800;
  font-size: 1.03rem;
}

.card-shelf {
  margin-top: 20px;
  padding: 20px;
  background: #eef1f5;
  border: 1px solid #d9dde5;
}

.card-shelf .panel-kicker {
  color: #6b7280;
}

.shelf-heading h3 { font-size: 1.08rem; }

.shelf-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.shelf-collection {
  border: 1px solid #dfe3e9;
  border-radius: 14px;
  overflow: clip;
  background: #fff;
}

.shelf-collection > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  cursor: pointer;
  list-style-position: inside;
}

.shelf-collection > summary span {
  color: #596273;
  font-size: .85rem;
  font-weight: 500;
}

.shelf-collection-body {
  padding: 0 16px 16px;
  border-top: 1px solid #e8ebef;
}

.shelf-collection-body h4 {
  margin: 16px 0 8px;
  font-size: .88rem;
}

.collection-description { margin-top: 12px; }

.bundle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bundle-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 72px;
  text-align: left;
  background: #fff;
  color: #1d2433;
  border-color: #c8ced7;
}

.bundle-button:hover:not(:disabled) {
  border-color: #1d2433;
}

.bundle-button > span:first-child {
  min-width: 0;
}

.bundle-button strong,
.bundle-button small {
  display: block;
}

.bundle-button small {
  margin-top: 2px;
  color: #596273;
  font-weight: 400;
}

.shelf-action-label {
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 700;
}

.individual-picker {
  margin-top: 14px;
  border-top: 1px solid #e8ebef;
  padding-top: 10px;
}

.individual-picker > summary {
  cursor: pointer;
  font-size: .88rem;
  font-weight: 700;
}

.individual-picker-body { padding-top: 10px; }

.collection-loading {
  margin: 0;
  color: #596273;
  font-size: .88rem;
}

.shelf-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.shelf-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 6px 8px 6px 12px;
  border: 1px solid #e1e5ea;
  border-radius: 10px;
}

.shelf-card-add {
  min-width: 76px;
  font-size: .78rem;
}

.play-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.source-info { min-width: 0; }

.flashcard {
  min-height: 360px;
  scroll-margin-top: 12px;
  background: #fff;
  border: 1px solid #d9dde5;
  border-radius: 18px;
  padding: clamp(24px, 6vw, 44px);
  box-shadow: 0 8px 28px rgba(28, 36, 51, .08);
  display: grid;
  align-content: start;
  gap: 32px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: .9rem;
}

.mode-toggle {
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 1px solid #c7ccd4;
  border-radius: 999px;
  background: #f2f4f7;
}

.mode-toggle label {
  position: relative;
  cursor: pointer;
}

.mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-toggle span {
  display: block;
  min-width: 58px;
  padding: 5px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
}

.mode-toggle input:checked + span {
  background: #1d2433;
  color: #fff;
}

.card-label {
  margin: 0 0 6px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
}

.prompt,
.answer {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.3rem);
  font-weight: 700;
  line-height: 1.35;
}

.card-action {
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  font-weight: 700;
  font-size: 1.05rem;
}

.answer-wrap {
  padding-top: 28px;
  border-top: 1px solid #e3e6eb;
}

.next-action { margin-top: 24px; }

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.shortcut-hint,
.status { font-size: .86rem; }

.shortcut-hint {
  margin-top: 18px;
  color: #596273;
}

.status {
  min-height: 1.4em;
  font-weight: 700;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 820px);
    padding-top: 28px;
  }

  .practice-set-panel,
  .card-shelf {
    padding: 16px;
  }

  .practice-set-heading,
  .practice-group-heading,
  .play-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .practice-group-heading { gap: 4px; }

  .bundle-list,
  .shelf-card-list {
    grid-template-columns: 1fr;
  }

  .bundle-button { min-height: 66px; }

  .play-heading-row .secondary {
    width: 100%;
  }

  .flashcard {
    min-height: 330px;
    gap: 26px;
  }

  .secondary-actions {
    grid-template-columns: 1fr;
  }
}
