/* In-context AI dictionary. Inline side float occupies layout space, never covers a lesson. */
.kedict-toolbar{display:flex;align-items:center;justify-content:flex-end;gap:8px;position:relative;z-index:1;margin:0 0 12px;clear:both}
.kedict-open-button{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:40px;padding:9px 13px!important;background:#f0e8ff!important;color:#6023b3!important;border:1px solid #d8c4f6!important;border-radius:12px!important;font:700 13px/1.3 Inter,system-ui,sans-serif!important;cursor:pointer}
.kedict-open-button span{font-size:11px;font-weight:500;color:#765f9e}
.kedict-open-button:hover,.kedict-open-button:focus-visible{background:#e5d4ff!important}
.kedict-panel{float:right;width:min(330px,43%);max-width:100%;margin:0 0 20px 20px;padding:16px;border:1px solid #dac9ef;border-radius:17px;background:#fcfaff;color:#261a3c;box-shadow:0 3px 18px #38145e14;font:400 13px/1.55 Inter,system-ui,sans-serif;overflow-wrap:anywhere}
.kedict-panel[hidden],.kedict-result[hidden]{display:none!important}
.kedict-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
.kedict-head small{display:block;color:#7854aa;font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.kedict-head h2{color:#4e178d!important;margin:4px 0 10px!important;font-size:21px!important;line-height:1.2!important}
.kedict-close{border:1px solid #e2d7ee;background:#fff;color:#563077;width:34px;height:34px;border-radius:9px;font-size:22px;line-height:1;cursor:pointer}
.kedict-intro{margin:0 0 16px;color:#665976;font-size:12px;line-height:1.6}
.kedict-word-label{display:block;font-weight:700;font-size:12px;color:#352450}
.kedict-word-label input{display:block;width:100%;min-height:42px;margin:7px 0 12px;border:1px solid #d2bfea;border-radius:9px;background:#fff;color:#241739;padding:10px 12px;font-size:14px;outline-offset:2px}
.kedict-consent{display:flex;align-items:flex-start;gap:8px;font-weight:550;font-size:11px;line-height:1.4;color:#675576;margin-bottom:12px;cursor:pointer}
.kedict-consent input{width:17px;height:17px;flex:none;accent-color:#752cd0;margin:0}
.kedict-submit{display:block;width:100%;min-height:42px;border:0;border-radius:10px;background:#6924bd;color:#fff;font-size:13px;font-weight:800;cursor:pointer}
.kedict-submit:disabled{opacity:.5;cursor:wait}
.kedict-status{font-size:11px;color:#6a557b;line-height:1.5;margin:12px 0}
.kedict-result{margin-top:12px;padding-top:12px;border-top:1px solid #e5dcef}
.kedict-result h3{margin:0 0 8px!important;color:#4d178c!important;font-size:20px!important}
.kedict-result strong{display:block;color:#4c2780;font-size:12px;margin-top:10px}
.kedict-result p{color:#30243e;margin:4px 0 10px;font-size:13px;line-height:1.65;white-space:normal!important}
.kedict-open .kedict-toolbar{clear:none}
#keduAsk .kedu-chat-answer .kedict-toolbar{margin:0 0 12px}
#keduAsk .kedu-chat-answer .kedict-open-button{font-size:12px}
#keduAsk .kedu-chat-answer .kedict-panel{width:min(300px,48%)}
@media(max-width:760px){
 .kedict-panel,#keduAsk .kedu-chat-answer .kedict-panel{float:none;width:100%;max-width:100%;margin:0 0 16px;padding:14px}
 .kedict-toolbar{justify-content:flex-start}
 .kedict-open-button span{display:none}
}
@media(min-width:761px) and (max-width:950px){.kedict-panel{width:min(300px,45%)}}
@media print{.kedict-toolbar,.kedict-panel{display:none!important}}

/* Companion reading panel: pinned beside the document while its conversation scrolls. */
@media(min-width:761px){
 .kedict-panel:not([hidden]){position:sticky;top:94px;max-height:calc(100dvh - 112px);min-height:280px;display:flex;flex-direction:column;overflow:hidden;z-index:5}
 .kedict-chat-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:12px 14px}
}
.kedict-panel:not([hidden]){padding:0}
.kedict-head{padding:15px 16px 9px;border-bottom:1px solid #e8dff3;flex-shrink:0}
.kedict-chat-scroll{padding:12px 16px;overflow-y:auto;min-height:90px;flex:1}
.kedict-composer{flex-shrink:0;padding:12px;border-top:1px solid #e8dff3;background:#fff}
.kedict-composer .kedict-word-label{font-size:11px;color:#75658b;margin-bottom:6px}
.kedict-input-row{display:flex;align-items:flex-end;border:1px solid #d2bfea;border-radius:17px;background:#fff;padding:6px;gap:8px}
.kedict-input-row:focus-within{border-color:#7431cb;box-shadow:0 0 0 2px #7431cb1a}
.kedict-word-label textarea{display:block;flex:1;min-width:0;width:100%;height:38px;max-height:120px;border:0;resize:none;outline:0;padding:9px;background:transparent;color:#241739;font:400 13px/1.45 Inter,system-ui,sans-serif}
.kedict-input-row .kedict-submit{flex:none;width:38px;height:38px;min-height:38px;border-radius:50%;font-size:20px;display:grid;place-items:center}
.kedict-composer .kedict-consent{margin:10px 0 4px}
.kedict-composer>small{display:block;color:#80748b;font-size:10px}
.kedict-panel .kedict-intro{background:#f5effd;padding:12px;border-radius:12px}
.kedict-panel .kedict-result{margin:0;border:0;background:#f9f7fd;border-radius:14px;padding:13px}
@media(max-width:760px){
 .kedict-panel:not([hidden]){position:relative;top:auto;display:flex;flex-direction:column;max-height:480px;overflow:hidden}
 .kedict-chat-scroll{min-height:95px;max-height:260px}
 .kedict-composer{padding:10px}
}
@media print{.kedict-panel:not([hidden]){position:static;max-height:none}}

/* iPad/Safari: give the open dictionary an actual scroll-containing reading block.
   Keep it in the right column rather than a modal over the lesson. */
@media(min-width:761px){
 .kdr-reading.kedict-open,.klr-reading.kedict-open,.mc-ai-lesson-paper.kedict-open,.km-detail-content.kedict-open,.kedu-material-reader.kedict-open{
   display:flow-root;min-height:calc(100dvh - 125px);
 }
 .kedict-open>.kedict-toolbar{position:relative;z-index:1;clear:none}
 .kedict-panel:not([hidden]){float:right;position:-webkit-sticky;position:sticky;top:105px;align-self:start;max-height:calc(100dvh - 122px);margin-left:20px}
}
@media(max-width:760px){
 .kedict-panel:not([hidden]){position:relative;float:none;margin:0 0 16px;width:100%;max-height:min(480px,75dvh)}
}

/* Fixed AI Dictionary launcher, visually paired with the existing Guide pill.
   It sits one row above Guide and is not a child of the scrolling lesson. */
.kedict-floating-launch{
 position:fixed!important;right:22px!important;bottom:calc(88px + env(safe-area-inset-bottom))!important;
 z-index:2147482999!important;display:inline-flex;align-items:center;justify-content:center;
 gap:8px;min-height:49px;padding:11px 17px!important;border-radius:999px!important;
 border:1px solid #a678f7!important;background:linear-gradient(115deg,#4d0f97,#7d30de)!important;
 color:#fff!important;box-shadow:0 7px 24px #3813764d;
 font:700 14px/1.2 Inter,system-ui,sans-serif!important;cursor:pointer;
}
.kedict-floating-launch[hidden]{display:none!important}
.kedict-floating-launch .kedict-floating-icon{width:26px;height:26px;display:grid;place-items:center;
 border:1.5px solid #edddff;border-radius:50%;font-size:16px}
.kedict-floating-launch:focus-visible{outline:3px solid #b998ff;outline-offset:3px}
.kedict-floating-launch.is-open{background:linear-gradient(115deg,#6023a4,#8b45e9)!important}
.kedict-toolbar{display:none!important}
@media(max-width:760px){
 .kedict-floating-launch{right:16px!important;bottom:calc(82px + env(safe-area-inset-bottom))!important;
 padding:9px 13px!important;min-height:46px;font-size:12px!important}
 .kedict-floating-launch .kedict-floating-icon{height:24px;width:24px;font-size:14px}
}
@media print{.kedict-floating-launch{display:none!important}}


/* Portal the open dictionary to the viewport: fixed on iPad Safari and desktop,
   with a separate scrolling conversation and the message composer always visible. */
.kedict-panel.kedict-floating-panel:not([hidden]),
#keduAsk .kedu-chat-answer .kedict-panel.kedict-floating-panel:not([hidden]){
 position:fixed!important;
 top:auto!important;
 left:auto!important;
 right:22px!important;
 bottom:calc(88px + env(safe-area-inset-bottom))!important;
 width:min(370px,calc(100vw - 32px))!important;
 max-width:calc(100vw - 32px)!important;
 height:min(570px,calc(100dvh - 185px))!important;
 min-height:0!important;
 max-height:calc(100dvh - 185px)!important;
 float:none!important;
 display:flex!important;
 flex-direction:column;
 overflow:hidden!important;
 margin:0!important;
 padding:0!important;
 border-radius:20px!important;
 background:#fcfaff;
 z-index:2147482999!important;
 box-shadow:0 15px 45px #25104936;
}
.kedict-panel.kedict-floating-panel .kedict-chat-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain}
.kedict-panel.kedict-floating-panel .kedict-composer{flex-shrink:0}
@media(max-width:760px){
 .kedict-panel.kedict-floating-panel:not([hidden]),
 #keduAsk .kedu-chat-answer .kedict-panel.kedict-floating-panel:not([hidden]){
  right:12px!important;
  bottom:calc(82px + env(safe-area-inset-bottom))!important;
  width:min(360px,calc(100vw - 24px))!important;
  max-width:calc(100vw - 24px)!important;
  height:min(490px,calc(100dvh - 170px))!important;
  max-height:calc(100dvh - 170px)!important;
 }
}
@media print{.kedict-panel.kedict-floating-panel{display:none!important}}


/* Match the approved iPad layout: text remains usable beside the floating
   dictionary and the ChatGPT-style composer fills the entire input row. */
.kedict-panel.kedict-floating-panel .kedict-composer,
.kedict-panel.kedict-floating-panel .kedict-input-row,
.kedict-panel.kedict-floating-panel .kedict-input-row *{box-sizing:border-box}
.kedict-panel.kedict-floating-panel .kedict-input-row{
 display:flex!important;flex-direction:row!important;align-items:flex-end!important;
 flex-wrap:nowrap!important;width:100%!important;min-height:54px;gap:8px;
}
.kedict-panel.kedict-floating-panel .kedict-input-row textarea[data-kedict-word]{
 appearance:none;display:block!important;position:static!important;flex:1 1 0%!important;
 width:0!important;min-width:0!important;max-width:none!important;
 height:38px;min-height:38px!important;max-height:120px!important;
 margin:0!important;padding:9px 10px!important;border:0!important;
 border-radius:10px;background:transparent!important;box-shadow:none!important;
 font:400 14px/1.45 Inter,system-ui,sans-serif!important;color:#241739!important;
 resize:none;overflow-y:auto;
}
.kedict-panel.kedict-floating-panel .kedict-input-row .kedict-submit{
 position:static!important;flex:0 0 40px!important;width:40px!important;max-width:40px!important;
 height:40px!important;min-height:40px!important;max-height:40px!important;
 padding:0!important;margin:0!important;line-height:1!important;
 border-radius:50%!important;display:grid!important;place-items:center!important;
}
.kedict-panel.kedict-floating-panel .kedict-composer{min-width:0;width:100%}
.kedict-panel.kedict-floating-panel .kedict-head{padding-top:14px}
@media(min-width:980px){
 body.kedu-app.kedict-docked .ke-content{
  padding-right:clamp(390px,31vw,460px)!important;
  box-sizing:border-box;transition:padding-right .16s ease;
 }
}
@media(min-width:761px) and (max-width:979px){
 .kedict-panel.kedict-floating-panel:not([hidden]){
  width:min(315px,calc(100vw - 32px))!important;
  height:min(460px,calc(100dvh - 185px))!important;
 }
}
@media(max-width:760px){
 .kedict-panel.kedict-floating-panel .kedict-input-row textarea[data-kedict-word]{font-size:16px!important}
}


/* Compact iPad Split View: keep utility controls off the bottom study actions.
   Safari can be 700-950 CSS pixels wide even on a landscape iPad. */
@media (max-width:979px){
 body.kedu-app .ksg-root .ksg-launch{
  position:fixed!important;
  top:calc(88px + env(safe-area-inset-top,0px))!important;
  bottom:auto!important;
  right:12px!important;
  width:48px!important;
  height:48px!important;
  min-height:48px!important;
  padding:6px!important;
  border-radius:50%!important;
  font-size:0!important;
  display:flex!important;
  justify-content:center!important;
  align-items:center!important;
 }
 body.kedu-app .ksg-root .ksg-launch span{
  width:30px!important;height:30px!important;font-size:19px!important;
 }
 body.kedu-app .kedict-floating-launch:not([hidden]){
  top:calc(145px + env(safe-area-inset-top,0px))!important;
  bottom:auto!important;
  right:12px!important;
  width:48px!important;
  height:48px!important;
  min-width:48px!important;
  min-height:48px!important;
  padding:6px!important;
  border-radius:50%!important;
  justify-content:center!important;
 }
 body.kedu-app .kedict-floating-launch .kedict-floating-icon{
  width:30px!important;height:30px!important;font-size:18px!important;
 }
 body.kedu-app .kedict-floating-launch > span:last-child{display:none!important}
 body.kedu-app .kedict-panel.kedict-floating-panel:not([hidden]){
  top:calc(145px + env(safe-area-inset-top,0px))!important;
  bottom:auto!important;
  right:12px!important;
  max-height:calc(100dvh - 165px - env(safe-area-inset-top,0px))!important;
  height:min(440px,calc(100dvh - 165px - env(safe-area-inset-top,0px)))!important;
 }
}
@media (max-width:700px){
 body.kedu-app .ksg-root .ksg-launch{
  top:calc(77px + env(safe-area-inset-top,0px))!important;
 }
 body.kedu-app .kedict-floating-launch:not([hidden]),
 body.kedu-app .kedict-panel.kedict-floating-panel:not([hidden]){
  top:calc(132px + env(safe-area-inset-top,0px))!important;
 }
 body.kedu-app .kedict-panel.kedict-floating-panel:not([hidden]){
  height:min(400px,calc(100dvh - 150px - env(safe-area-inset-top,0px)))!important;
  max-height:calc(100dvh - 150px - env(safe-area-inset-top,0px))!important;
 }
}
@media (max-width:979px) and (max-height:530px){
 body.kedu-app .kedict-panel.kedict-floating-panel:not([hidden]){
  top:80px!important;
  height:calc(100dvh - 95px)!important;
  max-height:calc(100dvh - 95px)!important;
 }
}


/* Never let a Split View utility control stretch into a pill or oval.
   Fixed physical dimensions and aspect ratio override inherited button sizing. */
@media (max-width:1100px){
 body.kedu-app .ksg-root .ksg-launch,
 body.kedu-app .kedict-floating-launch:not([hidden]){
  box-sizing:border-box!important;
  inline-size:48px!important;block-size:48px!important;
  width:48px!important;height:48px!important;
  min-width:48px!important;min-height:48px!important;
  max-width:48px!important;max-height:48px!important;
  flex:0 0 48px!important;aspect-ratio:1 / 1!important;
  border-radius:50%!important;padding:0!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  flex-wrap:nowrap!important;gap:0!important;
  font-size:0!important;line-height:0!important;white-space:nowrap!important;
  overflow:hidden!important;transform:none!important;
 }
 body.kedu-app .ksg-root .ksg-launch > span,
 body.kedu-app .kedict-floating-launch .kedict-floating-icon{
  box-sizing:border-box!important;
  inline-size:30px!important;block-size:30px!important;
  width:30px!important;height:30px!important;
  min-width:30px!important;min-height:30px!important;
  flex:0 0 30px!important;
  aspect-ratio:1 / 1!important;border-radius:50%!important;
  display:grid!important;place-items:center!important;
  font-size:18px!important;line-height:1!important;
 }
 body.kedu-app .kedict-floating-launch > span:last-child{display:none!important}
}


/* Recovery control stays in the conversation area, not over the reading. */
.kedict-retry{display:inline-flex;align-items:center;justify-content:center;min-height:38px;
 padding:8px 13px;margin:3px 0 12px;border:1px solid #bca0e9;border-radius:10px;
 background:#f1e9ff;color:#5d239e;font:700 12px/1.35 Inter,system-ui,sans-serif;cursor:pointer}
.kedict-retry[hidden]{display:none!important}
.kedict-retry:focus-visible{outline:3px solid #b998ff;outline-offset:2px}

/* The dictionary launcher moves like Guide without dragging the reading page. */
.kedict-floating-launch[data-kedict-movable]{touch-action:none;user-select:none;-webkit-user-select:none;cursor:grab}
.kedict-floating-launch[data-kedict-movable].is-dragging{cursor:grabbing;transition:none!important}


/* Meaning / Ask AI response selector */
.kedict-mode-switch{display:grid;grid-template-columns:1fr 1fr;gap:6px;padding:4px;background:#f1ecf9;border:1px solid #e6dcf5;border-radius:11px;margin:0 0 10px}.kedict-mode-switch button{min-width:0;min-height:48px;border:1px solid transparent;border-radius:8px;background:transparent;color:#574469;padding:6px 5px;text-align:center;cursor:pointer;font:inherit}.kedict-mode-switch button strong,.kedict-mode-switch button small{display:block;line-height:1.35}.kedict-mode-switch button strong{font-size:12px;font-weight:750}.kedict-mode-switch button small{font-size:10px;margin-top:3px;color:#6c5a82}.kedict-mode-switch button[aria-pressed=true]{color:#5b21b6;border-color:#d7c4f1;background:#fff;box-shadow:0 1px 3px #45217812}.kedict-mode-switch button:focus-visible{outline:2px solid #8b5cf6;outline-offset:2px}.kedict-mode-switch button:disabled{opacity:.65;cursor:wait}.kedict-composer-meta{display:flex!important;justify-content:space-between;gap:6px;align-items:center}.kedict-answer-mode{display:inline-block;background:#f0e9fb;color:#5b21b6;font-size:10px;font-weight:700;padding:5px 8px;border-radius:7px;margin-bottom:9px}.kedict-result .kedict-detail-section{margin:14px 0;padding:12px 0 0;border-top:1px solid #eee5f5}.kedict-detail-section h4{font-size:13px;color:#43276a;margin:0 0 7px}.kedict-result p{white-space:pre-wrap;overflow-wrap:anywhere}.kedict-result h3{overflow-wrap:anywhere}

.kedict-composer-meta [data-kedict-count]{white-space:nowrap;font-variant-numeric:tabular-nums}.kedict-composer-meta .kedict-over-limit{color:#b42342;font-weight:750}.kedict-input-row textarea[aria-invalid=true]{outline-color:#b42342!important}
