/* Matte ivory, pale jade, deep jade and warm stone share one generated material sheet. */
html[data-z-pane] {
  --surface-atlas:url('/shared/panel-materials.webp');
  --surface-generated-frame:url('/shared/panel-frame.webp');
  --surface-ivory:0 0;
  --surface-jade:100% 0;
  --surface-deep:0 100%;
  --surface-stone:100% 100%;
  --surface-plain-glaze:rgb(252 251 242 / 65%);
  --surface-feature-glaze:rgb(239 245 232 / 66%);
  --surface-dialog-glaze:rgb(247 249 237 / 76%);
  --surface-input-glaze:rgb(252 252 246 / 78%);
  --surface-rim-tint:rgb(37 77 55 / 41%);
  --surface-shadow:0 15px 44px rgb(14 35 26 / 12%);
  --surface-edge-opacity:.49;
}
html[data-z-pane='a'] {
  --surface-plain-glaze:rgb(14 45 37 / 92%);
  --surface-feature-glaze:rgb(19 57 44 / 91%);
  --surface-dialog-glaze:rgb(17 49 41 / 92%);
  --surface-input-glaze:rgb(12 41 34 / 94%);
  --surface-rim-tint:rgb(20 63 47 / 76%);
  --surface-shadow:0 18px 48px rgb(6 17 13 / 33%);
  --surface-edge-filter:brightness(1.75) saturate(.65);
}

/* Retain native controls and the borders' footprint. The exposed rim is painted with image pixels. */
html[data-z-pane] body :is(
  dialog,#auth-dialog.entry-login,.syllable-menu,.studio-form,.logbook,
  .analysis-panel,#analysis-flow,.score-hero,.score-dashboard,.studio-acoustics,
  .corrected-player,.audio-transport,.tutor-panel.card,.tutor-panel .message > div,
  .practice-method,.memory-overview,.memory-next,.memory-facts,.ev-receipt,
  .palm-review .preview,#chat-form,.entry-choice,#reference-select,#conversation-select,.ev-tools select,
  .entry-login form input,.syllable-menu input,.studio-form textarea,.analysis-settings input,
  .selection-controls input
),
html[data-z-pane='a'] body .record-layout > :is(.console,.practice-panel) {
  border:1px solid transparent;
  border-radius:var(--surface-radius,16px);
  background-color:var(--surface-fallback,var(--sheet,#f7f8ed));
  background-image:
    linear-gradient(var(--surface-glaze,var(--surface-plain-glaze)),var(--surface-glaze,var(--surface-plain-glaze))),
    var(--surface-atlas),
    linear-gradient(var(--surface-rim-tint),var(--surface-rim-tint)),
    var(--surface-frame-image,var(--surface-atlas));
  background-repeat:no-repeat;
  background-size:100% 100%,200% 200%,100% 100%,var(--surface-frame-size,200% 200%);
  background-position:center,var(--surface-material,var(--surface-ivory)),center,var(--surface-frame-position,var(--surface-stone));
  background-origin:padding-box,padding-box,border-box,border-box;
  background-clip:padding-box,padding-box,border-box,border-box;
}

html[data-z-pane] body :is(dialog,#auth-dialog.entry-login,.syllable-menu,.studio-form) {
  --surface-material:var(--surface-deep);
  --surface-glaze:var(--surface-dialog-glaze);
  --surface-fallback:var(--entry-paper,var(--sheet));
  --surface-radius:22px;
}
html[data-z-pane] body #auth-dialog.entry-login:not([hidden]) {
  border-color:transparent;
  border-radius:var(--surface-radius);
}
html[data-z-pane] body :is(dialog,#auth-dialog.entry-login,.syllable-menu) {box-shadow:var(--surface-shadow);}

/* The generated transparent frame keeps its corner detail at different panel sizes. */
html[data-z-pane] body :is(#auth-dialog.entry-login,.analysis-panel,#analysis-flow,.tutor-panel.card,.studio-form,
  .logbook,.memory-overview,.memory-next,.corrected-player,.practice-method) {position:relative;}
html[data-z-pane] body :is(dialog,#auth-dialog.entry-login,.analysis-panel,.tutor-panel.card,.studio-form,
  .logbook,#analysis-flow,.memory-overview,.memory-next,.corrected-player,.practice-method)::after {
  content:'';
  position:absolute;
  inset:0;
  z-index:1;
  border:10px solid transparent;
  border-image:var(--surface-generated-frame) 40 / var(--surface-edge-size,18px) stretch;
  clip-path:inset(0 round var(--surface-radius,16px));
  filter:var(--surface-edge-filter,none);
  opacity:var(--surface-edge-opacity);
  pointer-events:none;
}
html[data-z-pane] body :is(dialog,#auth-dialog.entry-login) {--surface-edge-opacity:.60;--surface-edge-size:22px;}
html[data-z-pane] body :is(.memory-overview,.memory-next,.corrected-player,.practice-method) {
  --surface-edge-opacity:.38;
  --surface-edge-size:14px;
}

html[data-z-pane] body :is(.memory-next,.memory-facts,.corrected-player,.ev-receipt,.tutor-panel .message.user > div) {
  --surface-material:var(--surface-jade);
  --surface-glaze:var(--surface-feature-glaze);
  --surface-fallback:var(--rail-selection,var(--sheet));
}
html[data-z-pane] body .score-hero {
  --surface-material:var(--surface-deep);
  --surface-glaze:rgb(17 63 44 / 94%);
  --surface-fallback:#17422e;
}
html[data-z-pane] body .studio-acoustics {
  --surface-glaze:color-mix(in srgb,var(--ac-ground) 94%,transparent);
  --surface-fallback:var(--ac-ground);
}

html[data-z-pane] body :is(
  #chat-form,.entry-choice,#reference-select,#conversation-select,.ev-tools select,
  .entry-login form input,.syllable-menu input,.studio-form textarea,.analysis-settings input,.selection-controls input
) {
  --surface-material:var(--surface-stone);
  --surface-glaze:var(--surface-input-glaze);
  --surface-fallback:var(--entry-field,var(--sheet));
  --surface-radius:9px;
}
html[data-z-pane] body #chat-form {--surface-radius:14px;}
html[data-z-pane] body .entry-choice:has(:checked) {
  --surface-material:var(--surface-jade);
  --surface-glaze:var(--surface-feature-glaze);
  box-shadow:inset 0 0 0 1px var(--entry-spruce);
}
html[data-z-pane] body :is(#chat-form:focus-within,#reference-select:focus-visible,#conversation-select:focus-visible) {
  outline:2px solid var(--entry-focus,var(--green));
  outline-offset:2px;
}

/* Header tint stays behind text. The individual illustration stays on its own element. */
html[data-z-pane] body :is(.practice-method-head,.practice-method-cue,.dialog-heading,.conversation-tools) {
  background-image:linear-gradient(var(--surface-feature-glaze),var(--surface-feature-glaze)),var(--surface-atlas);
  background-size:100% 100%,200% 200%;
  background-position:center,var(--surface-jade);
  background-repeat:no-repeat;
}
html[data-z-pane] body :is(.dialog-heading,.conversation-tools) {border-radius:14px 14px 0 0;}

@media(max-width:640px) {
  html[data-z-pane] body :is(dialog,#auth-dialog.entry-login,.studio-form) {--surface-radius:17px;}
}
@media(forced-colors:active) {
  html[data-z-pane] body :is(dialog,#auth-dialog,.syllable-menu,.studio-form,.analysis-panel,.tutor-panel,.logbook,
    .entry-choice,#syllable-open,#reference-select,#conversation-select,#chat-form,.practice-method,.audio-transport) {
    border-color:CanvasText;
  }
  html[data-z-pane] body :is(dialog,#auth-dialog.entry-login,.analysis-panel,.tutor-panel.card,.studio-form,
    .logbook,#analysis-flow,.memory-overview,.memory-next,.corrected-player,.practice-method)::after {display:none;}
}
