* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f7f7fb; color: #222; }
.admin-nav {
    display: flex; align-items: center; gap: 20px; padding: 14px 24px;
    background: #2f3542; color: white;
}
/* The padding sits on every link, not just the active one, so the bar does not
   shift when you move between pages. */
.admin-nav a { color: white; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.admin-nav a:hover { background: rgba(255,255,255,0.10); }
.admin-nav a.active { background: rgba(255,255,255,0.18); font-weight: 600; }
.admin-nav .brand { font-weight: bold; margin-right: auto; padding-left: 0; }
.admin-nav .brand:hover { background: none; }
.logout-form { margin-left: auto; }
.logout-form button { background: none; border: 1px solid white; color: white; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

.admin-main { max-width: 960px; margin: 0 auto; padding: 24px; }
h1 { margin-top: 0; }

.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
    background: white; border-radius: 12px; padding: 16px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.card .meta { color: #666; font-size: 0.9rem; }
.card .actions { display: flex; gap: 8px; }

.btn {
    display: inline-block; padding: 8px 14px; border-radius: 8px; border: none;
    background: #4b7bec; color: white; cursor: pointer; text-decoration: none; font-size: 0.95rem;
}
.btn.secondary { background: #a4b0be; }
.btn.danger { background: #eb3b5a; }

form.stacked { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
form.stacked label { font-weight: 600; display: block; margin-bottom: 4px; }
form.stacked input[type=text], form.stacked input[type=number], form.stacked input[type=password],
form.stacked input[type=email], form.stacked select, form.stacked textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 1rem;
}
fieldset { border: 1px solid #ddd; border-radius: 8px; padding: 12px 16px; }
legend { font-weight: 600; padding: 0 6px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.checkbox-grid label { font-weight: normal; display: flex; align-items: center; gap: 6px; }
.checkbox-grid img { width: 48px; height: 48px; object-fit: contain; }
.pair-row { display: flex; gap: 8px; align-items: center; }
.pair-row select { flex: 1; }
.pair-row input { width: 200px; }
.level-row { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
/* An author "display" declaration beats the browser's own [hidden] { display: none },
   so hiding a row from JS needs this rule to actually take effect. */
.level-row[hidden] { display: none; }
.level-row label { display: flex; gap: 6px; align-items: center; margin: 0; font-size: 0.9rem; color: #666; }
.level-row input { width: 90px; }
.level-label { width: 70px; font-weight: bold; }
.token-box { font-family: monospace; background: #eee; padding: 4px 8px; border-radius: 6px; }
a.token-box { color: #2d5fd0; text-decoration: none; display: inline-block; }
a.token-box:hover { text-decoration: underline; background: #e3e8f5; }

/* A field that is meaningless right now (posture duration with the reminder off).
   It stays readonly rather than disabled so its value is still submitted. */
.is-disabled { background: #f0f0f0; color: #999; }

/* Cursor hotspot picker */
#cursor-pick-box {
    position: relative; display: inline-block; margin: 6px 0;
    border: 1px solid #ccc; border-radius: 6px; padding: 8px;
    /* Checkerboard, so a transparent cursor image is actually visible. */
    background-color: #fff;
    background-image: linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%),
                      linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    cursor: crosshair;
}
#cursor-pick-image { display: block; image-rendering: pixelated; }
#cursor-pick-marker {
    position: absolute; left: 0; top: 0; width: 13px; height: 13px; margin: 8px 0 0 8px;
    transform: translate(-6px, -6px); pointer-events: none;
    background:
        linear-gradient(to right, transparent 6px, #eb3b5a 6px, #eb3b5a 7px, transparent 7px),
        linear-gradient(to bottom, transparent 6px, #eb3b5a 6px, #eb3b5a 7px, transparent 7px);
}
.hint { color: #666; font-size: 0.9rem; }

/* Media library */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 16px;
}
.filter-bar select, .filter-bar input[type=text] {
    padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem;
}
.filter-bar input[type=text] { min-width: 180px; }
.view-toggle { margin-left: auto; display: flex; gap: 4px; }
.view-toggle a {
    padding: 7px 12px; border-radius: 6px; background: #e4e6ea; color: #333; text-decoration: none; font-size: 0.9rem;
}
.view-toggle a.active { background: #4b7bec; color: white; }

.bulk-actions { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }

/* Now that editing lives in a modal, a tile is only a picture and a name, so more of
   them fit on screen - which was the whole point. */
.asset-list.grid-view {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.asset-list.grid-view .asset-item {
    background: white; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative; border: 2px solid transparent;
}
.asset-list.grid-view .asset-body { display: flex; flex-direction: column; gap: 8px; }
.asset-list.grid-view .asset-preview { height: 100px; display: flex; align-items: center; justify-content: center; }
.asset-list.grid-view .asset-preview img { max-width: 100%; max-height: 100px; object-fit: contain; }
.asset-list.grid-view .asset-select { position: absolute; top: 10px; left: 10px; z-index: 1; }
.asset-list.grid-view .asset-edit { position: absolute; top: 8px; right: 8px; }

.asset-list.list-view { display: flex; flex-direction: column; gap: 8px; }
.asset-list.list-view .asset-item {
    background: white; border-radius: 10px; padding: 10px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; align-items: center; gap: 14px; border: 2px solid transparent;
}
.asset-list.list-view .asset-body { flex: 1 1 auto; display: flex; align-items: center; gap: 14px; min-width: 0; }
.asset-list.list-view .asset-preview { width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.asset-list.list-view .asset-preview img { max-width: 40px; max-height: 40px; object-fit: contain; }
.asset-list.list-view .asset-info { flex: 1 1 auto; min-width: 120px; }

/* The whole body is one big checkbox label - selecting is what a teacher does here
   nine times out of ten. */
.asset-body { cursor: pointer; }
.asset-item.selected { border-color: #4b7bec !important; background: #eef2fb; }

/* Deliberately quiet: editing is the exception, and the pencil must never compete
   with the picture for attention. */
.asset-edit {
    background: none; border: none; border-radius: 6px; padding: 4px 7px;
    font-size: 1rem; line-height: 1; color: #666; cursor: pointer;
}
.asset-edit:hover { background: #e4e6ea; color: #222; }

.asset-edit-panel { width: min(460px, 100%); }
.asset-edit-panel form { padding: 16px 18px 0; display: flex; flex-direction: column; gap: 6px; }
.asset-edit-panel label { font-weight: 600; margin-top: 8px; }
.asset-edit-preview {
    height: 140px; display: flex; align-items: center; justify-content: center;
    background: white; border-radius: 10px; margin-bottom: 8px;
}
.asset-edit-preview img { max-width: 100%; max-height: 140px; object-fit: contain; }

/* Clamped rather than wrapped: a long filename used to push a tile two rows taller
   than its neighbours. The full name lives in the title attribute. */
.asset-name {
    font-weight: 600; overflow-wrap: anywhere; overflow: hidden;
    display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; line-clamp: 2;
}
.asset-list.list-view .asset-name { -webkit-line-clamp: 1; line-clamp: 1; }
.audio-icon { font-size: 2rem; }

.asset-rename { display: inline-flex; align-items: center; gap: 4px; }
.asset-rename input[type=text] { flex: 1 1 auto; padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; }
.asset-extension { color: #888; font-family: monospace; white-space: nowrap; }

/* Media library: folders, size, usage */
.notice { background: #fff4d6; border: 1px solid #e3c04a; border-radius: 8px; padding: 10px 14px; }
.library-size { color: #666; font-size: 0.9rem; }
.breadcrumb { margin: 10px 0; font-size: 0.95rem; }
.breadcrumb a { color: #2d5fd0; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.folder-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.folder-new { display: flex; gap: 8px; align-items: center; }
.folder-new input[type=text] { padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; }
/* Folders sit inside .asset-list next to the files, so they take their layout from
   whichever view is active rather than from a grid of their own. */
.folder-tile {
    background: white; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit;
}
.folder-tile:hover { background: #eef2fb; }
.folder-icon { font-size: 1.8rem; }
.asset-list.list-view .folder-tile {
    border-radius: 10px; padding: 10px 16px;
    flex-direction: row; align-items: center; gap: 14px;
}
.asset-list.list-view .folder-icon { font-size: 1.2rem; }
.asset-list.list-view .folder-name { flex: 1 1 auto; }
.folder-name { font-weight: 600; word-break: break-word; }
.bulk-move { display: flex; align-items: center; gap: 6px; }
.bulk-move label { font-weight: 600; }
.badge-inuse {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px;
    background: #d6f0d8; color: #256b2c; font-size: 0.75rem;
}

/* Asset picker */
.asset-field { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.asset-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 320px; min-height: 42px; }
.asset-chip {
    display: inline-flex; align-items: center; gap: 6px; background: white;
    border: 1px solid #ddd; border-radius: 8px; padding: 4px 8px; max-width: 220px;
}
.asset-chip img { width: 32px; height: 32px; object-fit: contain; }
.asset-chip-name { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-chip-remove { border: none; background: none; cursor: pointer; font-size: 1.1rem; color: #888; line-height: 1; }
.asset-chip-remove:hover { color: #eb3b5a; }
.asset-chip-empty { color: #888; font-size: 0.9rem; }

.asset-modal {
    position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.asset-modal[hidden] { display: none; }
.asset-modal-panel {
    background: #f7f7fb; border-radius: 14px; width: min(900px, 100%); max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.asset-modal-head, .asset-modal-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; background: white; border-bottom: 1px solid #e4e6ea;
}
.asset-modal-foot { border-bottom: none; border-top: 1px solid #e4e6ea; }
.asset-modal-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; }
.asset-modal-filters select, .asset-modal-filters input[type=text] {
    padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem;
}
.asset-modal-filters input[type=text] { flex: 1 1 180px; }
.asset-modal-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; padding: 0 18px 18px; overflow-y: auto;
}
.asset-modal-tile {
    background: white; border: 2px solid transparent; border-radius: 10px; padding: 10px;
    display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); font: inherit;
}
.asset-modal-tile img { width: 100%; height: 80px; object-fit: contain; }
.asset-modal-tile.chosen { border-color: #4b7bec; background: #eef2fb; }
.asset-modal-name { font-size: 0.85rem; word-break: break-word; text-align: center; }
.asset-modal-count { color: #666; font-size: 0.9rem; }
