/* PC3.5 unified interaction system
   Tabs switch views. Buttons perform actions. Underlined text opens a source. */
:root{
  --ui-control-radius:10px;
  --ui-control-height:42px;
  --ui-tab-ink:#3f554d;
  --ui-tab-active:#163f34;
  --ui-tab-accent:#d98f20;
  --ui-action-primary:#173f34;
  --ui-action-primary-hover:#205244;
  --ui-action-surface:#fffdf8;
  --ui-action-border:#cfc5b3;
  --ui-focus:#e6a43c;
}

/* Shared keyboard treatment */
:is(button,a,select,input,[tabindex]):focus-visible{
  outline:3px solid rgba(230,164,60,.42);
  outline:3px solid color-mix(in srgb,var(--ui-focus) 42%,transparent);
  outline-offset:2px;
}

/* One tab language at every level */
.ui-tablist{min-width:0;}
.ui-tab{
  appearance:none!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  min-height:44px;
  padding:10px 14px 8px!important;
  border:0!important;
  border-bottom:3px solid transparent!important;
  border-radius:0!important;
  background:transparent!important;
  color:var(--ui-tab-ink)!important;
  font:750 .82rem/1.2 var(--font-ui)!important;
  text-align:center;
  text-decoration:none!important;
  white-space:nowrap;
  cursor:pointer;
  transition:background .15s ease,color .15s ease,border-color .15s ease;
}
.ui-tab:hover:not(:disabled){background:#f6f1e7!important;color:var(--ui-tab-active)!important;}
.ui-tab.active,.ui-tab[aria-selected="true"]{
  background:#fbf7ed!important;
  color:var(--ui-tab-active)!important;
  border-bottom-color:var(--ui-tab-accent)!important;
}
.ui-tab:disabled,.ui-tab[aria-disabled="true"]{opacity:.42!important;cursor:not-allowed!important;}

.subject-tabs{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  width:min(100%,760px)!important;
  gap:0!important;
}
.subject-tabs .ui-tab{width:100%;min-height:50px;font-size:.9rem!important;}
.subject-tabs .ui-tab+.ui-tab{border-left:1px solid #e4dccd!important;}

.subject-subtabs{
  display:flex!important;
  align-items:stretch!important;
  justify-content:center!important;
  width:min(100%,760px)!important;
  padding:0!important;
  gap:0!important;
  border-top:1px solid #ece4d7!important;
  background:#f9f6ef;
}
.subject-subtabs[hidden]{display:none!important;}
.subject-subtabs .ui-tab{
  flex:1 1 0;
  min-width:120px;
  min-height:40px;
  padding:8px 12px 7px!important;
  font-size:.72rem!important;
}
.subject-subtabs .ui-tab+.ui-tab{border-left:1px solid #e5ded1!important;}

.adult-tabs{
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:0!important;
  padding:0 18px!important;
  border-bottom:1px solid var(--rule)!important;
  background:#faf7f0;
}
.adult-tabs .ui-tab{width:100%;min-height:48px;padding:10px 8px 8px!important;font-size:.72rem!important;}
.adult-tabs .ui-tab+.ui-tab{border-left:1px solid #e5ded1!important;}
.pref-section[data-adult-pane][hidden]{display:none!important;}

.learning-tabs{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(92px,1fr));
  gap:0!important;
  margin-left:auto!important;
  border-bottom:1px solid rgba(255,255,255,.12);
}
.breadcrumb .learning-tabs .learning-tab{
  min-height:40px!important;
  padding:8px 15px 7px!important;
  border-radius:0!important;
  background:transparent!important;
  color:#c9d8d1!important;
  font-size:.74rem!important;
}
.breadcrumb .learning-tabs .learning-tab:hover:not(:disabled){background:rgba(255,255,255,.06)!important;color:#fff9eb!important;}
.breadcrumb .learning-tabs .learning-tab.active,
.breadcrumb .learning-tabs .learning-tab[aria-selected="true"]{
  background:rgba(232,163,61,.08)!important;
  color:#fff7e4!important;
  border-bottom-color:#efb44f!important;
}

/* Shared action language */
.ui-action{
  appearance:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:var(--ui-control-height);
  box-sizing:border-box;
  padding:9px 15px;
  border:1px solid transparent;
  border-radius:var(--ui-control-radius)!important;
  font:750 .8rem/1.25 var(--font-ui);
  text-align:center;
  text-decoration:none!important;
  cursor:pointer;
  transition:background .15s ease,border-color .15s ease,color .15s ease,transform .15s ease;
}
.ui-action:hover:not(:disabled){transform:translateY(-1px);}
.ui-action:disabled{opacity:.45;cursor:not-allowed;transform:none;}
.ui-action-primary{
  border-color:var(--ui-action-primary)!important;
  background:var(--ui-action-primary)!important;
  color:#fffaf0!important;
  box-shadow:0 4px 12px rgba(23,63,52,.14)!important;
}
.ui-action-primary:hover:not(:disabled){background:var(--ui-action-primary-hover)!important;border-color:var(--ui-action-primary-hover)!important;}
.ui-action-secondary{
  border-color:var(--ui-action-border)!important;
  background:var(--ui-action-surface)!important;
  color:#294c40!important;
  box-shadow:none!important;
}
.ui-action-secondary:hover:not(:disabled){background:#f3eee4!important;border-color:#ada08a!important;}
.ui-action-quiet{
  border-color:#d9d0c0!important;
  background:#f4efe5!important;
  color:#3b584e!important;
  box-shadow:none!important;
}
.ui-action-quiet:hover:not(:disabled){background:#ebe4d7!important;}
.ui-action-danger{
  border-color:#d8a99b!important;
  background:#fbebe6!important;
  color:#7b342b!important;
  box-shadow:none!important;
}
.ui-action-danger:hover:not(:disabled){background:#f5ddd6!important;border-color:#c28f80!important;}
.ui-action-compact{min-height:34px;padding:7px 11px;font-size:.72rem;}

.onboarding-card .ui-action{width:100%;min-height:50px;font-size:1rem;}
.onboarding-card .ui-action-primary{background:var(--ui-action-primary)!important;color:#fffaf0!important;}
.onboarding-card .ui-action-secondary{background:#fff!important;color:#273d36!important;}
.settings-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:10px 0;}
.settings-actions .ui-action{margin:0!important;}
.pa-btn.ui-action{padding:9px 14px;font-size:.78rem;}
.study-home-primary.ui-action{min-height:44px;padding:10px 18px;}
.chapter-change.ui-action{white-space:nowrap;}
.chapter-narration.ui-action{white-space:nowrap;}
.source-only-chapters.ui-action{padding:10px 14px;}
.foundation-continue.ui-action{min-height:44px;padding:10px 18px;}
.book-page-actions .ui-action{min-height:42px;padding:9px 16px;border-radius:var(--ui-control-radius)!important;}
.practice-answer-row .ui-action{min-height:42px;}
.hint-btn.ui-action{border-radius:var(--ui-control-radius)!important;}
.revisit-actions .ui-action{border-radius:var(--ui-control-radius)!important;}

/* Actions inside the chapter tree no longer masquerade as links */
.curriculum-chapter-action.ui-action{
  width:auto;
  min-height:32px;
  margin:3px 0 8px;
  padding:6px 10px!important;
  font-size:.7rem!important;
  text-decoration:none!important;
}
button.curriculum-topic.is-action{
  border:1px solid transparent;
  color:#35594c;
  font-weight:650;
}
button.curriculum-topic.is-action:hover,
button.curriculum-topic.is-action.current{
  border-color:#c8d7cf;
  background:#e8efe9;
  color:#204d3f;
}
.inline-check-review-link.ui-action{
  min-height:32px;
  padding:6px 9px!important;
  border-radius:8px!important;
  text-decoration:none!important;
}

/* External destinations always read as links, never as tabs or actions */
.ui-external-link{
  display:inline-flex!important;
  align-items:center;
  gap:4px;
  width:auto!important;
  min-height:28px;
  padding:2px 0!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
  color:#285d4c!important;
  font-weight:720!important;
  text-align:left!important;
  text-decoration:underline!important;
  text-decoration-thickness:1px!important;
  text-underline-offset:3px!important;
  cursor:pointer;
}
.ui-external-link:hover{color:#173f34!important;text-decoration-thickness:2px!important;}
.official-source-links{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 18px!important;}
.official-source-link.ui-external-link{font-size:.73rem!important;}
.source-only-open.ui-external-link{align-self:center;}
.subject-textbook-links{display:flex;align-items:center;justify-content:flex-end;gap:8px 12px;flex-wrap:wrap;}
.subject-textbook-links[hidden]{display:none!important;}
.subject-textbook-links .subject-textbook-link{font-size:.72rem!important;white-space:nowrap;}

/* The one intentional internal text link */
.ui-text-link{border:0!important;background:transparent!important;box-shadow:none!important;text-decoration:underline!important;text-underline-offset:3px!important;}

/* Dialog controls use one clear target size */
.modal-head .close-x{
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  margin:-8px -10px -8px auto;
  padding:0;
  border-radius:50%!important;
  touch-action:manipulation;
}
.modal-head .close-x:hover{background:rgba(255,255,255,.1)!important;}

/* Adult-guided class placement */
.class-setting-card{
  margin:0 0 18px;
  padding:14px;
  border:1px solid #d8cfbd;
  border-radius:12px;
  background:#f8f4ea;
}
.class-setting-card h4,.narration-settings-title{margin:0 0 6px;color:#244b3f;font:760 .86rem/1.3 var(--font-ui);}
.class-setting-row{display:grid;grid-template-columns:minmax(150px,1fr) auto;gap:8px;align-items:end;margin-top:8px;}
.class-setting-row select{width:100%;min-height:42px;margin:0!important;}
.class-setting-status{min-height:1.3em;margin-top:7px;color:#50675e;font:650 .7rem/1.45 var(--font-ui);}
.narration-settings-title{margin-top:2px;}

/* Whole-chapter narration stays in the active chapter context. */
.breadcrumb .chapter-narration.ui-action{
  min-height:34px!important;
  border-color:rgba(239,191,98,.5)!important;
  background:rgba(232,163,61,.08)!important;
  color:#f2c46e!important;
  font-size:.68rem!important;
}
.breadcrumb .chapter-narration.ui-action:hover:not(:disabled){background:rgba(232,163,61,.19)!important;border-color:#efbf62!important;}
.breadcrumb .chapter-narration.ui-action.is-narrating{background:#f2c46e!important;border-color:#f2c46e!important;color:#183f34!important;}
.breadcrumb .chapter-narration.ui-action:disabled{opacity:.52!important;}

/* Optional, age-aware student learning guide. */
.learning-guide-entry{white-space:nowrap;}
.learning-guide-modal{
  width:min(900px,calc(100vw - 32px));
  max-width:900px;
  max-height:min(88vh,820px);
  background:#fbf8f0;
}
.learning-guide-modal .modal-head{flex:0 0 auto;padding:13px 20px;}
.learning-guide-modal .modal-head>div{display:flex;flex-direction:column;gap:2px;min-width:0;}
.learning-guide-modal .modal-kicker{
  color:#efc775;
  font:760 .6rem/1.2 var(--font-ui);
  letter-spacing:.1em;
  text-transform:uppercase;
}
.learning-guide-context{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
  padding:9px 22px;
  border-bottom:1px solid #ded5c5;
  background:#f1ebde;
  color:#3c554c;
  font:670 .7rem/1.3 var(--font-ui);
}
.learning-guide-context strong{color:#1f4b3e;font-weight:790;}
.learning-guide-context span::before{content:'·';padding-right:8px;color:#aa8b4f;}
.learning-guide-body{
  overflow-y:auto;
  padding:20px 22px 26px;
  color:#34483f;
  font:500 .82rem/1.58 var(--font-ui);
  overscroll-behavior:contain;
}
.learning-guide-body section{margin:0 0 25px;}
.learning-guide-body p{margin:0;}
.learning-guide-intro>p{max-width:780px;color:#4e5f57;font-size:.86rem;line-height:1.65;}
.learning-guide-choice-note{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:5px 9px;
  align-items:start;
  margin-top:12px;
  padding:10px 12px;
  border:1px solid #c9d9cf;
  border-radius:10px;
  background:#edf4ef;
  color:#4a6258;
}
.learning-guide-choice-note strong{color:#24523f;}
.learning-guide-section-heading{display:flex;flex-direction:column;gap:2px;margin:0 0 10px;}
.learning-guide-section-heading>span{
  color:#8a6b34;
  font:800 .6rem/1.2 var(--font-ui);
  letter-spacing:.085em;
  text-transform:uppercase;
}
.learning-guide-section-heading h3{margin:0;color:#213f35;font:780 1rem/1.3 var(--font-display);}
.learning-guide-cards{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;}
.learning-guide-cards article{
  display:flex;
  align-items:flex-start;
  gap:9px;
  min-width:0;
  padding:11px;
  border:1px solid #ddd4c5;
  border-radius:11px;
  background:#fffdf8;
}
.learning-guide-cards article>span,.learning-guide-simplify li>span,.learning-guide-qna summary>span{
  display:grid;
  place-items:center;
  flex:0 0 24px;
  width:24px;
  height:24px;
  border-radius:50%;
  background:#1f4b3e;
  color:#fff9e9;
  font:800 .64rem/1 var(--font-ui);
}
.learning-guide-cards h4{margin:0 0 3px;color:#29483d;font:780 .76rem/1.25 var(--font-ui);}
.learning-guide-cards p{color:#627068;font-size:.72rem;line-height:1.45;}
.learning-guide-body section>ul{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px 24px;margin:0;padding:0;list-style:none;}
.learning-guide-body section>ul li{position:relative;padding:7px 8px 7px 20px;border-bottom:1px solid #e8e1d5;color:#475b52;}
.learning-guide-body section>ul li::before{content:' ';position:absolute;left:3px;top:14px;width:7px;height:7px;border-radius:50%;background:#d9952e;}
.learning-guide-simplify ol{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin:0;padding:0;list-style:none;counter-reset:none;}
.learning-guide-simplify li{display:flex;align-items:flex-start;gap:9px;padding:9px 10px;border-radius:10px;background:#f0ecdf;}
.learning-guide-simplify li>span{background:#be7a1b;color:#fff;}
.learning-guide-simplify li p{padding-top:2px;color:#47584f;}
.learning-guide-facts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
.learning-guide-facts article{display:flex;align-items:flex-start;gap:9px;padding:11px 12px;border-left:3px solid #dda042;border-radius:8px;background:#fff9ed;color:#4d5e56;}
.learning-guide-facts article>span{color:#b66f12;font-size:.78rem;line-height:1.55;}
.learning-guide-section-note{margin:-3px 0 10px!important;color:#66736d;font-size:.72rem;}
.learning-guide-qna>div:last-child{display:grid;gap:7px;}
.learning-guide-qna details{border:1px solid #d8d0c1;border-radius:10px;background:#fffdf8;overflow:hidden;}
.learning-guide-qna summary{display:flex;align-items:center;gap:9px;padding:10px 12px;color:#29493e;font-weight:720;cursor:pointer;list-style:none;}
.learning-guide-qna summary::-webkit-details-marker{display:none;}
.learning-guide-qna summary::after{content:'+';margin-left:auto;color:#8d713d;font-size:1rem;}
.learning-guide-qna details[open] summary{border-bottom:1px solid #e3dccf;background:#f6f1e7;}
.learning-guide-qna details[open] summary::after{content:'−';}
.learning-guide-qna details>p{padding:10px 14px 12px 45px;color:#4f6158;}
.learning-guide-reflect>div:last-child{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;}
.learning-guide-reflect>div:last-child p{padding:11px 12px;border:1px dashed #bea874;border-radius:10px;background:#f8f3e8;color:#4d5e56;}
.learning-guide-boundary{padding:12px 14px;border-top:1px solid #ddd3c1;color:#68736e;font-size:.72rem;line-height:1.55;}
.learning-guide-basis{margin-top:12px;padding:10px 12px;border:1px solid #d9cfbc;border-radius:10px;background:#f8f4ea;color:#53635b;font-size:.72rem;}
.learning-guide-basis summary{color:#31564a;font-weight:760;cursor:pointer;}
.learning-guide-basis p{margin:8px 0!important;line-height:1.55;}
.learning-guide-source-links{margin-top:6px;}

/* Direct official-book PDF index. */
.book-pdf-modal{width:min(94vw,760px);max-height:min(88dvh,820px);overflow:hidden;}
.book-pdf-modal .modal-head>div{display:flex;flex-direction:column;gap:2px;min-width:0;}
.book-pdf-modal .modal-kicker{color:#d9ae61;font:800 .58rem/1.2 var(--font-ui);letter-spacing:.09em;text-transform:uppercase;}
.book-pdf-context{margin:0;padding:12px 18px;border-bottom:1px solid #ddd4c5;background:#f7f2e8;color:#53645c;font-size:.76rem;line-height:1.5;}
.book-pdf-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-height:52dvh;padding:14px 18px;overflow:auto;}
.book-pdf-row{display:grid;grid-template-columns:auto 1fr;align-items:start;gap:2px 10px;padding:11px 12px;border:1px solid #ddd4c5;border-radius:10px;background:#fffdf8;color:#234c3e!important;text-decoration:none!important;}
.book-pdf-row:hover{border-color:#c89543;background:#fff9ec;}
.book-pdf-row span{grid-row:1 / span 2;color:#8a6b34;font:800 .62rem/1.35 var(--font-ui);letter-spacing:.035em;text-transform:uppercase;}
.book-pdf-row strong{min-width:0;font:760 .78rem/1.35 var(--font-ui);}
.book-pdf-row small{grid-column:2;color:#65756d;font:650 .66rem/1.3 var(--font-ui);}
.book-download-area{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 18px;border-top:1px solid #ddd4c5;background:#f7f2e8;color:#3d594f;font-size:.72rem;}
.book-download-list{display:flex;justify-content:flex-end;gap:8px 14px;flex-wrap:wrap;}
.book-download-link{color:#285d4c!important;font-weight:750;text-underline-offset:3px;}

/* A readable, structured product footer. */
.app-footer{
  display:flex!important;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:3px;
  min-height:44px;
  padding:7px 14px calc(7px + env(safe-area-inset-bottom))!important;
  color:#b6c9c0!important;
  font:560 .66rem/1.35 var(--font-ui)!important;
  letter-spacing:.01em!important;
}
.footer-product,.footer-meta{display:flex;align-items:center;justify-content:center;gap:6px;flex-wrap:wrap;text-align:center;}
.footer-product strong{color:#d7e5de;font-weight:760;}
.footer-product>span{color:#b8cbc2;}
.footer-product>span>span{color:#e6a43c;padding:0 2px;}
.footer-meta{color:#91aaa0;}
.footer-meta a{color:#bad0c6;font-weight:700;text-decoration:underline;text-underline-offset:2px;}
.footer-meta a:hover{color:#e1eee8;}

@media(max-width:760px){
  .subject-tabs .ui-tab{min-height:44px;font-size:.8rem!important;}
  .subject-subtabs{justify-content:flex-start!important;overflow-x:auto!important;scrollbar-width:none;}
  .subject-subtabs .ui-tab{flex:1 0 128px;}
  .adult-tabs{display:flex!important;overflow-x:auto;padding:0 10px!important;scrollbar-width:none;}
  .adult-tabs .ui-tab{flex:1 0 150px;}
  .breadcrumb .learning-tabs{width:100%!important;margin:0!important;}
  .breadcrumb .learning-tabs .learning-tab{width:100%!important;}
  .settings-actions{display:grid;grid-template-columns:1fr;}
  .settings-actions .ui-action{width:100%;}
  .class-setting-row{grid-template-columns:1fr;}
  .class-setting-row .ui-action{width:100%;}
  .official-source-links{grid-template-columns:1fr;}
  .learning-guide-modal{width:100vw;max-width:none;max-height:100dvh;height:100dvh;border-radius:0;}
  .learning-guide-modal .modal-head{padding:12px 15px;}
  .learning-guide-context{padding:8px 15px;}
  .learning-guide-body{padding:17px 15px 24px;}
  .learning-guide-cards{grid-template-columns:repeat(2,minmax(0,1fr));}
  .learning-guide-reflect>div:last-child{grid-template-columns:1fr;}
  .book-pdf-modal{width:100vw;max-width:none;max-height:100dvh;height:100dvh;border-radius:0;}
  .book-pdf-list{grid-template-columns:1fr;max-height:calc(100dvh - 205px);padding:12px 14px;}
  .book-download-area{align-items:flex-start;flex-direction:column;padding:11px 14px;}
  .book-download-list{justify-content:flex-start;}
}

@media(max-width:480px){
  .course-book-actions{align-items:center!important;gap:10px!important;}
  .subject-textbook-links{justify-content:flex-start;gap:4px 10px;}
  .subject-textbook-links .subject-textbook-link{white-space:normal;}
  .learning-guide-entry{white-space:normal;}
  .ui-external-link{white-space:normal!important;}
  .source-only-actions{display:grid!important;grid-template-columns:1fr!important;}
  .source-only-open.ui-external-link{justify-self:start;align-self:start;}
  .study-switches{flex-wrap:wrap;justify-content:flex-end;}
  .app-footer{font-size:.61rem!important;padding-left:10px!important;padding-right:10px!important;}
  .learning-guide-body section>ul,.learning-guide-simplify ol,.learning-guide-facts{grid-template-columns:1fr;}
  .learning-guide-cards{grid-template-columns:1fr;}
  .learning-guide-choice-note{grid-template-columns:1fr;}
  .learning-guide-qna details>p{padding-left:14px;}
}
