/* Math child desktop palette. The native workspace owns all layout and controls. */
@media (min-width: 1024px) {
  body:has(> #childWorkspace:not(.hidden)) {
    --block-ink: #342619;
    --block-muted: #695642;
    --block-paper: #fff9ed;
    --block-surface: #f4e8d5;
    --block-edge: #be9a6c;
    --block-wood: #583521;
    --block-green: #456922;
    --block-leaf: #d3e8ae;
    --block-focus: #394e1d;
    --block-landscape: url("/assets/theme-block/landscape.webp");
    --block-avatars: url("/assets/theme-block/avatars.webp");
    color: var(--block-ink);
    background: #b5d796 var(--block-landscape) center bottom / cover fixed;
  }

  body:has(> #childWorkspace:not(.hidden)) > .topbar {
    background:
      repeating-linear-gradient(0deg, transparent 0 7px, #23160d1f 7px 8px, transparent 8px 11px),
      linear-gradient(#754d31, var(--block-wood));
    color: #fff6e6;
    border-bottom-color: #bd9159;
    box-shadow: inset 0 -3px #c2935d, inset 0 -5px #805435;
  }

  body:has(> #childWorkspace:not(.hidden)) > .topbar :is(.brand, .brand span, .sub, #identity) {
    color: inherit;
  }

  body:has(> #childWorkspace:not(.hidden)) > .topbar :is(button, .badge) {
    background-color: #faecd8;
    color: var(--block-ink);
    border-color: #b68b60;
    border-radius: 6px;
  }

  body:has(> #childWorkspace:not(.hidden)) .ctm-panel {
    background-color: var(--block-paper);
    border-color: var(--block-edge);
    border-radius: 8px;
  }

  body:has(> #childWorkspace:not(.hidden)) .ctm-panel .ctm-option[aria-checked="true"] {
    background-color: var(--block-leaf);
    border-color: #8aa063;
    color: #2f401d;
  }

  body:has(> #childWorkspace:not(.hidden)) .ctm-panel .ctm-option:not(:disabled):hover {
    background-color: #e4edcf;
  }

  body:has(> #childWorkspace:not(.hidden)) #subject-switch {
    background: #43291e;
    border-color: #997050;
    border-radius: 7px;
  }

  body:has(> #childWorkspace:not(.hidden)) #subject-switch > a {
    color: #fff2db;
    border-radius: 5px;
  }

  body:has(> #childWorkspace:not(.hidden)) #subject-switch > a:hover:not([aria-current]) {
    background: #78553a;
  }

  body:has(> #childWorkspace:not(.hidden)) #subject-switch > a[aria-current="page"] {
    background: linear-gradient(#dbeeb8, #b9d78a);
    color: #2c401c;
    box-shadow: inset 0 -2px #74934c;
  }

  #childWorkspace:not(.hidden) {
    color: var(--block-ink);
  }

  #childWorkspace .child-layout-toolbar,
  #childWorkspace > .panel,
  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog) {
    background-color: var(--block-paper);
    color: var(--block-ink);
    border-color: var(--block-edge);
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px #ebd4b5, 0 2px #9b79452b;
  }

  #childWorkspace .child-layout-toolbar {
    background-color: #f8e8cff2;
  }

  #childWorkspace > .panel {
    border-radius: 5px;
    box-shadow: inset 0 0 0 2px #ecd0a7, inset 0 0 0 4px #faf0de, 0 2px #513c26a6;
  }

  #childWorkspace #childStudyActions {
    background: #f8edd9;
    border-color: #dfc9a6;
  }

  #childWorkspace :is(.muted, .child-layout-location, .paper-zoom-level, .paper-zoom-hint, .child-picker-current) {
    color: var(--block-muted);
  }

  #childWorkspace :is(.image-wrap.paper-zoom-surface, #childStudyActions, .child-question-context-content),
  body:has(> #childWorkspace:not(.hidden)) .paper-zoom-dialog > .paper-zoom-surface {
    background-color: #eee6d7;
    border-color: #ddc9ad;
  }

  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog)::backdrop {
    background: #2f21195e;
  }

  body:has(> #childWorkspace:not(.hidden)) :is(.child-drawer-heading, .paper-zoom-dialog > header, .paper-zoom-dialog > footer) {
    background-color: #f4e8d5;
    border-color: #ddc9ad;
    color: var(--block-ink);
  }

  #childWorkspace button:not(.primary):not(:disabled),
  #childWorkspace .chat-tool-menu > summary,
  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog) button:not(.primary):not(:disabled) {
    color: var(--block-ink);
    background-color: #fff8eb;
    border-color: var(--block-edge);
    border-radius: 6px;
  }

  #childWorkspace button:not(.primary):not(:disabled):hover,
  #childWorkspace .chat-tool-menu > summary:hover,
  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog) button:not(.primary):not(:disabled):hover {
    background-color: #f0dfc4;
  }

  #childWorkspace :is(.page-tabs, .question-list) button.active,
  body:has(> #childWorkspace:not(.hidden)) #childTasksDrawer button.active,
  #childWorkspace button[aria-pressed="true"]:not(#childLayoutToggle):not(:disabled) {
    background-color: var(--block-leaf);
    border-color: #8aa063;
    color: #2f401d;
  }

  #childWorkspace button.primary:not(:disabled),
  body:has(> #childWorkspace:not(.hidden)) #childTasksDrawer button.primary:not(:disabled) {
    background: linear-gradient(#52792b, var(--block-green));
    color: #fff;
    border-color: #3d5d20;
    border-radius: 6px;
    box-shadow: inset 0 -2px #344c20;
  }

  #childWorkspace button.primary:not(:disabled):hover,
  body:has(> #childWorkspace:not(.hidden)) #childTasksDrawer button.primary:not(:disabled):hover {
    background: #3b5c1e;
  }

  #childWorkspace button:disabled,
  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog) button:disabled {
    background: #ebe1d0;
    color: #625a4c;
    border-color: #cbbca5;
  }

  #childWorkspace :is(#childProgressShortcut, #childExplanationBtn) {
    color: #394b25;
  }

  #childWorkspace progress,
  body:has(> #childWorkspace:not(.hidden)) #childTasksDrawer progress {
    accent-color: var(--block-green);
  }

  #childWorkspace #childQuestionPicker,
  #childWorkspace #childQuestionPicker > summary {
    border-color: var(--block-edge);
    border-radius: 6px;
  }

  #childWorkspace #childQuestionPicker > summary {
    background: #f5e7d0;
    color: var(--block-ink);
  }

  #childWorkspace #childQuestionPicker > summary:hover {
    background: #efdcba;
  }

  #childWorkspace .child-picker-hint {
    background: #dbe7c1;
    color: #30441d;
  }

  #childWorkspace :is(.child-question-context, .child-source-details) > summary,
  #childWorkspace .child-task-context > details > summary {
    color: #455b2b;
  }

  #childWorkspace :is(.child-task-context, .child-source-content, .child-question-preview, .image-actions, .tool-popover) {
    background-color: var(--block-surface);
    border-color: #ddc9ad;
  }

  #childWorkspace .child-tutor .bubble {
    background-color: #f4e7d4;
    border-color: #dbc39e;
    color: var(--block-ink);
  }

  #childWorkspace .child-tutor .bubble.child {
    background-color: #e6edcf;
    border-color: #a5b782;
  }

  #childWorkspace :is(.math-editor, textarea),
  body:has(> #childWorkspace:not(.hidden)) #childTasksDrawer :is(input, textarea) {
    background-color: #fffdf7;
    color: var(--block-ink);
    border-color: var(--block-edge);
  }

  #childWorkspace :is(button, summary, .math-editor, textarea):focus-visible,
  body:has(> #childWorkspace:not(.hidden)) :is(#childTasksDrawer, .paper-zoom-dialog) :is(button, summary, input):focus-visible {
    outline-color: var(--block-focus);
  }

  #childWorkspace button:not(.primary):not(:disabled),
  #childWorkspace .chat-tool-menu > summary {
    background-image: linear-gradient(#fff3dd, #eacb9c);
    box-shadow: inset 0 1px #fff7e9, inset 0 -2px #b787554a;
    border-radius: 4px;
  }

  #childWorkspace button:not(.primary):not(:disabled):hover,
  #childWorkspace .chat-tool-menu > summary:hover {
    background-image: linear-gradient(#fff0ce, #deb480);
  }

  #childWorkspace :is(.page-tabs, .question-list) button.active,
  #childWorkspace button[aria-pressed="true"]:not(#childLayoutToggle):not(:disabled) {
    background-image: linear-gradient(#e6f4cb, #bbd68c);
    box-shadow: inset 0 -2px #7d9c50;
  }

  #childWorkspace button.primary:not(:disabled) {
    background-image: linear-gradient(#658f35, #416723);
    border-radius: 4px;
    box-shadow: inset 0 1px #a4c46e, inset 0 -3px #2f4b1b;
  }

  #childWorkspace .child-tutor #childMessages {
    background:
      linear-gradient(to bottom, var(--block-paper) 29%, #fff9effa 49%, #fff9efba 75%, #fff9ef5c),
      var(--block-landscape) center bottom / cover;
    border-radius: 5px;
  }

  #childWorkspace #childMessages > .bubble {
    position: relative;
    max-width: calc(100% - 82px);
    margin-inline-start: 77px;
  }

  #childWorkspace #childMessages > .bubble.child {
    margin-inline: 0 77px;
  }

  #childWorkspace #childMessages > .bubble::before,
  #childWorkspace[data-block-reaction="thinking"] #childChatSendStatus:not(.hidden)::before {
    content: "";
    position: absolute;
    width: 70px;
    height: 70px;
    inset-inline-start: -75px;
    top: 0;
    background: var(--block-avatars) 0 0 / 200% 200% no-repeat;
    pointer-events: none;
  }

  #childWorkspace #childMessages > .bubble.child::before {
    inset-inline: auto -75px;
    background-position: 100% 100%;
  }

  #childWorkspace[data-block-reaction="thinking"] #childChatSendStatus:not(.hidden) {
    position: relative;
    padding-inline-start: 35px;
  }

  #childWorkspace[data-block-reaction="thinking"] #childChatSendStatus:not(.hidden)::before {
    width: 31px;
    height: 31px;
    inset-inline-start: 0;
    top: calc(50% - 16px);
    animation: ashu-block-thinking 900ms ease-in-out infinite;
  }

  #childWorkspace[data-block-reaction="correct"] #childMessages > .bubble:not(.child):last-child::before {
    background-position: 100% 0;
    animation: ashu-block-thinking 600ms ease-in-out 2;
  }

  #childWorkspace[data-block-reaction="incorrect"] #childMessages > .bubble:not(.child):last-child::before {
    background-position: 0 100%;
    animation: ashu-block-dip 450ms ease-in-out;
  }
}

@media (min-width: 1300px) {
  body:has(> #childWorkspace:not(.hidden)) #identity {
    position: relative;
  }

  body:has(> #childWorkspace:not(.hidden)) #identity::before {
    content: "";
    position: absolute;
    inset-inline-start: -38px;
    top: calc(50% - 17px);
    width: 34px;
    height: 34px;
    background: var(--block-avatars) 100% 100% / 200% 200% no-repeat;
    pointer-events: none;
  }
}

@keyframes ashu-block-thinking {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes ashu-block-dip {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

@media (prefers-reduced-motion: reduce) {
  #childWorkspace[data-block-reaction] #childMessages > .bubble::before,
  #childWorkspace[data-block-reaction] #childChatSendStatus:not(.hidden)::before {
    animation: none !important;
  }
}
