/*
 * Class-page "Your study tools" explorer (folders, Study Paths with a 7-step progress strip,
 * files; sort / delete mode / maximise / drag & drop) and the study-tool create form
 * (`tressle:open-create` → flashcards / mini quiz / study path). 2026 revamp — tokens only.
 * create.ts also loads this file on non-class pages for the create form.
 */

/* Study Path v2 tool colours not in tokens.css yet (same values in study-nav.css):
 * step 1 "Lesson" reuses the podcast blue; practice scenarios get a calm teal. */
:root { --tool-lesson: var(--tool-podcast); --tool-scenarios: #0f9e99; }
[data-tool='lesson'] { --tool-c: var(--tool-lesson); }
[data-tool='scenarios'] { --tool-c: var(--tool-scenarios); }

/* ───────────── toolbar ───────────── */
.fe-toolbar { display: flex; align-items: center; gap: var(--s-1); margin-left: auto; }
.fe-toolbar .fe-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-width: 40px; height: 40px; margin: 0; padding: 0 var(--s-3);
  background: transparent; color: var(--text-2); border: 1px solid transparent; border-radius: var(--r-pill); font: 600 var(--text-sm)/1 var(--font-body); cursor: pointer;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease), border-color var(--t-med) var(--ease), transform var(--t-fast) var(--ease);
}
.fe-toolbar .fe-icon:hover { background: var(--surface-3); color: var(--text); }
.fe-toolbar .fe-icon:active { transform: scale(.94); }
.fe-toolbar .fe-icon:focus-visible { outline: none; box-shadow: var(--ring); }
.fe-toolbar .fe-icon[hidden] { display: none; }
.fe-toolbar .fe-icon[aria-expanded='true'] { background: var(--surface-3); color: var(--text); }
.fe-sort-wrap { position: relative; display: inline-flex; }
/* "⋯" menu: New folder · Delete study tools · Expand */
.fe-menu { display: none; position: absolute; top: calc(100% + var(--s-2)); right: 0; z-index: 200; min-width: 210px; padding: var(--s-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3); text-align: left; }
.fe-menu.show { display: block; animation: t-pop var(--t-med) var(--ease) both; transform-origin: top right; }
.fe-menu .fe-menu-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 40px; margin: 0; padding: 0 var(--s-3); background: transparent; color: var(--text); border: 0; border-radius: var(--r-sm); font: 500 var(--text-sm)/1 var(--font-body); text-align: left; white-space: nowrap; cursor: pointer; transition: background-color var(--t-fast) var(--ease); }
.fe-menu .fe-menu-item[hidden] { display: none; }
.fe-menu .fe-menu-item > i { width: 16px; color: var(--text-2); text-align: center; }
.fe-menu .fe-menu-item:hover { background: var(--surface-2); }
.fe-menu .fe-menu-item:focus-visible { outline: none; box-shadow: var(--ring); }
.fe-menu .fe-trash > i { color: var(--danger); }
.fe-menu .fe-trash.active { color: var(--danger); font-weight: 700; }
#fe-sort-menu { display: none; position: absolute; top: calc(100% + var(--s-2)); right: 0; z-index: 200; min-width: 220px; padding: var(--s-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3); text-align: left; }
#fe-sort-menu.show { display: block; animation: t-pop var(--t-med) var(--ease) both; transform-origin: top right; }
#fe-sort-menu .sort-title { margin: 0; padding: var(--s-1) var(--s-3) var(--s-2); font: 700 var(--text-xs)/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
#fe-sort-menu .sort-option { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); width: 100%; min-height: 40px; margin: 0; padding: 0 var(--s-3); background: transparent; color: var(--text); border: 0; border-radius: var(--r-sm); font: 500 var(--text-sm)/1 var(--font-body); text-align: left; white-space: nowrap; cursor: pointer; transition: background-color var(--t-fast) var(--ease); }
#fe-sort-menu .sort-option:hover { background: var(--surface-2); }
#fe-sort-menu .sort-option:focus-visible { outline: none; box-shadow: var(--ring); }
#fe-sort-menu .sort-option i { color: var(--green-600); font-size: var(--text-xs); visibility: hidden; }
#fe-sort-menu .sort-option.is-active { font-weight: 700; }
#fe-sort-menu .sort-option.is-active i { visibility: visible; }

/* ───────────── list ───────────── */
main.class-main .study-tools-root { text-align: left; }
#tressle-explorer { position: relative; width: 100%; }
#tressle-explorer .your-materials { width: 100%; min-height: 120px; border-radius: var(--r-lg); font: 500 var(--text-sm)/1.4 var(--font-body); color: var(--text); transition: background-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease); }
#tressle-explorer .file-explorer-list, #tressle-explorer .file-explorer-list ul { list-style: none; margin: 0; padding: 0; }
#tressle-explorer .file-explorer-list { visibility: hidden; display: flex; flex-direction: column; gap: var(--s-1); }
#tressle-explorer .file-explorer-list li { position: relative; border-radius: var(--r-md); }
#tressle-explorer .file-explorer-list > li, #tressle-explorer .nested-list > li { animation: t-fade-up var(--t-med) var(--ease) both; }
#tressle-explorer .file-explorer-list ul.nested-list { display: none; margin: 2px 0 var(--s-1) var(--s-5); padding-left: var(--s-3); border-left: 2px solid var(--border); }
#tressle-explorer .file-explorer-list li.expanded > ul.nested-list { display: flex; flex-direction: column; gap: 2px; animation: fe-open var(--t-med) var(--ease) both; transform-origin: top; }
@keyframes fe-open { from { opacity: 0; transform: translateY(-6px) scaleY(.96); } to { opacity: 1; transform: none; } }

/* folder + study-path headers */
#tressle-explorer .folder-item > .name {
  display: flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2); border-radius: var(--r-md); cursor: pointer; user-select: none;
  white-space: nowrap; transition: background-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
#tressle-explorer .folder-item > .name:hover { background: var(--surface-2); }
#tressle-explorer .folder-item > .name:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer .folder-item > .name .trunc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#tressle-explorer .fe-chev { flex: none; display: grid; place-items: center; width: 20px; height: 20px; color: var(--text-3); font-size: 11px; transition: transform var(--t-med) var(--ease); }
#tressle-explorer .folder-item.expanded > .name > .fe-chev { transform: rotate(90deg); }
#tressle-explorer .fe-folder-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); font-size: var(--text-sm); transition: transform var(--t-med) var(--ease-spring); }
#tressle-explorer .folder-item > .name:hover .fe-folder-ico { transform: scale(1.08); }
#tressle-explorer .folder-item[data-foldertype='general'] > .name { font-weight: 700; }
#tressle-explorer .fe-count:not(:empty) { flex: none; min-width: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font: 700 var(--text-xs)/1.8 var(--font-body); text-align: center; }
#tressle-explorer .folder-item[data-foldertype='studypath'] { border: 1px solid var(--border); background: var(--surface); transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease); }
#tressle-explorer .folder-item[data-foldertype='studypath']:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
#tressle-explorer .folder-item[data-foldertype='studypath'] > .name .fe-folder-ico { background: var(--surface-2); color: var(--tool-path); }
#tressle-explorer .folder-item[data-foldertype='studypath'] > .name strong { flex: none; color: var(--text-2); font-weight: 600; }
#tressle-explorer .folder-item[data-foldertype='studypath'] > .name .trunc { flex: 0 1 auto; font-weight: 700; color: var(--text); }
#tressle-explorer .folder-item[data-foldertype='studypath'] > ul.nested-list { margin-right: var(--s-2); margin-bottom: var(--s-2); }

/* files */
#tressle-explorer .file-item > a { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2); border-radius: var(--r-md); color: var(--text); text-decoration: none; transition: background-color var(--t-med) var(--ease); }
#tressle-explorer .file-item > a:hover { background: var(--surface-2); color: var(--text); }
#tressle-explorer .file-item > a:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer .fe-tool-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--tool-c, var(--tool-docs)) 14%, var(--surface)); color: var(--tool-c, var(--tool-docs)); font-size: var(--text-sm); transition: transform var(--t-med) var(--ease-spring), background-color var(--t-med) var(--ease), color var(--t-med) var(--ease); }
#tressle-explorer .file-item > a:hover .fe-tool-ico { transform: scale(1.06); }
#tressle-explorer .material-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tressle-explorer .material-type { font-weight: 700; }
#tressle-explorer .nested-list .file-item .material-text .trunc { color: var(--text-2); font-weight: 400; }
#tressle-explorer .fe-open { flex: none; color: var(--text-3); font-size: var(--text-xs); opacity: 0; transform: translateX(-6px); transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease); }
#tressle-explorer .file-item > a:hover .fe-open, #tressle-explorer .file-item > a:focus-visible .fe-open { opacity: 1; transform: none; }
#tressle-explorer .fe-status { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--s-2); border-radius: var(--r-pill); background: var(--info-bg); color: var(--info); font: 600 var(--text-xs)/1.6 var(--font-body); }
#tressle-explorer .fe-status-spin { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tt-spin2 .8s linear infinite; }
#tressle-explorer .empty-msg { padding: var(--s-2) var(--s-3); color: var(--text-3); font-size: var(--text-xs); font-style: italic; animation: none; }

/* ───────────── Study Path: calm collapsed line ("3/6" + thin bar), vertical stepper when open ───────────── */
#tressle-explorer .fe-progress { flex: none; display: inline-flex; align-items: center; gap: var(--s-2); margin-left: auto; padding-left: var(--s-2); }
#tressle-explorer .fe-progress-bar { position: relative; display: block; width: 44px; height: 4px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
#tressle-explorer .fe-progress-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--green-500); transition: width var(--t-slow) var(--ease); }
#tressle-explorer .fe-progress-text { min-width: 26px; font: 600 var(--text-xs)/1 var(--font-body); color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
#tressle-explorer .fe-progress.is-complete .fe-progress-text { color: var(--green-700); }

#tressle-explorer .file-explorer-list ul.fe-stepper { gap: 2px; margin: 0 var(--s-2) var(--s-2) var(--s-2); padding: var(--s-1) 0 0; border-left: 0; border-top: 1px solid var(--border); }
#tressle-explorer .fe-stepitem { position: relative; }
/* the line linking one step's icon to the next */
#tressle-explorer .fe-stepitem:not(:last-child)::after { content: ''; position: absolute; left: 51px; top: 42px; bottom: -8px; width: 2px; border-radius: 2px; background: var(--border); pointer-events: none; }
#tressle-explorer .fe-stepitem.is-done:not(:last-child)::after { background: var(--green-200); }
#tressle-explorer .fe-stepitem > a, #tressle-explorer .fe-step-row { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-1) var(--s-2); border-radius: var(--r-md); color: var(--text); text-decoration: none; }
#tressle-explorer a.fe-step-row:hover { background: var(--surface-2); color: var(--text); }
#tressle-explorer a.fe-step-row:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer .fe-step-num { flex: none; width: 16px; font: 600 var(--text-xs)/1 var(--font-body); color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
#tressle-explorer .fe-stepitem .fe-tool-ico { position: relative; z-index: 1; border-radius: 50%; }
#tressle-explorer .fe-stepitem .material-text { display: flex; flex-direction: column; gap: 1px; white-space: normal; }
#tressle-explorer .fe-stepitem .material-type { font-weight: 600; }
#tressle-explorer .fe-step-sub { font: 400 var(--text-xs)/1.3 var(--font-body); color: var(--text-3); }
#tressle-explorer .fe-open-text { margin-right: var(--s-1); font: 600 var(--text-xs)/1 var(--font-body); }
#tressle-explorer .fe-stepitem .fe-open { display: inline-flex; align-items: center; opacity: 1; transform: none; color: var(--text-3); }
#tressle-explorer .fe-stepitem > a:hover .fe-open, #tressle-explorer a.fe-step-row:hover .fe-open { color: var(--green-700); }
/* missing steps: outlined grey icon; the next one is gently highlighted */
#tressle-explorer .fe-step-missing .fe-tool-ico { background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 1.5px var(--border-strong); }
#tressle-explorer .fe-step-missing .material-type { color: var(--text-2); font-weight: 500; }
#tressle-explorer .fe-step-missing.is-next .material-type { color: var(--text); font-weight: 600; }
#tressle-explorer .fe-step-missing.is-next .fe-step-sub { color: var(--green-700); font-weight: 600; }
#tressle-explorer .fe-step-missing.is-next .fe-tool-ico { color: var(--tool-c); box-shadow: inset 0 0 0 1.5px var(--tool-c); }
#tressle-explorer .fe-stepitem.is-error .fe-tool-ico { background: var(--danger-bg); color: var(--danger); }
#tressle-explorer .fe-stepitem.is-error .fe-step-sub { color: var(--danger); }
#tressle-explorer .fe-step-create {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0 0 0 auto; padding: 0 var(--s-3);
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); border-radius: var(--r-pill); font: 600 var(--text-xs)/1 var(--font-body); cursor: pointer;
  transition: background-color var(--t-med) var(--ease), border-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-fast) var(--ease);
}
#tressle-explorer .fe-step-create:hover { background: var(--green-50); border-color: var(--green-600); color: var(--green-800); }
#tressle-explorer .fe-step-create:active { transform: scale(.96); }
#tressle-explorer .fe-step-create:focus-visible { outline: none; box-shadow: var(--ring); }
/* only the next step gets a real button; later ones stay quiet text links */
#tressle-explorer .is-pending .fe-step-create { border-color: transparent; background: transparent; color: var(--text-3); }
#tressle-explorer .is-pending .fe-step-create:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
#tressle-explorer .is-next .fe-step-create { background: var(--green-600); border-color: var(--green-600); color: var(--surface); }
#tressle-explorer .is-next .fe-step-create:hover { background: var(--green-700); border-color: var(--green-700); color: var(--surface); }
/* Explain it back (24 h spaced recall): quiet clock while locked, a warm "Ready to explain" once unlocked */
#tressle-explorer .is-explain-locked .fe-step-sub { color: var(--text-3); }
#tressle-explorer .is-explain-locked .fe-step-sub i { margin-right: 2px; }
#tressle-explorer .is-explain-ready > a { background: color-mix(in srgb, var(--tool-teach) 10%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tool-teach) 45%, var(--surface)); }
#tressle-explorer .is-explain-ready > a:hover { background: color-mix(in srgb, var(--tool-teach) 18%, var(--surface)); }
#tressle-explorer .fe-ready-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px var(--s-2); border-radius: var(--r-pill); background: color-mix(in srgb, var(--tool-teach) 24%, var(--surface)); color: color-mix(in srgb, var(--tool-teach) 35%, var(--text)); font: 700 0.6875rem/1.6 var(--font-body); }
#tressle-explorer .fe-ready-chip i { font-size: 0.625rem; animation: fe-ring 2.4s var(--ease) 600ms 2; transform-origin: 50% 10%; }
#tressle-explorer .fe-ready-dot { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-left: auto; border-radius: 50%; background: color-mix(in srgb, var(--tool-teach) 24%, var(--surface)); color: color-mix(in srgb, var(--tool-teach) 35%, var(--text)); font-size: 0.625rem; }
#tressle-explorer .fe-ready-dot + .fe-progress { margin-left: 0; }
@keyframes fe-ring { 0%, 30%, 100% { transform: rotate(0); } 6% { transform: rotate(14deg); } 12% { transform: rotate(-12deg); } 18% { transform: rotate(8deg); } 24% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { #tressle-explorer .fe-ready-chip i { animation: none; } }
#tressle-explorer .fe-step-create.is-busy { opacity: .6; cursor: progress; }
#tressle-explorer .fe-step-create.is-busy i { animation: tt-spin2 .9s linear infinite; }

/* stand-alone deck: "1/6 ⌄" toggle + the same stepper below the row */
#tressle-explorer .file-item.has-path { display: flex; flex-wrap: wrap; align-items: center; }
#tressle-explorer .file-item.has-path > a { flex: 1 1 0; min-width: 0; }
#tressle-explorer .fe-path-toggle {
  flex: none; display: inline-flex; align-items: center; gap: var(--s-2); min-height: 36px; margin: 0 var(--s-1) 0 0; padding: 0 var(--s-2);
  background: transparent; color: var(--text-2); border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer; transition: background-color var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
#tressle-explorer .fe-path-toggle:hover { background: var(--surface-2); border-color: var(--border); }
#tressle-explorer .fe-path-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer .fe-path-toggle .fe-progress { margin: 0; padding: 0; }
#tressle-explorer .fe-path-toggle .fe-chev { transition: transform var(--t-med) var(--ease); }
#tressle-explorer .file-item.path-open > .fe-path-toggle .fe-chev { transform: rotate(180deg); }
#tressle-explorer .file-item > ul.fe-stepper { display: none; flex-basis: 100%; }
#tressle-explorer .file-item.path-open > ul.fe-stepper { display: flex; flex-direction: column; animation: fe-open var(--t-med) var(--ease) both; transform-origin: top; }
#tressle-explorer.edit-on .fe-path-toggle { margin-right: 44px; }

/* ───────────── delete mode ───────────── */
#tressle-explorer .fe-edit-note { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3); border-radius: var(--r-md); background: var(--danger-bg); color: var(--danger); font: 600 var(--text-sm)/1.5 var(--font-body); animation: t-fade-up var(--t-med) var(--ease) both; }
#tressle-explorer .fe-edit-note[hidden] { display: none; }
#tressle-explorer .fe-edit-note > span { flex: 1; }
#tressle-explorer .fe-edit-done { min-height: 36px; margin: 0; padding: 0 var(--s-4); background: var(--danger); color: var(--surface); border: 0; border-radius: var(--r-pill); font: 700 var(--text-sm)/1 var(--font-body); cursor: pointer; }
#tressle-explorer .fe-edit-done:hover { filter: brightness(.92); }
#tressle-explorer .fe-edit-done:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer .trash-icon { display: none; position: absolute; top: 4px; right: var(--s-1); z-index: 5; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0; background: var(--surface); border: 0; border-radius: 50%; color: var(--danger); font-size: var(--text-lg); cursor: pointer; transition: transform var(--t-fast) var(--ease-spring), background-color var(--t-med) var(--ease); }
#tressle-explorer .trash-icon:hover { background: var(--danger-bg); transform: scale(1.12); }
#tressle-explorer .trash-icon:active { transform: scale(.9); }
#tressle-explorer .trash-icon:focus-visible { outline: none; box-shadow: var(--ring); }
#tressle-explorer.edit-on .trash-icon { display: grid; animation: t-pop var(--t-med) var(--ease-spring) both; }
#tressle-explorer.edit-on .folder-item > .name, #tressle-explorer.edit-on .file-item > a { padding-right: 44px; }
#tressle-explorer.edit-on .fe-open { display: none; }

/* ───────────── drag & drop ───────────── */
#tressle-explorer.can-edit li[draggable='true'] > .name, #tressle-explorer.can-edit li[draggable='true'] > a { cursor: grab; }
#tressle-explorer.can-edit li[draggable='true'] > .name:active, #tressle-explorer.can-edit li[draggable='true'] > a:active { cursor: grabbing; }
#tressle-explorer .file-explorer-list li.dragging { opacity: .45; background: var(--info-bg); }
#tressle-explorer.is-dragging .folder-item[data-foldertype='general'] > .name { box-shadow: inset 0 0 0 2px var(--green-200); }
#tressle-explorer .file-explorer-list li.drag-over-folder { background: var(--green-50); outline: 2px dashed var(--green-500); outline-offset: -2px; }
#tressle-explorer .file-explorer-list li.drag-over-folder > .name { background: var(--green-100); }
#tressle-explorer.drag-over-root .your-materials { background: var(--green-50); box-shadow: inset 0 0 0 2px var(--green-500); }
#tressle-explorer .invalid-drop { background: var(--danger-bg) !important; outline: 2px dashed var(--danger) !important; outline-offset: -2px; }
#tressle-explorer .rename-input { display: block; width: 100%; min-height: 40px; margin: 2px 0; padding: 0 var(--s-3); box-sizing: border-box; background: var(--surface); color: var(--text); border: 1px solid var(--green-600); border-radius: var(--r-md); box-shadow: var(--ring); font: 600 var(--text-sm)/1.4 var(--font-body); outline: none; }
#tressle-explorer .folder-item.is-new > .name { animation: fe-flash 1.2s var(--ease) both; }
@keyframes fe-flash { 0% { background: var(--green-100); } 100% { background: transparent; } }

/* ───────────── empty state ───────────── */
#tressle-explorer .fe-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-8) var(--s-4); text-align: center; background: var(--bg); border-radius: var(--r-lg); animation: t-fade-up var(--t-slow) var(--ease) both; }
#tressle-explorer .fe-empty[hidden] { display: none; }
#tressle-explorer .fe-empty-art { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--green-100); color: var(--green-700); font-size: var(--text-xl); }
#tressle-explorer .fe-empty-title { margin: 0; font: 600 var(--text-md)/1.3 var(--font-body); color: var(--text-2); }
#tressle-explorer .fe-empty-text { max-width: 380px; margin: 0; font-size: var(--text-sm); line-height: 1.55; color: var(--text-2); }
#tressle-explorer .fe-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin-top: var(--s-3); }
#tressle-explorer .fe-empty-actions:empty { display: none; }
#tressle-explorer .fe-empty-primary, #tressle-explorer .fe-empty-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; margin: 0; padding: 0 var(--s-5); border: 1px solid transparent; border-radius: var(--r-pill);
  font: 600 var(--text-sm)/1 var(--font-body); cursor: pointer; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), background-color var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
#tressle-explorer .fe-empty-primary { background: var(--green-600); color: var(--surface); box-shadow: var(--shadow-2); }
#tressle-explorer .fe-empty-primary:hover { background: var(--green-700); transform: translateY(-2px); box-shadow: var(--shadow-3); }
#tressle-explorer .fe-empty-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
#tressle-explorer .fe-empty-secondary:hover { background: var(--green-50); border-color: var(--green-600); color: var(--green-700); transform: translateY(-1px); }
#tressle-explorer .fe-empty-primary:active, #tressle-explorer .fe-empty-secondary:active { transform: scale(.97); }
#tressle-explorer .fe-empty-primary:focus-visible, #tressle-explorer .fe-empty-secondary:focus-visible { outline: none; box-shadow: var(--ring); }

@media (max-width: 560px) {
  .fe-toolbar .fe-add .fe-icon-label { display: none; }
  .fe-toolbar .fe-icon { min-width: 44px; height: 44px; }
  #tressle-explorer .fe-progress-bar { display: none; }
  #tressle-explorer .file-explorer-list ul.nested-list { margin-left: var(--s-3); padding-left: var(--s-2); }
  #tressle-explorer .file-explorer-list ul.fe-stepper { margin-left: var(--s-1); margin-right: var(--s-1); padding-left: 0; }
  #tressle-explorer .folder-item[data-foldertype='studypath'] > .name strong { font-size: var(--text-xs); }
}

/* ───────────── info modal ("Whoops!") ───────────── */
.fe-modal-overlay, .tt-create-overlay { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: var(--s-4); overflow-y: auto; background: var(--scrim); animation: t-overlay-in var(--t-med) var(--ease) both; }
.fe-modal { width: min(380px, 100%); box-sizing: border-box; padding: var(--s-6); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); font-family: var(--font-body); color: var(--text); text-align: center; animation: t-modal-in var(--t-slow) var(--ease-spring) both; }
.fe-modal-badge { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--warning-bg); color: var(--warning); font-size: var(--text-lg); }
.fe-modal h4 { margin: var(--s-3) 0 var(--s-2); font: 700 var(--text-lg)/1.3 var(--font-display); color: var(--text); }
.fe-modal p { margin: 0 0 var(--s-5); font-size: var(--text-sm); line-height: 1.5; color: var(--text-2); }
.fe-modal .fe-modal-ok { min-width: 120px; min-height: 44px; margin: 0; padding: 0 var(--s-6); background: var(--green-600); color: var(--surface); border: 0; border-radius: var(--r-pill); font: 600 var(--text-sm)/1 var(--font-body); cursor: pointer; transition: background-color var(--t-med) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease); }
.fe-modal .fe-modal-ok:hover { background: var(--green-700); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.fe-modal .fe-modal-ok:active { transform: scale(.97); }
.fe-modal .fe-modal-ok:focus-visible { outline: none; box-shadow: var(--ring); }

/* ───────────── create form (flashcards / mini quiz / study path) ───────────── */
.tt-create-card {
  position: relative; width: min(480px, 100%); margin: auto; box-sizing: border-box; padding: var(--s-6); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  font: 400 var(--text-sm)/1.5 var(--font-body); color: var(--text); text-align: left; animation: t-modal-in var(--t-slow) var(--ease-spring) both;
}
.tt-create-card.is-shaking { animation: t-shake var(--t-slow) var(--ease); }
.tt-create-card p { margin: 0; }
.tt-create-head { display: flex; align-items: flex-start; gap: var(--s-3); padding-right: var(--s-10); }
.tt-create-badge { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-md); background: color-mix(in srgb, var(--tool-c) 12%, var(--surface)); color: var(--tool-c); font-size: var(--text-lg); }
.tt-create-card .tt-create-heading { margin: 0; font: 800 var(--text-xl)/1.2 var(--font-display); color: var(--text); }
.tt-create-card .tt-create-sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-2); }
.tt-create-card .tt-create-close { position: absolute; top: var(--s-3); right: var(--s-3); display: grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0; background: transparent; border: 0; border-radius: 50%; color: var(--text-2); font-size: var(--text-md); cursor: pointer; transition: background-color var(--t-med) var(--ease), transform var(--t-fast) var(--ease); }
.tt-create-card .tt-create-close:hover { background: var(--surface-3); color: var(--text); }
.tt-create-card .tt-create-close:active { transform: scale(.9); }
.tt-create-card .tt-create-close:focus-visible { outline: none; box-shadow: var(--ring); }
.tt-path-preview { display: flex; list-style: none; margin: var(--s-4) 0 0; padding: var(--s-3) var(--s-2); background: var(--surface-2); border-radius: var(--r-md); }
.tt-path-preview li { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: var(--s-1); font: 600 10px/1.2 var(--font-body); color: var(--text-2); text-align: center; animation: t-pop var(--t-med) var(--ease-spring) both; }
.tt-path-preview li:nth-child(2) { animation-delay: 50ms; } .tt-path-preview li:nth-child(3) { animation-delay: 100ms; } .tt-path-preview li:nth-child(4) { animation-delay: 150ms; } .tt-path-preview li:nth-child(5) { animation-delay: 200ms; } .tt-path-preview li:nth-child(6) { animation-delay: 250ms; } .tt-path-preview li:nth-child(7) { animation-delay: 300ms; }
.tt-path-preview li + li::before { content: ''; position: absolute; top: 14px; right: calc(50% + 17px); width: calc(100% - 34px); height: 2px; border-radius: 2px; background: var(--border-strong); }
.tt-path-dot { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface); color: var(--tool-c); box-shadow: inset 0 0 0 1.5px var(--border); font-size: 12px; }
.tt-path-preview li.is-first { color: var(--text); font-weight: 800; }
.tt-path-preview li.is-first .tt-path-dot { box-shadow: inset 0 0 0 2px var(--tool-c); }
.tt-create-source { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3) !important; padding: var(--s-2) var(--s-3); background: var(--green-50); border-radius: var(--r-md); font-size: var(--text-xs); color: var(--green-800); }
.tt-create-source span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-step { display: flex; gap: var(--s-3); margin-top: var(--s-4); }
.tt-step-num { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; background: color-mix(in srgb, var(--tool-c) 16%, var(--surface)); color: var(--text); font: 700 var(--text-xs)/1 var(--font-body); }
.tt-step-body { flex: 1; min-width: 0; }
.tt-step-body > p { margin-bottom: var(--s-2); font: 600 var(--text-sm)/1.6 var(--font-body); color: var(--text); }
.tt-create-card .tt-create-topic { display: block; width: 100%; min-height: 44px; margin: 0; padding: 0 var(--s-4); box-sizing: border-box; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-md); font: 400 var(--text-md)/1.4 var(--font-body); transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease); }
.tt-create-card .tt-create-topic:hover { border-color: var(--text-3); }
.tt-create-card .tt-create-topic:focus { outline: none; border-color: var(--green-600); box-shadow: var(--ring); }
.tt-create-group { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.tt-create-card .tt-pick { flex: 1 1 auto; min-width: 48px; min-height: 40px; margin: 0; padding: 0 var(--s-3); background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-md); font: 600 var(--text-sm)/1 var(--font-body); cursor: pointer; transition: background-color var(--t-med) var(--ease), border-color var(--t-med) var(--ease), color var(--t-med) var(--ease), transform var(--t-fast) var(--ease-spring), box-shadow var(--t-med) var(--ease); }
.tt-create-card .tt-pick:hover { background: var(--surface-2); border-color: var(--text-3); transform: translateY(-1px); }
.tt-create-card .tt-pick:active { transform: scale(.95); }
.tt-create-card .tt-pick:focus-visible { outline: none; box-shadow: var(--ring); }
.tt-create-card .tt-pick.active, .tt-create-card .tt-pick.active:hover { background: var(--green-600); border-color: var(--green-600); color: var(--surface); box-shadow: var(--shadow-1); }
.tt-create-foot { margin-top: var(--s-5); }
.tt-create-card .tt-generate { display: flex; align-items: center; justify-content: center; gap: var(--s-2); width: 100%; min-height: 52px; margin: 0; padding: 0 var(--s-6); background: var(--green-600); color: var(--surface); border: 0; border-radius: var(--r-pill); box-shadow: var(--shadow-2); font: 700 var(--text-md)/1 var(--font-body); cursor: pointer; transition: background-color var(--t-med) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), opacity var(--t-med) var(--ease); }
.tt-create-card .tt-generate:hover { background: var(--green-700); transform: translateY(-2px); box-shadow: var(--shadow-3); }
.tt-create-card .tt-generate:active { transform: scale(.98); box-shadow: var(--shadow-1); }
.tt-create-card .tt-generate:focus-visible { outline: none; box-shadow: var(--ring); }
.tt-create-card .tt-generate:disabled, .tt-create-card .tt-generate:disabled:hover { background: var(--green-600); opacity: .6; transform: none; box-shadow: none; cursor: progress; }
.tt-create-card.is-working .tt-generate i { animation: tt-spin2 1.4s linear infinite; }
.tt-progress, .pc-progress { position: relative; height: 6px; margin-top: var(--s-3); overflow: hidden; border-radius: var(--r-pill); background: var(--green-100); }
.tt-progress[hidden], .pc-progress[hidden] { display: none; }
.tt-progress span, .pc-progress span { position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: inherit; background: var(--green-600); animation: t-indeterminate 1.3s var(--ease) infinite; }
.tt-create-status:empty { display: none; }
.tt-create-status { margin-top: var(--s-3) !important; font-size: var(--text-sm); color: var(--text-2); text-align: center; }
.tt-create-status.is-error { color: var(--danger); font-weight: 600; }
.tt-create-status.is-success { color: var(--success); font-weight: 700; }
/* example topics under the topic field */
.tt-examples { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); margin-top: var(--s-2); }
.tt-examples-label { font-size: var(--text-xs); color: var(--text-3); }
.tt-create-card .tt-example { min-height: 32px; margin: 0; padding: 0 var(--s-3); background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-pill); font: 500 var(--text-xs)/1 var(--font-body); cursor: pointer; transition: background-color var(--t-med) var(--ease), border-color var(--t-med) var(--ease); }
.tt-create-card .tt-example:hover { background: var(--green-50); border-color: var(--green-500); }
.tt-create-card .tt-example:focus-visible { outline: none; box-shadow: var(--ring); }
.tt-create-form[hidden], .tt-creating[hidden] { display: none; }
/* "Creating…": the steps light up one after another; the button gives way to the progress bar */
.tt-create-card.is-working .tt-generate, .tt-create-card.is-done .tt-generate { display: none; }
.tt-creating { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin-top: var(--s-5); padding: var(--s-5) var(--s-4); background: var(--surface-2); border-radius: var(--r-lg); text-align: center; animation: t-fade-up var(--t-med) var(--ease) both; }
.tt-creating-steps { display: flex; gap: var(--s-2); margin: 0 0 var(--s-2); padding: 0; list-style: none; }
.tt-creating-steps li { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 1.5px var(--border); font-size: var(--text-sm); animation: tt-light 2.4s var(--ease) infinite; animation-delay: calc(var(--i, 0) * 280ms); }
@keyframes tt-light { 0%, 100% { color: var(--text-3); transform: none; box-shadow: inset 0 0 0 1.5px var(--border); } 18% { color: var(--tool-c); transform: translateY(-4px); box-shadow: inset 0 0 0 2px var(--tool-c); } 40% { color: var(--tool-c); transform: none; box-shadow: inset 0 0 0 2px var(--tool-c); } }
.tt-create-card.is-done .tt-creating-steps li { animation: none; color: var(--tool-c); box-shadow: inset 0 0 0 2px var(--tool-c); }
.tt-create-card .tt-creating-title { font: 700 var(--text-md)/1.4 var(--font-display); color: var(--text); overflow-wrap: anywhere; }
.tt-create-card .tt-creating-eta { font-size: var(--text-sm); color: var(--text-2); }
@keyframes tt-spin2 { to { transform: rotate(360deg); } }
@keyframes t-overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes t-modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes t-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@media (max-width: 480px) {
  .tt-create-card { padding: var(--s-5) var(--s-4); }
  .tt-step-num { display: none; }
}
