/* Classroom chrome: tools stay legible on a projector and reachable on a phone. */
:root { --classroom-nav-height: 60px; --reader-toolbar-height: 56px; }
body { padding-bottom: calc(var(--classroom-nav-height) + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--theme-focus); outline-offset: 3px;
}
header {
  height: 56px; min-height: 56px; max-height: 56px; gap: 16px;
  padding-inline: 20px; color: var(--theme-text); overflow: visible;
  border-bottom: 1px solid var(--theme-divider);
}
header > strong { gap: 8px; font-size: 19px; color: var(--theme-text); }
header button, #classroom-navigation button, #zoom-controls button, #annotation-tools button {
  border: 1px solid var(--theme-divider); border-radius: 8px;
  background: var(--theme-background); color: var(--theme-text);
  min-height: 38px; padding: 7px 12px;
}
header button:hover, #classroom-navigation button:hover, #zoom-controls button:hover {
  border-color: var(--theme-focus);
}
.collection-picker { display: flex; align-items: center; gap: 10px; max-width: 230px; }
#collection-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-field {
  display: flex; align-items: center; flex: 1 1 240px; min-width: 90px; max-width: 400px;
  border: 1px solid var(--theme-divider); border-radius: 9px; background: var(--theme-background);
}
.search-field:focus-within { outline: 2px solid var(--theme-focus); }
.search-field #search {
  min-width: 0; width: 100%; height: 36px; border: 0; padding: 6px 10px;
  background: transparent; color: var(--theme-text); outline: none; font-size: 14px;
}
.search-field button { border: 0; padding: 0; width: 36px; min-width: 36px; min-height: 36px; font-size: 24px; }
#search-close { display: none; }
.header-tools { margin-left: auto; gap: 8px; }
.header-tools .header-icon-btn { width: auto; padding: 7px 12px !important; font-size: 14px; }
#more-toggle { display: none; }
#cluster-context {
  display: flex; align-items: center; gap: 12px; min-height: 54px;
  margin-inline: var(--page-turn-width); padding: 8px 18px;
}
#cluster-title { margin: 0; font-size: 18px; font-weight: 650; }
#cluster-meta { font-size: 13px; opacity: .7; white-space: nowrap; }
#cluster-review-status { font-size: 12px; padding: 3px 8px; background: #e7ab3424; border-radius: 5px; }
#zoom-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
#zoom-controls button { min-height: 32px; padding: 3px 9px; font-size: 14px; }
#zoom-level { min-width: 44px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
#reader { padding-top: 0; }
.edge-page-turn { top: var(--reader-toolbar-height); bottom: calc(var(--classroom-nav-height) + env(safe-area-inset-bottom)); }
#classroom-navigation {
  position: fixed; z-index: 20; inset: auto 0 0; display: flex; justify-content: center;
  align-items: center; gap: 18px; min-height: var(--classroom-nav-height);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--theme-header); border-top: 1px solid var(--theme-divider);
}
#classroom-navigation #previous, #classroom-navigation #next { width: 106px; height: 42px; font-size: 15px; }
#catalog-toggle { display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 220px; }
#current-cluster-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#position { font-variant-numeric: tabular-nums; font-size: 13px; opacity: .75; }
.classroom-panel, #settings-panel, #profile-panel {
  position: fixed; z-index: 50; top: 68px; right: 20px; display: block;
  width: min(390px, calc(100vw - 32px)); max-height: calc(100dvh - 150px);
  overflow: auto; overscroll-behavior: contain; padding: 20px;
  background: var(--theme-background); color: var(--theme-text);
  border: 1px solid var(--theme-divider); border-radius: 14px;
  box-shadow: 0 16px 60px #0002;
}
body[data-ui-panel] #dictionary-card, body[data-ui-panel] #canvas-note-drawer { visibility: hidden; }
.panel-heading, .settings-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-heading h2, .settings-panel-header h2 { font-size: 19px; margin: 0; }
.panel-heading button, #settings-panel-close { min-width: 40px; min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 22px; }
.eyebrow { font-size: 12px; margin: 0 0 5px; opacity: .65; }
.panel-help { font-size: 12px; line-height: 1.65; opacity: .75; margin-block: 12px; }
.settings-section + .settings-section { border-top: 1px solid var(--theme-divider); margin-top: 20px; padding-top: 8px; }
.settings-section h3 { font-size: 13px; opacity: .7; margin: 12px 0; letter-spacing: .05em; }
.field-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 48px; font-size: 14px; }
.field-row select { max-width: 64%; min-height: 36px; padding: 5px 8px; border: 1px solid var(--theme-divider); border-radius: 7px; background: var(--theme-background); color: inherit; }
.field-row input[role="switch"] { appearance: none; width: 38px; height: 23px; border-radius: 14px; background: var(--theme-divider); position: relative; cursor: pointer; flex-shrink: 0; }
.field-row input[role="switch"]::after { content: ''; position: absolute; width: 17px; height: 17px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0003; }
.field-row input[role="switch"]:checked { background: var(--theme-focus); }
.field-row input[role="switch"]:checked::after { left: 18px; }
#word-style-preview { margin: 8px auto 0; width: 105px; border: 1px solid var(--theme-divider); border-radius: 10px; padding: 8px; display: grid; gap: 2px; text-align: center; }
#word-style-preview span { font-size: 12px; opacity: .75; }
body.hide-word-box #word-style-preview { border-color: transparent; }
.field-label { font-size: 14px; margin: 12px 0 8px; }
.theme-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-choices button { display: grid; justify-items: center; gap: 7px; padding: 10px 6px; border: 1px solid var(--theme-divider); border-radius: 9px; background: transparent; color: inherit; font-size: 13px; }
.theme-choices button[aria-pressed="true"] { border: 2px solid var(--theme-focus); padding: 9px 5px; background: color-mix(in srgb, var(--theme-focus) 8%, transparent); }
.theme-swatch { width: 42px; height: 23px; border-radius: 4px; border: 1px solid #0002; }
.swatch-light { background: linear-gradient(135deg, #fff 65%, #d73a49 65%); }
.swatch-warm { background: linear-gradient(135deg, #fdf6e3 65%, #b58900 65%); }
.swatch-dark { background: linear-gradient(135deg, #1a1b26 65%, #7aa2f7 65%); }
#more-themes { margin: 12px 0; font-size: 13px; }
#more-themes summary { cursor: pointer; min-height: 32px; padding-block: 6px; }
#selected-theme-name { float: right; opacity: .65; max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#text-size-preview { padding: 12px; border-radius: 8px; background: color-mix(in srgb, var(--theme-text) 4%, transparent); font-size: calc(14px * var(--text-scale, 1)); }
#text-size-preview span { display: block; margin-top: 4px; }
.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--theme-text); text-decoration: underline; font-size: 13px; }
.compact-panel { width: 300px; }
#view-actions, #more-panel { gap: 8px; }
#view-actions { display: grid; }
#view-actions button, #more-panel > button { min-height: 44px; padding: 10px 12px; text-align: left; border: 1px solid var(--theme-divider); border-radius: 8px; background: transparent; color: inherit; width: 100%; }
#view-actions button[aria-pressed="true"] { border-color: var(--theme-focus); background: color-mix(in srgb, var(--theme-focus) 12%, transparent); }
#more-panel > button + button { margin-top: 8px; }
#annotation-tools { display: flex; justify-content: center; gap: 8px; }
#annotation-tools:has(button:not([hidden])) { padding: 8px; background: color-mix(in srgb, var(--theme-focus) 8%, transparent); }
#annotation-tools .header-icon-btn { width: auto; padding: 7px 12px !important; }
.catalog-filter { display: grid; gap: 8px; font-size: 13px; }
.catalog-filter input { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--theme-divider); border-radius: 8px; background: transparent; color: inherit; }
#cluster-list { padding: 0; list-style: none; margin: 14px 0 0; }
#cluster-list button { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; text-align: left; border: 0; border-bottom: 1px solid var(--theme-divider); background: transparent; color: inherit; padding: 10px; border-radius: 6px; }
#cluster-list button[aria-current="true"] { background: color-mix(in srgb, var(--theme-focus) 12%, transparent); box-shadow: inset 3px 0 var(--theme-focus); }
.cluster-list-number { min-width: 28px; opacity: .55; font-size: 12px; }
.cluster-list-name { flex: 1; overflow-wrap: anywhere; }
.cluster-list-meta { font-size: 12px; opacity: .7; }
#scope-notice { margin: 0 var(--page-turn-width) 8px; padding: 8px 18px; font-size: 13px; background: #e7ab341a; }
#scope-notice button { margin-left: 10px; border: 0; background: transparent; color: inherit; text-decoration: underline; min-height: 32px; }
body.toolbar-hidden #reader, body.toolbar-hidden #mindmap, body.toolbar-hidden #sentences { min-height: 0; }
body.toolbar-hidden .classroom-panel { top: 56px; }
@media (max-width: 760px) {
  :root { --page-turn-width: 0px; --classroom-nav-height: 64px; }
  header { position: relative; padding-inline: 10px; gap: 8px; overflow: visible; }
  header > strong .app-title-text { display: inline; }
  header > strong { font-size: 18px; gap: 5px; }
  header > strong img { display: none; }
  .collection-picker { max-width: 105px; font-size: 12px; padding: 5px 7px; gap: 3px; }
  .header-tools { display: none; }
  #more-toggle { display: block; min-width: 42px; padding: 5px; margin-left: auto; }
  .search-field { flex: 1 1 100px; min-width: 72px; }
  .search-field #search { font-size: 13px; padding-inline: 8px; }
  .search-field #search-submit { display: none; }
  .search-field:focus-within { position: absolute; left: 10px; right: 10px; z-index: 40; max-width: none; }
  .search-field:focus-within #search-close, .search-field:focus-within #search-submit { display: block; }
  .edge-page-turn { display: none; }
  #cluster-context { flex-wrap: wrap; padding: 8px 12px; gap: 6px 10px; min-height: 72px; }
  #cluster-title { font-size: 16px; }
  #cluster-meta { font-size: 12px; }
  #zoom-controls { margin-left: auto; }
  #zoom-controls button { min-height: 36px; }
  #reader { margin: 0; padding-inline: 8px; padding-bottom: 8px; }
  #classroom-navigation { gap: 8px; padding-inline: 8px; }
  #classroom-navigation #previous, #classroom-navigation #next { width: 80px; font-size: 14px; }
  #catalog-toggle { min-width: 0; flex: 1; gap: 6px; padding-inline: 6px; }
  #current-cluster-name { max-width: 75px; font-size: 14px; }
  #position { min-width: 0; font-size: 12px; }
  .classroom-panel, #settings-panel, #profile-panel { inset: 0; width: 100%; max-height: 100dvh; border: 0; border-radius: 0; padding: 0 20px max(20px, env(safe-area-inset-bottom)); }
  body.toolbar-hidden .classroom-panel { top: 0; }
  .panel-heading, .settings-panel-header { position: sticky; z-index: 1; top: 0; padding-block: 14px; background: var(--theme-background); border-bottom: 1px solid var(--theme-divider); }
  #profile-panel-close { position: sticky; top: 12px; min-height: 44px; }
  #view-panel, #more-panel { padding-top: 0; }
  #settings-panel .field-row { min-height: 54px; }
}
