/* One set of controls for Studio and the reference tool opened from the Editor or Library. */
.reference-panel { container: reference / inline-size; }
.reference-summary > span:first-of-type { min-width: 0; overflow-x: auto; white-space: nowrap; }
.reference-panel > .reference-summary:not([hidden]) {
  display: flex; align-items: center; gap: .7rem; min-height: 46px; padding: .65rem .7rem;
  border: 1px solid #3f6c94; border-top-color: #77a8d0; border-radius: 10px;
  background: linear-gradient(165deg, #284c6d, #142a43 68%);
  color: #ecf7ff; list-style: none; line-height: 1.25;
  box-shadow: inset 0 1px #b6ddff33, 0 3px 0 #091a2c, 0 8px 16px #060f1794;
}
.reference-summary::-webkit-details-marker { display: none; }
.reference-mark {
  flex: none; width: 33px; height: 33px; padding: 5px; box-sizing: border-box;
  color: #a7deff; background: #102840;
  border: 1px solid #537a9a; border-radius: 9px; box-shadow: inset 0 1px 4px #050f1a;
}
.reference-summary::after {
  content: ''; flex: none; width: .45rem; height: .45rem; margin: 0 .15rem .2rem .1rem;
  border: solid #a6d3fa; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.reference-panel[open] > .reference-summary::after { margin-block: .2rem 0; transform: rotate(225deg); }
.reference-ready-count {
  flex: none; margin-inline-start: auto; padding: .27rem .53rem;
  color: #cee6ff; background: #0b2036; border: 1px solid #47759a; border-radius: 1rem;
  box-shadow: inset 0 1px 3px #081524;
  font-size: .76rem; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.reference-ready-count:empty { display: none; }
[data-reference-state="ready"] .reference-ready-count { color: #b0f6cb; border-color: #509879; background: #143f35; }
[data-reference-state="loaded"] .reference-ready-count { color: #b0f6cb; border-color: #65b891; background: #143f35; }
[data-reference-state="checking"] .reference-ready-count { color: #bfe3ff; border-color: #76acd9; }
.reference-workspace {
  margin-top: .72rem; padding: clamp(.65rem, 2vw, .95rem);
  border: 1px solid #395a76; border-radius: 9px;
  background: radial-gradient(ellipse at top left, #1e3c58, transparent 74%), #0d2033;
  box-shadow: inset 0 1px #6b99bd2c, inset 0 -6px 14px #06162455;
}
.reference-workspace h3:first-child { margin-top: 0; }
.reference-setup {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(8rem, max-content); gap: .85rem; align-items: start;
}
.reference-setup h3, .reference-deck h3 { color: #e9f6ff; }
.reference-setup .field-note { margin-block: .35rem 0; }
.reference-progress-box {
  display: grid; gap: .5rem; padding: .65rem .75rem; color: #cbe9ff;
  font-size: .78rem; font-weight: 650; font-variant-numeric: tabular-nums;
  border: 1px solid #3e6381; border-radius: 9px; background: #0a1c2d; box-shadow: inset 0 1px 4px #020913;
}
.reference-progress-box progress {
  appearance: none; display: block; width: 100%; height: .38rem; border: 0; border-radius: 1rem;
  overflow: hidden; background: #253c51; color: #73dcb7;
}
.reference-progress-box progress::-webkit-progress-bar { background: #253c51; }
.reference-progress-box progress::-webkit-progress-value { background: linear-gradient(90deg,#5eaafa,#80e8b9); }
.reference-progress-box progress::-moz-progress-bar { background: linear-gradient(90deg,#5eaafa,#80e8b9); }
#reference-progress-label { white-space: nowrap; overflow-x: auto; }
.reference-follow-control:not([hidden]) {
  margin-block: .85rem; padding: .45rem .75rem .6rem; border: 1px solid #3e6381; border-radius: 9px;
  background: linear-gradient(145deg,#203d59,#132a40); box-shadow: inset 0 1px #bce0ff26,0 2px 0 #0a1827;
}
.reference-follow-control .button { min-height: 44px; max-width: 100%; white-space: nowrap; }
.reference-follow-control .button[aria-pressed="true"] { color: #c1f7d9; border-color: #75ad98; background: #17463e; }
.reference-follow-control .field-note { margin: .35rem 0 0; }
.reference-deck { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,.9fr); gap: .8rem; margin-top: .85rem; }
.reference-queue, .reference-console {
  min-width: 0; padding: clamp(.65rem,2vw,.95rem); border: 1px solid #456883; border-radius: 10px;
  background: linear-gradient(145deg,#1c3852,#12263b 80%); box-shadow: inset 0 1px #bce0ff29,0 3px 0 #081827;
}
.reference-console { border-top-color: #709abc; }
.reference-console:not([open]) { align-self: start; }
.reference-console-summary {
  display: flex; align-items: center; gap: .55rem; min-height: 44px;
  color: #e9f6ff; font-size: .92rem; font-weight: 700; white-space: nowrap; list-style: none;
}
.reference-console-summary::-webkit-details-marker { display: none; }
.reference-panel .reference-console-summary .ico {
  flex: none; width: 30px; height: 30px; padding: 5px; box-sizing: border-box;
  border: 1px solid #527d9d; border-radius: 8px; background: #0b2036; color: #a7deff;
  box-shadow: inset 0 1px 4px #050f1a;
}
.reference-console-summary span { min-width: 0; overflow-x: auto; }
.reference-console-summary::after {
  content: ''; flex: none; width: .4rem; height: .4rem; margin-inline-start: auto;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.reference-console[open] > .reference-console-summary::after { transform: rotate(225deg); }
.reference-target {
  margin-top: .55rem; border-inline-start: 3px solid #7bbdf5; padding: .38rem .6rem;
  color: #f2faff; font-size: clamp(1rem,4.1cqi,1.6rem); font-weight: 750; line-height: 1.2;
  letter-spacing: -.015em; white-space: nowrap; overflow-x: auto;
}
.reference-capture-display {
  position: relative; min-height: 5rem; padding: .68rem .75rem; margin-block: .75rem;
  border: 1px solid #375a78; border-radius: 9px; background: #091c2e; box-shadow: inset 0 3px 10px #040f19;
}
.reference-capture-display #reference-status { margin: 0; overflow-x: auto; }
.reference-console #reference-package-status { margin-block: .35rem 0; }
.reference-console .reference-record-instruction { margin-block: .45rem 0; }
.reference-console #reference-package-status:empty { display: none; }
.reference-capture-display .reference-cue { margin: 0 0 .55rem; }
.reference-panel:is([data-reference-phase="listening"],[data-reference-phase="capturing"]) .reference-capture-display { border-color: #62b093; }
.reference-panel[data-reference-phase="retry"] .reference-capture-display { border-color: #bd965f; }
.reference-panel[data-reference-result="mismatch"] .reference-capture-display { border-color: #bd965f; }
.reference-console .reference-next:not([hidden]) { display: inline-flex; gap: .5rem; align-items: center; }
.reference-next span { font-size: 1.3rem; line-height: 1; }
#reference-status { min-height: 1.3em; color: #c0ddf4; }
.reference-panel input[type="search"] {
  min-height: 44px; min-width: 0; padding: .6rem .65rem; font-size: 16px;
  border: 1px solid #507da1; border-radius: 8px; background: #081b2d; color: #f4f9ff;
  box-shadow: inset 0 2px 5px #0005;
}
.reference-panel input[type="search"]::placeholder { color: #a4b9cc; }
.reference-workspace .session-picker-actions { gap: .6rem; align-items: stretch; padding-block: .25rem .45rem; }
.reference-workspace .session-picker-actions { display: flex; flex-wrap: wrap; }
.reference-workspace .session-picker-actions > .button { white-space: nowrap; min-height: 44px; justify-content: center; }
.reference-panel:not(.reference-editor-dialog .reference-panel) .reference-workspace .session-picker-actions > .button {
  border-color: #537ea1; background: linear-gradient(155deg, #315777, #1a3650);
  box-shadow: inset 0 1px #bfe7ff36, 0 2px 0 #071721;
}
.reference-panel:not(.reference-editor-dialog .reference-panel) .reference-workspace .session-picker-actions > .primary {
  border-color: #91caef; background: linear-gradient(155deg, #4b8bba, #245a8e); color: #f4f9ff;
}
.reference-panel [data-word], .reference-workspace .button { touch-action: manipulation; }
[data-reference-recording="recording"] .reference-workspace { border-color: #77aed9; }
[data-reference-recording="saving"] .reference-workspace { border-color: #509879; }
.reference-panel :focus-visible { outline: 2px solid #a9ddff; outline-offset: 2px; }
@container reference (max-width: 31rem) {
  .reference-setup, .reference-deck { grid-template-columns: minmax(0,1fr); }
  .reference-workspace .session-picker-actions > .button:not([hidden]) { flex: 1 0 max-content; }
  .reference-panel > .reference-summary:not([hidden]) { font-size: .875rem; }
}
@container reference (max-width: 23rem) {
  .reference-panel > .reference-summary:not([hidden]) { gap: .4rem; padding-inline: .48rem; }
  .reference-mark { width: 23px; height: 23px; padding: 3px; }
  .reference-ready-count { padding-inline: .32rem; }
}
@container reference (max-width: 20rem) { .reference-mark { display: none; } }
@container reference (max-width: 18rem) {
  .reference-panel > .reference-summary:not([hidden]) { gap: .22rem; padding-inline: .28rem; font-size: .77rem; }
  .reference-summary::after { margin-inline: .06rem; }
  .reference-ready-count { padding-inline: .22rem; }
  .reference-follow-control:not([hidden]) { padding-inline: .55rem; }
  .reference-follow-control .button { font-size: .825rem; }
  .reference-console-summary { gap: .38rem; }
  .reference-panel .reference-console-summary .ico { width: 24px; height: 24px; padding: 4px; }
}
@media (max-width: 360px) { .script-card .helper-tools { padding-inline: 3px; } }
@media (forced-colors: active) {
  .reference-panel > .reference-summary, .reference-workspace, .reference-ready-count { border: 1px solid ButtonText; }
}
.reference-panel h3 { margin: .75rem 0 .35rem; font-size: .95rem; }
.reference-panel label[for="reference-search"] { display: block; margin: .6rem 0 .25rem; }
.reference-panel input[type="search"] { width: 100%; }
.reference-words, .reference-library-list { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0; list-style: none; }
.reference-words { margin-block: .55rem; }
:is(.reference-words,.reference-library-list) > li { min-width: 0; max-width: 100%; }
.reference-words button,.reference-library-word,.reference-library-trigger {
  display: inline-flex; align-items: center; gap: .45rem; min-width: 0; max-width: 100%;
  min-height: 44px; padding: .43rem .65rem; border: 1px solid #4c7799; border-top-color: #79a8ca; border-radius: 8px;
  color: var(--ink); background: linear-gradient(155deg,#274969,#172f4a);
  box-shadow: inset 0 1px #d4edff28,0 2px 0 #091b2c,0 5px 10px #06142160;
  font-weight: 650; text-align: start; white-space: nowrap;
}
.reference-library-trigger { margin-top: .6rem; min-height: 44px; }
.reference-words button, .reference-library-word { min-height: 34px; padding: .25rem .45rem; gap: .3rem; font-size: .82rem; }
.reference-word-label { min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
@media (pointer: coarse) {
  .reference-words button, .reference-library-word { min-height: 36px; }
}
.reference-workspace #reference-compare[hidden] { display: none; }
.reference-library-trigger .ico { color: #a8dbff; }
.reference-words button:hover:not(:disabled),.reference-library-word:hover:not(:disabled),.reference-library-trigger:hover:not(:disabled) {
  background: linear-gradient(155deg,#365e82,#234466); border-color: #90bddd;
}
.reference-words button[aria-pressed="true"] { border-color: #a4d5ff; background: #2866a2; color: #fff; }
.reference-word-state {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1rem; height: 1rem; border: 1px solid #509879; border-radius: 50%;
  color: #aaf6c7; background: linear-gradient(#205b46,#103b31);
  box-shadow: inset 0 1px #a9ffcc34,0 0 8px #7deab126;
}
.reference-word-state::before {
  content: ""; width: .28rem; height: .48rem; margin-top: -.12rem;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
#reference-library-dialog {
  width: 570px; max-height: min(80vh,calc(100dvh - 24px)); padding: clamp(.85rem,4vw,1.2rem);
  background: radial-gradient(ellipse at top left,#234a6e 0%,transparent 66%),#13283f;
  border-color: #5c86aa; box-shadow: inset 0 1px #c5e7ff43,0 9px 0 #081a2c,0 24px 52px #030f1cbb;
}
#reference-library-dialog[open] { display: flex; flex-direction: column; }
.reference-library-header { align-items: flex-start; }
.reference-library-header h2 { color: #e7f6ff; font-size: clamp(1.08rem,4vw,1.32rem); }
.reference-library-header .icon-button { min-width: 44px; min-height: 44px; }
#reference-library-script { color: #c8e1fc; margin-top: .2rem; white-space: nowrap; overflow-x: auto; }
.reference-library-count { color: #a9d7f7; font-size: .8rem; margin-block: .65rem; }
.reference-library-empty { color: var(--muted); padding: .65rem .8rem; background: #102539; border: 1px solid #305574; border-radius: 8px; }
.reference-library-list {
  min-height: 0; overflow: auto; overscroll-behavior: contain;
  margin: 0; padding: .15rem .25rem .5rem; list-style: none;
}
.reference-library-list:empty { display: none; }
.reference-mic { margin-top: .65rem; }
.reference-mic > div { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; font-size: .8rem; }
.reference-mic meter { display: block; width: 100%; }
.reference-mic meter::-webkit-meter-optimum-value { background: linear-gradient(90deg, #54abff, #87ebbc); }
.reference-mic meter::-moz-meter-bar { background: linear-gradient(90deg, #54abff, #87ebbc); }
.reference-cue { width: max-content; min-width: 3.5rem; padding: .4rem .9rem; margin-top: .65rem; border: 1px solid #89c5ff;
  border-radius: 2rem; color: #bfe2ff; font-size: 1.9rem; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.reference-cue[data-phase="listening"], .reference-cue[data-phase="capturing"] { background: #87ebbc; color: #0b2941; border-color: #b8f9dc; }

.reference-editor-symbols { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.reference-editor-dialog, #reference-library-dialog {
  --ink: #f4f9ff; --muted: #b2c6db; --accent: #a8d4ff;
  container: reference-dialog / inline-size;
  color-scheme: dark; color: var(--ink); max-width: calc(100vw - 32px); border: 1px solid #5c86aa;
  border-radius: 12px;
}
.reference-editor-dialog {
  width: 680px; max-height: calc(100dvh - 24px); overflow: auto; padding: clamp(.85rem,4vw,1.2rem);
  background: radial-gradient(ellipse at top left,#234a6e 0%,transparent 66%),#13283f;
  box-shadow: inset 0 1px #c5e7ff43,0 9px 0 #081a2c,0 24px 52px #030f1cbb;
}
.reference-editor-dialog::backdrop, #reference-library-dialog::backdrop { background: #061021ab; }
.reference-editor-heading,.reference-library-header { display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between; }
.reference-editor-heading > div, .reference-library-header > div { min-width: 0; }
.reference-editor-heading h2,.reference-library-header h2 { margin: 0; font-size: clamp(.94rem,4cqi,1.4rem); white-space: nowrap; overflow-x: auto; }
.reference-editor-heading p { margin: .25rem 0 0; color: #bbdefa; white-space: nowrap; overflow-x: auto; }
.reference-editor-dialog .reference-panel { padding: 0; border: 0; }
.reference-editor-dialog .reference-workspace { margin-top: .8rem; }
.reference-editor-dialog .field-note { color: var(--muted); margin: .45rem 0; font-size: .86rem; line-height: 1.45; }
.reference-editor-dialog input[type="search"] {
  max-width: 100%; min-height: 44px; padding: .55rem .65rem; color: var(--ink); background: #0d1f32;
  border: 1px solid #537b9a; border-radius: 7px;
}
.reference-editor-dialog .session-picker-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.reference-editor-dialog .button,.reference-editor-close,#reference-library-dialog .icon-button {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; border: 1px solid #597e9e; border-radius: 8px;
  background: linear-gradient(#2c5274,#203b58); color: var(--ink); padding: .4rem .7rem; font-weight: 650;
  box-shadow: inset 0 1px #bfe7ff36, 0 2px 0 #071721;
}
.reference-editor-dialog .button.primary { background: linear-gradient(#3c76a9,#275787); }
.reference-sample-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(10.25rem,100%),1fr)); gap: .65rem; }
.reference-sample-action { min-width: 0; }
.reference-sample-action .button {
  min-height: 44px; width: 100%; justify-content: center; white-space: nowrap;
  border-color: #537ea1; background: linear-gradient(155deg,#315777,#1a3650);
  box-shadow: inset 0 1px #bfe7ff36,0 2px 0 #071721;
}
.reference-sample-action .field-note { margin: .4rem 0 0; }
.reference-panel[data-reference-sample="new"] #reference-record,
.reference-panel[data-reference-sample="saved"]:not([data-reference-result="mismatch"]) #reference-compare {
  border-color: #91caef; background: linear-gradient(155deg,#4b8bba,#245a8e); color: #f4f9ff;
}
.reference-panel[data-reference-result="mismatch"] #reference-record:not(:disabled) {
  border-color: #e3bd80; background: linear-gradient(155deg,#68502e,#3d2d19); color: #fff3dd;
}
.reference-editor-close,#reference-library-dialog .icon-button { justify-content: center; }
.reference-editor-dialog .ico,#reference-library-dialog .ico {
  width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round;
}
.reference-editor-dialog button:disabled { opacity: .45; cursor: default; }
.reference-editor-dialog :focus-visible,#reference-library-dialog :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
