/* 摺疊區塊（紀錄、教師標記） */
details.panel.fold > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  color: var(--ink);
}
details.panel.fold > summary::-webkit-details-marker { display: none; }
details.panel.fold > summary::before {
  content: "▸ ";
  font-family: var(--font-mono);
  color: var(--muted);
  font-weight: 500;
}
details.panel.fold[open] > summary::before { content: "▾ "; }
details.panel.fold .fold-body { margin-top: 0.55rem; }
details.panel.fold[open] > .fold-body {
  animation: lam-panel-in var(--motion-in) var(--ease-out);
}
details.panel.fold + details.panel.fold { margin-top: 0.75rem; }
.teacher-marks .ops-more-body,
details.panel.fold .ops-more-body { margin-top: 0.45rem; }

/* 快速新增／選項：一律原生 <dialog>；overlay 用 ::backdrop */
dialog.lam-quick-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: none;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, var(--safe-top)) 1rem max(1rem, var(--safe-bottom));
  background: transparent;
}
dialog.lam-quick-modal:not([open]) {
  display: none;
}
dialog.lam-quick-modal[open] {
  display: flex;
}
dialog.lam-quick-modal::backdrop {
  background: var(--overlay);
  opacity: 0;
  transition: opacity var(--motion-in) var(--ease-out);
}
dialog.lam-quick-modal[open]:not(.is-closing)::backdrop,
dialog.lam-quick-modal.is-open::backdrop {
  opacity: 1;
}
dialog.lam-quick-modal.is-closing::backdrop {
  opacity: 0;
  transition-duration: var(--motion-fast);
}
/* 卡片保持實色：不可對整張卡做 opacity 進場，否則下拉選項會透出底下表單 */
.lam-quick-modal-card {
  position: relative;
  z-index: 1;
  width: min(28rem, 100%);
  max-height: min(90vh, 36rem);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.05rem;
  background: var(--panel);
  box-shadow: 0 6px 20px var(--shadow);
  transform: scale(0.98) translateY(0.2rem);
  transition: transform var(--motion-in) var(--ease-out);
}
dialog.lam-quick-modal[open]:not(.is-closing) .lam-quick-modal-card,
dialog.lam-quick-modal.is-open .lam-quick-modal-card {
  transform: scale(1) translateY(0);
}
dialog.lam-quick-modal.is-closing .lam-quick-modal-card {
  transform: scale(0.98) translateY(0.12rem);
  transition-duration: var(--motion-fast);
}
@supports (overlay: auto) {
  @starting-style {
    dialog.lam-quick-modal[open] .lam-quick-modal-card {
      transform: scale(0.98) translateY(0.2rem);
    }
    dialog.lam-quick-modal[open]::backdrop {
      opacity: 0;
    }
  }
}
/* 文字按鈕：底線由左長出。來自 Galaxy Buttons/biswacpcode_curvy-crab-71。 */
.btn-text {
  display: inline-block;
  position: relative;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  background-image: none;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn-text::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1px;
  width: 0;
  background: currentColor;
  transition: width var(--motion-fill) var(--ease-out);
}
.btn-text:hover { color: var(--accent-hover); }
.btn-text:hover::after { width: 100%; }
.btn-text:active { transform: none; }

/* 可搜尋／可快速新增的下拉 */
.lam-combo {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}
.filters .lam-combo {
  width: auto;
  min-width: 10rem;
  flex: 0 1 auto;
}
.vocab-row .lam-combo {
  display: inline-flex;
  align-items: stretch;
  min-width: 7.5rem;
  width: auto;
  max-width: 12rem;
  flex: 0 1 10rem;
}
.inline-add .lam-combo {
  width: auto;
  min-width: 7rem;
  display: inline-block;
  vertical-align: middle;
}
.lam-combo-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
/* button.lam-combo-* 提高 specificity，避免被全域 button 預設蓋掉（不再靠 !important） */
button.lam-combo-trigger {
  width: 100%;
  text-align: left;
  background: var(--input-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 1.75rem 0 0.55rem;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  /* font 縮寫會把行高清掉，所以行高要寫在後面。單行撐滿，字才不會偏上 */
  min-height: 2.5rem;
  line-height: calc(2.5rem - 2px);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.lam-combo-trigger::after {
  content: "";
  position: absolute;
  right: 0.55rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.lam-combo.is-open button.lam-combo-trigger {
  border-color: var(--accent);
  outline: 2px solid var(--focus-ring);
}
button.lam-combo-trigger.is-placeholder { color: var(--muted); }
button.lam-combo-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 選項彈窗：與 .lam-quick-modal 同殼，卡片內為可捲清單 */
.lam-picker.lam-quick-modal {
  z-index: 920;
}
.lam-picker-card {
  display: flex;
  flex-direction: column;
  width: min(28rem, 100%);
  max-height: min(85vh, 32rem);
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--panel);
}
.lam-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  flex: 0 0 auto;
}
.lam-picker-title {
  margin: 0;
  font-size: var(--fs);
  font-weight: 600;
}
.lam-picker .lam-combo-search-wrap {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
.lam-picker .lam-combo-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overscroll-behavior: contain;
  background: var(--panel);
}
.lam-picker button.lam-combo-option {
  min-height: var(--touch-min);
  padding: 0.55rem 0.9rem;
  font-size: var(--fs);
}
.lam-picker .lam-combo-add {
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  background: var(--surface-muted);
  flex: 0 0 auto;
}
.lam-picker .lam-combo-empty {
  padding: 0.85rem 0.9rem;
}
html.lam-picker-open,
html.lam-quick-open,
html:has(dialog.lam-picker[open]),
html:has(dialog.lam-prompt[open]),
html:has(dialog.lam-quick-modal[open]),
html:has(#lam-plate-camera[open]),
html:has(#lam-lightbox[open]) {
  overflow: hidden;
}
/* 寬螢幕選項清單貼欄位；有 CSS anchor 時用 position-area，否則 JS 寫 top/left */
@media (min-width: 901px) {
  html.lam-picker-open:has(.lam-picker.is-anchored) {
    overflow: auto;
  }
  .lam-picker.is-anchored::backdrop {
    background: transparent;
    opacity: 1;
  }
  .lam-picker.is-anchored .lam-picker-card {
    position: fixed;
    margin: 0;
    max-height: min(24rem, 70vh);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  }
  @supports (anchor-name: --a) {
    .lam-picker.is-anchored .lam-picker-card {
      inset: auto;
      position-area: block-end span-all;
      position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
      min-width: min(20rem, calc(100vw - 1rem));
      width: max(anchor-size(width), 20rem);
      max-width: calc(100vw - 1rem);
    }
  }
}

.lam-combo-search-wrap {
  padding: 0.35rem;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  flex: 0 0 auto;
}
.lam-combo-search {
  width: 100%;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.45rem;
}
.lam-combo-list {
  list-style: none;
  margin: 0;
  padding: 0.2rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 12rem;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.lam-combo-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
button.lam-combo-option {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 400;
  cursor: pointer;
  transition:
    background var(--motion-micro) var(--ease-out),
    color var(--motion-micro) var(--ease-out);
}
.lam-combo-row:hover button.lam-combo-option,
button.lam-combo-option:hover,
button.lam-combo-option:focus,
button.lam-combo-option.is-active {
  background: var(--accent-soft);
}
button.lam-combo-option.is-selected {
  background: var(--accent-soft-2);
  font-weight: 500;
}
button.lam-combo-option.is-selected.is-active {
  background: var(--accent-soft-3);
}
button.lam-combo-remove {
  flex: 0 0 auto;
  width: 1.7rem;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--combo-disabled-ink);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
button.lam-combo-remove:hover,
button.lam-combo-remove:focus {
  color: var(--combo-placeholder-ink);
  background: var(--ghost-hover);
  opacity: 1;
}
.lam-combo-empty {
  padding: 0.5rem 0.65rem;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.lam-combo-add {
  border-top: 1px solid var(--line);
  padding: 0.25rem;
  background: var(--surface-muted);
}
button.lam-combo-add-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--accent);
  border: 0;
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: 0.35rem 0.5rem;
}
button.lam-combo-add-btn:hover { background: var(--accent-soft); }
.lam-combo-add-form {
  display: grid;
  gap: 0.3rem;
  padding: 0.25rem 0.3rem 0.35rem;
}
.lam-combo-add-form[hidden] {
  display: none;
}
.lam-combo-add-input {
  width: 100%;
  font-size: var(--fs-sm);
  padding: 0.3rem 0.45rem;
}
.lam-combo-add-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}
.lam-combo-add-actions button.btn-sm,
.lam-combo-add-actions button {
  font-size: var(--fs-xs);
  padding: 0.2rem 0.45rem;
}

