:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-subtle: #fafafa;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: #d2d2d7;
  --border-light: #e5e5ea;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #e8f2fd;
  --success-bg: #e5f8e9;
  --warning-bg: #fff4e5;
  --warning-border: #ffd699;
  --danger: #ff3b30;
  --danger-dark: #b91c1c;
  --danger-bg: #ffeceb;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================ */
/* BEAUTIFUL NATIVE SCROLLBARS                                  */
/* ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7c7cc; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #86868b; }
* { scrollbar-width: thin; scrollbar-color: #c7c7cc transparent; }

/* Ensure the main content can scroll smoothly */
.content { overflow-y: auto !important; }

/* ============================================================ */
/* LOGIN & AUTHENTICATION                                       */
/* ============================================================ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(180deg, #f5f5f7 0%, #e8f0f8 100%);
}
.login-card {
  background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 48px 40px 36px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); animation: cardIn 0.4s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 56px; width: auto; }
.login-title { font-size: 26px; font-weight: 600; text-align: center; letter-spacing: -0.4px; margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 32px; }
.login-footer { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-light); text-align: center; font-size: 13px; color: var(--text-secondary); }
.login-footer a { color: var(--accent); text-decoration: none; font-weight: 500; }
.login-footer a:hover { text-decoration: underline; }
.tab-btn { flex: 1; padding: 8px 12px; border: none; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 500; font-family: inherit; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
.tab-btn.active { background: white; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ============================================================ */
/* FORMS & BUTTONS                                              */
/* ============================================================ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; color: var(--text-primary); background: var(--bg-elevated);
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-field { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 14px; color: var(--text-primary); cursor: pointer; user-select: none; }
.checkbox-field input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.section-label { font-size: 14px; color: var(--text-secondary); margin: 24px 0 12px; font-weight: 600; }
.section-label-small { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; font-weight: 500; }
.subsection { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-light); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 44px; }
.eye-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 15px; padding: 6px 8px; line-height: 1; color: var(--text-tertiary); border-radius: 6px; transition: background var(--transition); }
.eye-btn:hover { background: var(--bg-subtle); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 20px; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,113,227,0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-subtle); border-color: var(--text-tertiary); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn-danger { background: var(--danger-dark); color: white; }
.btn-danger:hover { background: #991b1b; }
.btn-danger-outline { background: transparent; color: var(--danger-dark); border: 1px solid var(--danger-dark); }
.btn-danger-outline:hover { background: var(--danger-bg); }
.btn-full { width: 100%; }
.btn-small { padding: 7px 14px; font-size: 13px; border-radius: 8px; background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); font-weight: 500; font-family: inherit; cursor: pointer; transition: all var(--transition); box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.btn-small:hover { background: var(--bg-subtle); border-color: var(--text-tertiary); }
.btn-small.btn-danger { color: var(--danger-dark); border-color: var(--border-light); }
.btn-small.btn-danger:hover { background: #fff0f0; border-color: #f4a2a2; }
.btn-small.btn-primary { background: var(--accent); color: white; border-color: var(--accent); box-shadow: 0 2px 6px rgba(0,113,227,0.3); }
.btn-small.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ============================================================ */
/* MAIN LAYOUT (FLUID APP-STYLE)                                */
/* ============================================================ */
.app-shell { display: flex; height: 100vh; overflow: hidden; width: 100vw; }
.sidebar { width: clamp(200px, 20vw, 260px); flex-shrink: 0; background: rgba(255,255,255,0.72); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-right: 1px solid var(--border-light); display: flex; flex-direction: column; padding: clamp(10px, 2vh, 20px) clamp(8px, 1vw, 16px); height: 100%; overflow-y: auto; }
.sidebar-brand { padding: 0 8px clamp(10px, 2vh, 20px); border-bottom: 1px solid var(--border-light); margin-bottom: clamp(8px, 1.5vh, 16px); }
.sidebar-brand img { height: clamp(28px, 4vh, 40px); width: auto; display: block; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: clamp(2px, 0.5vh, 4px); }
.nav-item { display: flex; align-items: center; gap: clamp(8px, 1.5vw, 12px); padding: clamp(6px, 1.5vh, 12px) clamp(8px, 1.5vw, 12px); border: none; background: transparent; border-radius: var(--radius-sm); font-size: clamp(12px, 1.5vh, 14px); font-weight: 500; font-family: inherit; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); text-align: left; width: 100%; }
.nav-item:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(0,113,227,0.25); }
.nav-item.active .nav-icon { filter: brightness(2); }
.nav-icon { font-size: clamp(14px, 1.8vh, 16px); line-height: 1; display: inline-block; width: clamp(16px, 2vw, 20px); text-align: center; }
.sidebar-footer { padding-top: clamp(10px, 2vh, 20px); border-top: 1px solid var(--border-light); display: flex; flex-direction: column; gap: clamp(4px, 1vh, 8px); }
.user-chip { font-size: clamp(10px, 1.3vh, 12px); color: var(--text-secondary); padding: clamp(6px, 1vh, 10px) clamp(8px, 1.5vw, 12px); background: var(--bg-subtle); border-radius: var(--radius-sm); line-height: 1.4; white-space: pre-line; }
.content { flex: 1; padding: clamp(10px, 2vh, 24px) clamp(16px, 4vw, 40px); max-width: 1100px; margin: 0 auto; width: 100%; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }

/* ============================================================ */
/* WORKSPACE SWITCHER                                           */
/* ============================================================ */
.workspace-switcher { padding: 12px; border-bottom: 1px solid var(--border-light); margin-bottom: 12px; }
.workspace-switcher label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-tertiary); margin-bottom: 6px; font-weight: 600; }
.workspace-switcher select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; font-weight: 500; background: white; color: var(--text-primary); cursor: pointer; }
.workspace-switcher select:focus { outline: none; border-color: var(--accent); }

/* ============================================================ */
/* SCREEN & PAGE HEADERS                                        */
/* ============================================================ */
.screen { 
  display: none; 
  animation: fadeIn 0.25s ease; 
  width: 100%; 
  flex-direction: column; 
  min-height: 100%; /* Allows the screen to grow taller than the window */
}

.screen.active { 
  display: flex; 
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: clamp(12px, 2vh, 28px); flex-shrink: 0; }
.page-header h1 { font-size: clamp(20px, 3vh, 30px); font-weight: 600; letter-spacing: -0.5px; }
.page-subtitle { font-size: clamp(12px, 1.5vh, 14px); color: var(--text-secondary); margin-top: 4px; }
.banner { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 24px; font-size: 14px; line-height: 1.5; flex-shrink: 0; }
.banner.warn { background: var(--warning-bg); border: 1px solid var(--warning-border); color: #8a5700; }
.banner.warn a { color: #8a5700; font-weight: 600; text-decoration: underline; }
.card { background: var(--bg-elevated); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); margin-bottom: 20px; }
.danger-zone { border: 1px solid rgba(255,59,48,0.25); }
.danger-zone h3 { color: var(--danger-dark); font-size: 16px; margin-bottom: 8px; }
.danger-zone p { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

/* ============================================================ */
/* CLIENT CARDS (FLUID SCALING)                                 */
/* ============================================================ */
.list-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5vh 1.5vw; }
.child-card { background: var(--bg-elevated); padding: 1.5vh 1vw; border-radius: 14px; border: 1px solid var(--border-light); box-shadow: 0 2px 12px rgba(0,0,0,0.03); transition: all 0.2s ease; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; height: fit-content; }
.child-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.06); transform: translateY(-2px); }
.child-card.inactive { opacity: 0.55; background: #fafafa; }
.child-card.is-adult { background-color: #f2f7fd; border-color: #cce0f5; border-left: 6px solid #0071e3; }
.child-card.is-adult:hover { box-shadow: 0 6px 20px rgba(0, 113, 227, 0.15); border-color: #0071e3; }
.child-card.is-child { background-color: #f1faf3; border-color: #d1ecd7; border-left: 6px solid #34c759; }
.child-card.is-child:hover { box-shadow: 0 6px 20px rgba(52, 199, 89, 0.15); border-color: #34c759; }
.child-card strong { display: flex; flex-direction: column; align-items: center; gap: 0.2vh; font-size: 2vh; font-weight: 600; margin-top: 0.8vh; margin-bottom: 0.2vh; }
.child-card small { display: none !important; }
.child-photo-thumb { width: 6vh; height: 6vh; border-radius: 50%; object-fit: cover; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.case-number { display: inline-block; font-size: 1.2vh; color: var(--text-tertiary); background: var(--bg-subtle); padding: 0.2vh 6px; border-radius: 6px; margin-left: 8px; font-family: 'SF Mono', Menlo, Consolas, monospace; vertical-align: middle; }
.card-actions { margin-top: 1vh; display: flex; flex-direction: column; gap: 0.4vh; width: 100%; }
.card-actions .btn-small { width: 100%; padding: 0.6vh 1vw; font-size: 1.3vh; min-height: 0; line-height: 1.2; }

.empty-state { color: var(--text-tertiary); font-size: 14px; text-align: center; padding: 48px 20px; background: var(--bg-elevated); border-radius: var(--radius); border: 1px dashed var(--border); }
.status { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.status:empty { display: none; padding: 0; margin: 0; }
.status.ok { background: var(--success-bg); color: #1d6b2a; }
.status.warn { background: var(--warning-bg); color: #8a5700; }

/* ============================================================ */
/* MODALS                                                       */
/* ============================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; animation: fadeIn 0.2s ease; }
.modal-card { background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 32px; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: cardIn 0.3s ease; }
.modal-card h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.cred-box { background: #f5f5f7; padding: 18px; border-radius: 12px; font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 14px; line-height: 2; }
.cred-sep { margin-top: 8px; padding-top: 12px; border-top: 1px dashed #d2d2d7; }
.warn-text { font-size: 13px; color: var(--danger-dark); margin-top: 14px; }
#confirm-modal { z-index: 99999 !important; }

/* ============================================================ */
/* TABLES & LISTS                                               */
/* ============================================================ */
.audit-table { width: 100%; border-collapse: collapse; background: var(--bg-elevated); font-size: 13px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); }
.audit-table th { background: var(--bg-subtle); text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); font-weight: 600; }
.audit-table td { padding: 12px 16px; border-top: 1px solid var(--border-light); vertical-align: top; }
.audit-table tr:hover td { background: var(--bg-subtle); }
.audit-table small { color: var(--text-tertiary); }

/* ============================================================ */
/* ASSESSMENT SCREEN                                            */
/* ============================================================ */
.assess-grid-header { display: grid; grid-template-columns: 140px 1fr 1fr 1fr; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); font-weight: 600; padding: 0 12px 8px; border-bottom: 1px solid var(--border-light); margin-bottom: 8px; }
.assess-grid-header > div:not(:first-child) { text-align: center; }
.assess-row { display: grid; grid-template-columns: 140px 1fr 1fr 1fr; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--bg-elevated); border-right: 6px solid var(--border-light); box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: all 0.2s; }
.assess-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.assess-cell { height: 32px; border-radius: 6px; border: 1px solid var(--border); background: white; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-tertiary); transition: all var(--transition); }
.assess-cell:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.assess-cell[data-state="present"] { background: var(--success-bg); border-color: #86c99a; color: #1d6b2a; }
.assess-cell[data-state="missing"] { background: var(--danger-bg); border-color: #f4a2a2; color: var(--danger-dark); }
.assess-cell-na { background: #fafafa; color: #c7c7cc; border-style: dashed; cursor: not-allowed; font-weight: 400; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.assess-subheader { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; margin: 20px 0 8px 12px; }
.assess-subheader:first-child { margin-top: 0; }
.assess-sound-ipa { font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", "Lucida Sans Unicode", "Segoe UI", system-ui, sans-serif; font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.assess-sound-label, .assess-sound-example { font-size: 10px; color: var(--text-secondary); line-height: 1.3; margin-top: 2px; }
.assess-sound-example { font-style: italic; }
.cat-stops { border-right-color: #0071e3; }
.cat-fricatives { border-right-color: #af52de; }
.cat-affricates { border-right-color: #ff9500; }
.cat-nasals { border-right-color: #34c759; }
.cat-liquids { border-right-color: #ff3b30; }
.cat-glides { border-right-color: #5ac8fa; }
.cluster-row { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--bg-elevated); border-right: 6px solid var(--border-light); box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.cat-sblends { border-right-color: #0071e3; }
.cat-lblends { border-right-color: #34c759; }
.cat-rblends { border-right-color: #ff9500; }
.assess-cell-quick { height: auto; min-height: 44px; padding: 4px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.2; cursor: pointer; transition: all var(--transition); }
.assess-cell-quick:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,113,227,0.15); }
.assess-cell-quick[data-state="present"] { background: var(--success-bg); border-color: #86c99a; }
.assess-cell-quick[data-state="present"] .assess-cell-state { color: #1d6b2a; }
.assess-cell-quick[data-state="missing"] { background: var(--danger-bg); border-color: #f4a2a2; }
.assess-cell-quick[data-state="missing"] .assess-cell-state { color: var(--danger-dark); }
.assess-cell-state { font-size: 12px; font-weight: 600; }
.assess-cell-probe { font-size: 10px; color: var(--text-secondary); text-align: center; word-break: break-word; }
.assess-cell-mastered { background: var(--accent); border-color: var(--accent); color: white; font-weight: 700; cursor: pointer; transition: all var(--transition); }
.assess-cell-mastered:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,113,227,0.3); }
.survey-info { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px; font-size: 14px; color: #1d3d5c; line-height: 1.6; }
.survey-info strong { display: block; font-size: 15px; margin-bottom: 6px; }
.survey-info p { margin: 4px 0; }
.survey-row { display: grid; grid-template-columns: 140px 1fr 1fr 1fr; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid #f0f0f2; }
.survey-row:last-child { border-bottom: none; }
.survey-cell { height: 32px; border-radius: 8px; border: 1px solid var(--border); background: white; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-tertiary); transition: all var(--transition); }
.survey-cell:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.survey-cell[data-state="present"] { background: var(--success-bg); border-color: #86c99a; color: #1d6b2a; }
.survey-cell[data-state="missing"] { background: var(--danger-bg); border-color: #f4a2a2; color: var(--danger-dark); }

/* ============================================================ */
/* LIBRARY SCREEN                                               */
/* ============================================================ */
.picture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.picture-tile { background: white; border: 1px solid var(--border-light); border-radius: var(--radius); overflow: hidden; transition: all var(--transition); position: relative; }
.picture-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.picture-tile.inactive { opacity: 0.5; background: #fafafa; }
.picture-tile img { width: 100%; height: 110px; object-fit: cover; display: block; background: #f0f0f2; }
.picture-tile-info { padding: 8px 10px 10px; }
.picture-tile-info strong { display: block; font-size: 13px; margin-bottom: 2px; }
.picture-tile-info small { font-size: 11px; color: var(--text-secondary); display: block; }
.picture-tile-ipa { font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", "Lucida Sans Unicode", "Segoe UI", system-ui, sans-serif; color: #1d3d5c !important; }
.picture-tile-controls { margin-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tile-inline { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.tile-inline input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.tile-vocab-select { font-size: 11px; padding: 2px 4px; border: 1px solid var(--border); border-radius: 5px; background: white; font-family: inherit; cursor: pointer; }
.duplicate-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.duplicate-option { background: white; border: 2px solid var(--border-light); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 12px; transition: all var(--transition); }
.duplicate-option:hover { border-color: var(--accent); }
.duplicate-option img { width: 100%; height: 220px; object-fit: contain; background: #f5f5f7; border-radius: 8px; }
.duplicate-option-info { text-align: center; }
.duplicate-option-info strong { display: block; font-size: 14px; margin-bottom: 2px; }
.duplicate-option-info small { font-size: 12px; color: var(--text-secondary); }
.import-summary-box { background: #f0f6fb; border: 1px solid #b8d5ec; border-radius: var(--radius); padding: 16px 20px; font-size: 14px; line-height: 1.9; color: #1d3d5c; }
.import-summary-box .row { display: flex; justify-content: space-between; padding: 2px 0; }
.import-summary-box .num { font-weight: 700; font-family: 'SF Mono', Menlo, Consolas, monospace; }
.baseline-progress-bar { width: 100%; height: 6px; background: #e5e5ea; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.baseline-progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; }
.names-header { display: grid; grid-template-columns: 40px 1fr 1fr 1.2fr; gap: 12px; padding: 10px 14px; background: var(--bg-subtle); border-radius: 8px 8px 0 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); font-weight: 600; }
.names-list { border: 1px solid var(--border-light); border-radius: 0 0 8px 8px; max-height: 550px; overflow-y: auto; margin-bottom: 16px; }
.name-row { display: grid; grid-template-columns: 40px 1fr 1fr 1.2fr; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border-light); align-items: center; transition: background var(--transition); }
.name-row:first-child { border-top: none; }
.name-row:hover { background: var(--bg-subtle); }
.name-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.name-row-word { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; color: var(--text-secondary); word-break: break-word; }
.name-row-display { font-size: 15px; font-weight: 500; color: var(--text-primary); word-break: break-word; }
.name-row-edit { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; background: white; width: 100%; outline: none; }
.name-row-edit:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================ */
/* THERAPY SCREEN (FLUID SCALING)                               */
/* ============================================================ */
.therapy-shell { display: flex; flex-direction: column; gap: clamp(4px, 1vh, 16px); max-width: 900px; margin: 0 auto; height: 100%; min-height: 0; }

.therapy-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1vh; flex-shrink: 0; }
.therapy-info { display: flex; flex-direction: column; gap: 0.2vh; }
.therapy-child-label { font-weight: 600; font-size: clamp(14px, 2.2vh, 18px); }
.therapy-target-label { color: var(--text-secondary); font-size: clamp(11px, 1.5vh, 13px); }
.therapy-tools { display: flex; gap: clamp(4px, 1vw, 8px); flex-wrap: wrap; }
.therapy-tools .btn-small { padding: clamp(4px, 0.8vh, 7px) clamp(8px, 1.2vw, 14px); font-size: clamp(10px, 1.4vh, 13px); }

/* Default Therapy Stage (Word Level, Syllables) */
.therapy-stage { 
  background: white; border: 1px solid var(--border-light); border-radius: var(--radius); 
  padding: clamp(4px, 1.5vh, 16px); box-shadow: var(--shadow-sm); 
  display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1.5vh, 16px); 
  flex: 1 1 0; min-height: 0; overflow: hidden; 
}

/* Isolation specific grid override (2 columns) */
#screen-isolation .therapy-stage { 
  display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; overflow: hidden;
}

.therapy-word-row { display: flex; align-items: center; justify-content: center; gap: clamp(4px, 1vw, 12px); flex-shrink: 0; }
.therapy-word { font-size: clamp(20px, 3vh, 34px); font-weight: 700; letter-spacing: -0.5px; }
.therapy-image-wrap { width: 100%; display: flex; align-items: center; justify-content: center; flex: 1 1 0; min-height: 0; position: relative; }
.therapy-image-wrap img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.therapy-empty { color: var(--text-tertiary); text-align: center; }
.therapy-picture-meta { font-size: clamp(10px, 1.3vh, 12px); color: var(--text-tertiary); letter-spacing: 0.4px; text-transform: uppercase; flex-shrink: 0; }

/* Token Bar */
.token-bar-row { position: relative; display: flex; align-items: center; padding: clamp(4px, 1vh, 12px) clamp(10px, 2vw, 18px) clamp(4px, 1vh, 12px) clamp(60px, 8vw, 100px); min-height: clamp(40px, 6vh, 60px); flex-shrink: 0; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.reward-preview-img { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: clamp(40px, 6vh, 72px); height: clamp(40px, 6vh, 72px); border-radius: 12px; object-fit: cover; border: 2px solid var(--border-light); box-shadow: 0 4px 12px rgba(0,0,0,0.1); background: white; z-index: 2; }
.token-bar { display: flex; gap: 6px; flex: 1; flex-wrap: nowrap !important; overflow: hidden; }
.token-slot { flex: 1 1 0%; max-width: 28px; min-width: 12px; aspect-ratio: 1 / 1; border-radius: 50%; border: 2px solid var(--border); background: white; transition: all var(--transition); }
.token-slot.filled { background: linear-gradient(135deg, #f7c948, #f0a500); border-color: #d99000; transform: scale(1.08); box-shadow: 0 2px 8px rgba(240,165,0,0.4); }
.token-progress-text { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: clamp(11px, 1.4vh, 14px); font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.reward-preview { font-size: clamp(10px, 1.3vh, 12px); color: var(--text-secondary); text-align: center; margin-top: -6px; flex-shrink: 0; }
.reward-preview strong { color: var(--text-primary); }

/* Scoring Buttons and Tally */
.therapy-tally { text-align: center; padding: 0.5vh 1vw; font-size: clamp(11px, 1.4vh, 13px); color: var(--text-secondary); background: var(--bg-subtle); border-radius: 8px; flex-shrink: 0; }
.therapy-tally strong { color: var(--text-primary); }
.therapy-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: clamp(4px, 1vw, 12px); flex-shrink: 0; }
.therapy-btn { padding: clamp(8px, 1.5vh, 22px); font-size: clamp(12px, 1.8vh, 17px); font-weight: 600; border: none; border-radius: var(--radius); cursor: pointer; font-family: inherit; transition: all var(--transition); }
.therapy-btn-independent { background: #d1f2d8; color: #1d6b2a; }
.therapy-btn-independent:hover { background: #b5ecc1; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(29,107,42,0.15); }
.therapy-btn-cued { background: #fdeccd; color: #8a5700; }
.therapy-btn-cued:hover { background: #fadb99; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(138,87,0,0.15); }
.therapy-btn-incorrect { background: #ffdbd8; color: #8a1f16; }
.therapy-btn-incorrect:hover { background: #fbc3bd; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(138,31,22,0.15); }

/* Baseline Mode & Setup */
.therapy-shell.baseline-mode .therapy-btn-cued { display: none; }
.therapy-shell.baseline-mode .therapy-controls { grid-template-columns: 1fr 1fr; }
.therapy-shell.baseline-mode .token-bar-row,
.therapy-shell.baseline-mode .reward-preview { display: none; }
#therapy-baseline-section { border: 1px solid var(--border-light); border-radius: var(--radius); padding: 16px 20px; background: var(--bg-subtle); margin-bottom: 16px; }
#therapy-baseline-section .section-label-small { margin-bottom: 8px; }
.reward-list { display: flex; gap: 10px; flex-wrap: wrap; }
.reward-thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: var(--bg-subtle); width: 84px; transition: all var(--transition); }
.reward-thumb:hover { background: #f0f0f2; }
.reward-thumb.selected { border-color: var(--accent); background: var(--accent-soft); }
.reward-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: white; }
.reward-thumb span { font-size: 11px; color: var(--text-secondary); text-align: center; }

/* Reward Overlay */
.reward-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.reward-card { background: white; border-radius: 20px; padding: 40px; text-align: center; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.reward-card h2 { font-size: 28px; margin-bottom: 8px; letter-spacing: -0.4px; }
.reward-image-wrap { margin: 24px 0; }
.reward-image-wrap img { max-width: 100%; max-height: 240px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* ============================================================ */
/* BIG-SCREEN PROBE CARD                                        */
/* ============================================================ */
.quick-probe-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; z-index: 1500; padding: 20px; animation: fadeIn 0.2s ease; }
.quick-probe-card { background: white; border-radius: 24px; padding: 32px; width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); display: flex; flex-direction: column; align-items: center; gap: 20px; animation: cardIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.quick-probe-top { width: 100%; display: flex; justify-content: center; align-items: center; position: relative; min-height: 28px; }
.quick-probe-close { position: absolute; top: -4px; right: -4px; background: transparent; border: none; font-size: 20px; color: var(--text-tertiary); cursor: pointer; padding: 6px 10px; border-radius: 8px; transition: background var(--transition), color var(--transition); font-family: inherit; line-height: 1; }
.quick-probe-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.quick-probe-hint { font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", "Lucida Sans Unicode", "Segoe UI", system-ui, sans-serif; font-size: 15px; font-weight: 600; color: var(--accent); text-align: center; line-height: 1.4; padding: 0 40px; }
.quick-probe-image-wrap { position: relative; width: 100%; height: 320px; background: #f5f5f7; border-radius: 20px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.quick-probe-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 20px; }
.quick-probe-sound-btn { position: absolute; top: 14px; right: 14px; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent); color: white; cursor: pointer; box-shadow: 0 6px 20px rgba(0,113,227,0.4), 0 2px 6px rgba(0,0,0,0.15); transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow var(--transition); display: flex; align-items: center; justify-content: center; padding: 0; z-index: 2; }
.quick-probe-sound-btn svg { width: 26px; height: 26px; display: block; }
.quick-probe-sound-btn:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(0,113,227,0.5), 0 3px 8px rgba(0,0,0,0.18); }
.quick-probe-sound-btn:active { transform: scale(0.95); }
.quick-probe-word { font-size: 42px; font-weight: 700; letter-spacing: -0.5px; text-align: center; color: var(--text-primary); }
.quick-probe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.quick-probe-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px 12px; border: none; border-radius: 16px; cursor: pointer; font-family: inherit; transition: all var(--transition); }
.quick-probe-btn-icon { font-size: 32px; line-height: 1; }
.quick-probe-btn-label { font-size: 16px; font-weight: 600; }
.quick-probe-btn-yes { background: #d1f2d8; color: #1d6b2a; }
.quick-probe-btn-yes:hover { background: #b5ecc1; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(29,107,42,0.18); }
.quick-probe-btn-no { background: #ffdbd8; color: #8a1f16; }
.quick-probe-btn-no:hover { background: #fbc3bd; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(138,31,22,0.18); }
.quick-probe-skip { background: transparent; border: none; color: var(--text-secondary); font-size: 14px; font-family: inherit; cursor: pointer; padding: 8px 16px; border-radius: 8px; transition: background var(--transition); }
.quick-probe-skip:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* ============================================================ */
/* RESPONSIVE / MOBILE MEDIA QUERIES                            */
/* ============================================================ */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; overflow: hidden; width: 100vw; height: 100vh; }
  .sidebar { width: 100%; height: auto; flex-shrink: 0; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; gap: 8px; border-right: none; border-bottom: 1px solid var(--border-light); }
  .sidebar-brand { display: none; }
  .workspace-switcher { display: none; }
  .sidebar-nav { flex-direction: row; flex: 1; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav-item { white-space: nowrap; width: auto; padding: 8px 12px; font-size: 13px; }
  .sidebar-footer { display: none; }
  .content { padding: 12px 12px 60px; max-width: 100%; width: 100%; height: 100%; overflow-y: auto; }
  
  /* Squeeze the therapy layout so it fits perfectly without scrolling */
  .therapy-shell { width: 100%; max-width: 100%; height: calc(100vh - 80px); }
  .therapy-stage { padding: 10px !important; gap: 10px !important; }
  .therapy-top { flex-wrap: wrap; justify-content: center; }
  .therapy-tools { flex-wrap: wrap; justify-content: center; width: 100%; margin-top: 8px; }
  .therapy-controls { gap: 6px; }
  .therapy-btn { padding: 12px 6px !important; font-size: 13px !important; }
}

@media (max-width: 768px) {
  .therapy-controls { grid-template-columns: 1fr; gap: 8px; }
  .therapy-btn { padding: 16px; font-size: 16px; }
  .token-bar-row { padding-left: 80px; }
  .reward-preview-img { width: 56px; height: 56px; left: 12px; }
  .field-row { grid-template-columns: 1fr; }
  .duplicate-options { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .assess-grid-header, .assess-row, .survey-row { grid-template-columns: 110px 1fr 1fr 1fr; }
  .assess-sound-ipa { font-size: 17px; }
  .names-header, .name-row { grid-template-columns: 30px 1fr 1fr; }
  .names-header > div:last-child, .name-row-edit { display: none; }
  .therapy-word { font-size: 26px; }
  .therapy-btn { padding: 14px; font-size: 15px; }
  .assess-cell-quick { min-height: 56px; }
  .assess-cell-probe { font-size: 10px; }
  .quick-probe-card { padding: 20px; gap: 14px; }
  .quick-probe-image-wrap { height: 220px; }
  .quick-probe-word { font-size: 32px; }
  .quick-probe-btn-icon { font-size: 26px; }
  .quick-probe-btn-label { font-size: 14px; }
  .quick-probe-btn { padding: 18px 8px; }
  .quick-probe-sound-btn { width: 46px; height: 46px; top: 10px; right: 10px; }
  .quick-probe-sound-btn svg { width: 22px; height: 22px; }
  .quick-probe-hint { font-size: 14px; padding: 0 32px; }
}

/* ============================================================ */
/* PRINT STYLES                                                 */
/* ============================================================ */
@media print {
  .sidebar, .modal-overlay, #admin-backup-tools, .card-actions, .btn, button, .status, .banner, .reward-overlay, .therapy-controls, .therapy-tools, .token-bar-row, .reward-preview { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: 100%; }
  body { background: white; font-size: 12pt; }
  .card, .child-card, .audit-table { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .audit-table { font-size: 10pt; }
  a { color: inherit; text-decoration: none; }
  h1, h2 { color: black; }
}

/* ============================================================ */
/* SETUP WELCOME SCREEN (APPLE STYLE)                           */
/* ============================================================ */
.setup-choice { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin-bottom: 12px; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius); cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.setup-choice:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(0, 113, 227, 0.12); }
.setup-icon { font-size: 28px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); border-radius: 14px; flex-shrink: 0; }
.setup-choice strong { display: block; font-size: 16px; color: var(--text-primary); margin-bottom: 4px; font-weight: 600; }
.setup-choice p { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.4; }
.setup-clinic { border-left: 6px solid #0071e3; }
.setup-clinic:hover { border-color: #0071e3; box-shadow: 0 8px 24px rgba(0, 113, 227, 0.15); }
.setup-solo { border-left: 6px solid #af52de; }
.setup-solo:hover { border-color: #af52de; box-shadow: 0 8px 24px rgba(175, 82, 222, 0.15); }
.setup-teacher { border-left: 6px solid #34c759; }
.setup-teacher:hover { border-color: #34c759; box-shadow: 0 8px 24px rgba(52, 199, 89, 0.15); }
.setup-parent { border-left: 6px solid #ff9500; }
.setup-parent:hover { border-color: #ff9500; box-shadow: 0 8px 24px rgba(255, 149, 0, 0.15); }

.login-signup-row { display: flex; gap: 12px; width: 100%; }
.login-signup-btn { flex: 1; padding: 12px; background: var(--bg-subtle); border: 1px solid var(--border-light); border-radius: var(--radius); color: var(--text-primary); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.login-signup-btn span { font-size: 22px; }
.login-signup-btn:hover { background: white; border-color: var(--accent); box-shadow: 0 4px 12px rgba(0, 113, 227, 0.12); transform: translateY(-2px); color: var(--accent); }

/* Play button on Library tiles */
.picture-tile-img-wrap { position: relative; display: block; width: 100%; height: 110px; }
.picture-tile-img-wrap img { width: 100%; height: 100%; object-fit: cover; background: #f0f0f2; }
.play-audio-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); border: none; box-shadow: 0 2px 8px rgba(0,0,0,0.15); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all 0.2s; z-index: 2; }
.play-audio-btn:hover { transform: scale(1.1); background: white; }

/* ============================================================ */
/* ANATOMY GAME STYLES (PREMIUM & RESPONSIVE)                   */
/* ============================================================ */
@keyframes anaPulse {
  50% { transform: translate(-50%,-50%) scale(1.4); box-shadow: 0 0 20px currentColor; }
}
@keyframes anaFlashText {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.95); }
}
#anatomy-game-modal .ana-flash-label { position: absolute; transform: translate(-50%, -50%); font-size: clamp(10px, 1.2vw, 14px); font-weight: 900; color: #ef4444; background: rgba(255, 255, 255, 0.95); padding: 6px 12px; border-radius: 8px; border: 2px solid #ef4444; pointer-events: none; z-index: 50; text-transform: uppercase; animation: anaFlashText 1.5s infinite; box-shadow: 0 4px 12px rgba(0,0,0,0.2); white-space: nowrap; }
#anatomy-game-modal .ana-flash-label::after { content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); border-width: 8px 6px 0; border-style: solid; border-color: #ef4444 transparent transparent transparent; }
#anatomy-game-modal .btn { position: absolute; width: clamp(32px, 5vw, 54px); height: clamp(32px, 5vw, 54px); border-radius: 50%; border: none; color: #fff; display: grid; place-items: center; cursor: pointer; transform: translate(-50%,-50%); box-shadow: 0 6px 16px rgba(0,0,0,0.15), inset 0 2px 4px rgba(255,255,255,0.3); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); z-index: 10; padding: 0; }
#anatomy-game-modal .btn svg { width: clamp(16px, 2vw, 24px); height: clamp(16px, 2vw, 24px); margin-left: 2px; }
#anatomy-game-modal .btn:hover { transform: translate(-50%,-50%) scale(1.1); box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
#anatomy-game-modal .btn:active { transform: translate(-50%,-50%) scale(0.95); }
#anatomy-game-modal .port { position: absolute; width: clamp(8px, 1.5vw, 12px); height: clamp(8px, 1.5vw, 12px); border-radius: 50%; background: #ffffff; transform: translate(-50%,-50%); pointer-events: none; z-index: 9; box-shadow: 0 1px 4px rgba(0,0,0,0.2); border: 2px solid; }
#anatomy-game-modal .handle { position: absolute; width: clamp(20px, 3vw, 30px); height: clamp(20px, 3vw, 30px); border-radius: 50%; background: #ffffff; border: 3px solid; cursor: grab; touch-action: none; transform: translate(-50%,-50%); box-shadow: 0 0 0 2px #ffffff, 0 4px 12px rgba(0,0,0,0.25); z-index: 8; transition: transform 0.1s ease, box-shadow 0.2s ease; }
#anatomy-game-modal .handle::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--handle-dot, #3b82f6); transition: background 0.2s ease; }
#anatomy-game-modal .handle.dragging { cursor: grabbing; z-index: 15; transform: translate(-50%,-50%) scale(1.15); box-shadow: 0 8px 20px rgba(0,0,0,0.35); }
#anatomy-game-modal .handle.ok { border-color: #10b981 !important; cursor: default; }
#anatomy-game-modal .handle.ok::after { background: #10b981 !important; }
#anatomy-game-modal .handle.bad { border-color: #ef4444 !important; }
#anatomy-game-modal .handle.bad::after { background: #ef4444 !important; }
#anatomy-game-modal .socket { position: absolute; width: clamp(14px, 2.5vw, 22px); height: clamp(14px, 2.5vw, 22px); border-radius: 50%; background: rgba(255,255,255,0.9); border: 3px solid; transform: translate(-50%,-50%); pointer-events: none; box-shadow: 0 0 0 3px #ffffff, 0 0 12px currentColor; z-index: 5; transition: all 0.2s ease; }
#anatomy-game-modal .socket.ok { background: #10b981; border-color: #10b981; box-shadow: 0 0 0 3px #ffffff, 0 0 15px #10b981; color: #10b981; }
#anatomy-game-modal .socket.bad { background: #ef4444; border-color: #ef4444; box-shadow: 0 0 0 3px #ffffff, 0 0 15px #ef4444; color: #ef4444; }
#anatomy-game-modal .socket.reveal { animation: anaPulse 0.9s infinite; }
#anatomy-game-modal .region { fill: currentColor; fill-opacity: 0.15; stroke: currentColor; stroke-width: 3; stroke-dasharray: 8 6; pointer-events: none; transition: all 0.3s; filter: drop-shadow(0 0 2px #ffffff) drop-shadow(0 0 4px #ffffff); }
#anatomy-game-modal .region.ok { fill-opacity: 0.25; stroke: #10b981; color: #10b981; stroke-dasharray: none; }
#anatomy-game-modal .region.bad { fill-opacity: 0.25; stroke: #ef4444; color: #ef4444; stroke-dasharray: none; }
#anatomy-game-modal .region.reveal { animation: anaRegionPulse 1.1s infinite; }
@keyframes anaRegionPulse { 50% { fill-opacity: 0.3; } }
#anatomy-game-modal .lbl { position: absolute; transform: translate(-50%, 0); font-size: clamp(10px, 1.5vw, 14px); font-weight: 800; color: #1e293b; background: rgba(255,255,255,0.95); padding: 6px 12px; border-radius: 20px; white-space: nowrap; pointer-events: none; margin-top: clamp(24px, 4vw, 36px); z-index: 11; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
#anatomy-game-modal .wire { stroke-width: 3.5; stroke-linecap: round; fill: none; transition: stroke 0.3s ease; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
#anatomy-game-modal .hud { display: flex; gap: clamp(4px, 1vw, 12px); flex-wrap: wrap; align-items: center; background: #1e293b; padding: clamp(6px, 1.5vh, 12px) clamp(12px, 2vw, 24px); border-radius: 100px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); width: fit-content; max-width: 100%; margin: 0 auto; border: 1px solid #334155; }
#anatomy-game-modal .hud button { padding: clamp(6px, 1vh, 10px) clamp(10px, 2vw, 20px); border: none; border-radius: 50px; background: #334155; color: #cbd5e1; font-size: clamp(12px, 1.5vw, 15px); font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
#anatomy-game-modal .hud button:hover { background: #475569; color: #fff; }
#anatomy-game-modal .hud button.active { background: #3b82f6; color: white; box-shadow: 0 0 15px rgba(59,130,246,0.5); }
#anatomy-game-modal .hud button.primary { background: #10b981; color: white; box-shadow: 0 0 15px rgba(16,185,129,0.4); }
#anatomy-game-modal .hud button.primary:hover { background: #059669; }
#anatomy-game-modal .hud button:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; background: #334155; }
#anatomy-game-modal #ana-status { font-size: clamp(11px, 1.5vw, 14px); font-weight: 600; color: #94a3b8; margin-left: 10px; }

@keyframes jumpBoar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}
@keyframes floatLaLa {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
  50% { opacity: 1; transform: translate(-50%, -30px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

/* ============================================================ */
/* QUICK FIX FOR SHORT SCREENS (A4 / Landscape)                 */
/* ============================================================ */
@media (max-height: 800px) {
  /* Hide the admin banner to save vertical space */
  #second-admin-banner { display: none !important; }
  
  /* Make the card buttons 2 columns so they fit */
  .card-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 4px !important;
  }
  
  .card-actions .btn-small {
    width: 100% !important;
    padding: 4px 2px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  /* Ensure the home screen content can scroll if needed, without showing ugly scrollbars */
  .content {
    overflow-y: auto !important;
  }
}

/* ============================================================ */
/* ALLOW THERAPY SCREENS TO SCROLL IF SCREEN IS TOO SHORT       */
/* ============================================================ */
.therapy-shell {
  height: 100% !important;
  overflow-y: auto !important; /* Allows scrolling if it gets too small */
}

/* ============================================================ */
/* EAR TRAINING SCREEN — pill strip active state                */
/* ============================================================ */
#screen-ear-training .btn-small.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

/* ============================================================ */
/* EAR TRAINING — Round 1 (Sound Anchor) animations             */
/* ============================================================ */
@keyframes earCharDrop {
  0%   { transform: translate(-50%, -50%) translateY(-200px) scale(0.6); opacity: 0; }
  70%  { transform: translate(-50%, -50%) translateY(15px) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(0) scale(1); opacity: 1; }
}
@keyframes earCharLift {
  0%   { transform: translate(-50%, -50%) translateY(0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(-200px) scale(0.6); opacity: 0; }
}
@keyframes earLetterScroll {
  0%   { left: -100%; }
  100% { left: 100%; }
}

/* ============================================================ */
/* FLUID SCROLL FIX (Overrides all previous .content rules)     */
/* ============================================================ */
.app-shell {
  height: 100dvh; /* Dynamic viewport height for mobile */
  max-height: 100dvh;
  overflow: hidden;
}

.content {
  height: 100%;
  overflow-y: auto;
  min-height: 0; /* THE MAGIC FIX: Forces the flex child to allow scrolling */
  display: flex;
  flex-direction: column;
}

/* ============================================================ */
/* CLUSTERS GRID LAYOUT FIX                                     */
/* ============================================================ */
#assess-cluster-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 20px;
}

.cluster-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  border: 1px solid var(--border-light);
  border-right: 6px solid var(--border-light); /* Default color */
  transition: all 0.2s;
}

.cluster-card-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.cluster-card-item .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cluster-card-item .label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.cluster-card-item .word {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Border colors for each cluster type */
.cluster-card-item.cat-sblends { border-right-color: #0071e3; } /* Blue */
.cluster-card-item.cat-lblends { border-right-color: #34c759; } /* Green */
.cluster-card-item.cat-rblends { border-right-color: #ff9500; } /* Orange */

/* ============================================================ */
/* FIX FOR STORY SCREEN BUTTONS & IMAGES                        */
/* ============================================================ */

/* Make the 3 scoring buttons side-by-side on tablet/desktop */
#screen-story .therapy-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 800px;
  margin: 10px auto;
}

/* Make buttons a nice size */
#screen-story .therapy-btn {
  padding: 14px 10px;
  font-size: 16px;
  border-radius: 12px;
}

/* Only stack them vertically on actual small phones */
@media (max-width: 600px) {
  #screen-story .therapy-controls {
    grid-template-columns: 1fr;
  }
}

/* Info Tooltip Icons */
.info-icon { 
  display: inline-flex; align-items: center; justify-content: center; 
  width: 16px; height: 16px; background: #0071e3; color: white; 
  border-radius: 50%; font-size: 11px; font-weight: bold; 
  cursor: help; margin-left: 6px; position: relative; 
}
.info-icon:hover::after { 
  content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; 
  transform: translateX(-50%); background: #1d1d1f; color: white; 
  padding: 8px 12px; border-radius: 6px; font-size: 12px; 
  white-space: normal; width: max-content; max-width: 250px; 
  z-index: 100; margin-bottom: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); 
  font-weight: normal; line-height: 1.4; text-align: center; 
  pointer-events: none; 
}