/* ═══════════════════════════════════════════════════════════════
   admin.css — AgentWeb Admin Panel
   Uses the same CSS custom properties as common.css
   ═══════════════════════════════════════════════════════════════ */

/* ─── RESET COMMON BODY CONSTRAINTS ────────────────────────── */
body.admin-body {
    overflow: auto;
    height: auto;
    display: block;
    justify-content: unset;
    align-items: unset;
}

/* ─── LAYOUT ────────────────────────────────────────────────── */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ───────────────────────────────────────────────── */
.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow: hidden;
}

.sidebar-logo {
    padding: 28px 20px 20px;
    font-size: 15px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.08em;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border-left: 3px solid transparent;
    user-select: none;
}

.sidebar-nav-item:hover {
    color: var(--text);
    background: var(--accent-glow);
}

.sidebar-nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-glow);
    font-weight: 600;
}

.sidebar-nav-item .nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-bottom {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

/* ─── MAIN CONTENT ──────────────────────────────────────────── */
.admin-content {
    margin-left: 220px;
    flex: 1;
    background: var(--bg);
    min-height: 100vh;
    padding: 32px;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* ─── SECTION PANELS ────────────────────────────────────────── */
.admin-section {
    display: none;
    animation: fadeInSection 0.2s ease;
}

.admin-section.active {
    display: block;
}

@keyframes fadeInSection {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ─── CARDS ─────────────────────────────────────────────────── */
.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}

.admin-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

/* ─── FORM ELEMENTS ─────────────────────────────────────────── */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vocab-setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.vocab-setting-row .form-select {
    flex: 1 1 220px;
}

.vocab-placement-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.vocab-placement-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.vocab-setting-help {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.form-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.form-label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 10px;
}

.form-label .required {
    color: var(--hard);
    margin-left: 2px;
}

.btn-inline-refresh {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.7;
    line-height: 1;
}
.btn-inline-refresh:hover { opacity: 1; color: var(--accent); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: 'Inter', -apple-system, sans-serif;
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892B0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    color: #0A0E17;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: filter 0.15s, transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif;
}

.btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
    filter: brightness(0.96);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

.btn-ghost {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif;
}

.btn-ghost:hover {
    border-color: var(--text-muted);
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--hard);
    border-radius: 10px;
    color: var(--hard);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif;
    margin-left: auto;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.12);
}

.btn-danger {
    padding: 10px 20px;
    background: rgba(244, 67, 54, 0.08);
    border: 1px solid var(--hard);
    border-radius: 10px;
    color: var(--hard);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif;
}

.btn-danger:hover {
    background: rgba(244, 67, 54, 0.16);
}

/* Small button variant */
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 8px;
}

/* Icon-only button (sidebar theme toggle, etc.) */
.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    font-size: 16px;
    width: 100%;
}

.btn-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Theme toggle in sidebar — override .btn-icon width so rotation stays centered on the icon */
.btn-icon.theme-toggle-btn {
    width: auto;
    border: none;
    padding: 6px;
}

/* Logout button (sidebar bottom) */
.btn-logout {
    background: none;
    border: 1px solid rgba(244, 67, 54, 0.35);
    border-radius: 8px;
    color: var(--hard);
    cursor: pointer;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s;
    font-family: 'Inter', -apple-system, sans-serif;
}

.btn-logout:hover {
    background: rgba(244, 67, 54, 0.08);
}

/* ─── SEARCH BAR ────────────────────────────────────────────── */
.search-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 180px;
    padding: 9px 14px 9px 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238892B0' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    font-family: 'Inter', -apple-system, sans-serif;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ─── GROUP FILTER ──────────────────────────────────────────── */
.group-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 20px;
    min-height: 36px;
}

.group-filter-chip {
    padding: 5px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif;
}

.group-filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.group-filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0A0E17;
    font-weight: 600;
}

[data-theme="light"] .group-filter-chip.active {
    color: #fff;
}

/* ─── USERS GRID ────────────────────────────────────────────── */
.users-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.users-grid.grouped-summary-mode {
    grid-template-columns: 1fr;
    gap: 12px;
}

.group-user-row {
    --group-user-card-height: 186px;
    display: grid;
    grid-template-columns: minmax(260px, 310px);
    gap: 0;
    align-items: start;
}

.group-user-row.expanded {
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    gap: 12px;
}

.user-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.user-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.user-card-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-content: start;
}

.user-card-summary-left {
    min-height: var(--group-user-card-height);
    height: var(--group-user-card-height);
    padding: 16px 16px 14px;
    overflow: visible;
}

.user-summary-edit-btn {
    position: absolute;
    top: -10px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, transform 0.15s, background 0.15s;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.user-summary-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-2);
    transform: translateY(-1px);
}

.user-summary-edit-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.user-summary-main {
    min-width: 0;
    padding-right: 28px;
}

.user-summary-head {
    min-width: 0;
}

.user-summary-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-summary-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.summary-stat-pill {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px;
    background: var(--surface-2, rgba(255,255,255,0.04));
    border: 1px solid var(--border);
    border-radius: 12px;
}

.summary-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.summary-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

.user-card-detail-panel {
    min-width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    border-color: transparent;
    transform: translateX(-8px);
    box-shadow: none;
    cursor: default;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
}

.group-user-row.expanded .user-card-detail-panel {
    min-height: var(--group-user-card-height);
    height: var(--group-user-card-height);
    opacity: 1;
    pointer-events: auto;
    padding: 14px 16px;
    border-color: var(--border);
    transform: translateX(0);
}

.user-card-detail-panel:hover {
    transform: translateX(0);
    border-color: var(--border);
    box-shadow: none;
}

.user-detail-panel-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.user-detail-caps-row {
    margin: 2px 0 0;
}

.user-detail-last {
    margin-top: 2px;
}

.user-detail-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.2;
}

.user-card-id {
    font-size: 13px;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    color: var(--accent);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-last {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.user-card-rank {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.user-caps-row {
    display: flex;
    gap: 6px;
    margin: 8px 0 2px;
}

.user-cap-item {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: var(--surface-2, rgba(255,255,255,0.04));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 4px 6px 4px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.cap-status-lights {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
}

.status-light {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s, box-shadow 0.3s;
}
.status-light.green.active  { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.6); }
.status-light.yellow.active { background: #eab308; box-shadow: 0 0 4px rgba(234,179,8,0.6); }
.status-light.red.active    { background: #ef4444; box-shadow: 0 0 4px rgba(239,68,68,0.6); }
.user-cap-item:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.user-cap-icon {
    font-size: 14px;
    line-height: 1;
}

.user-cap-xp {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
    letter-spacing: -0.02em;
}

.user-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.level-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(94, 234, 212, 0.25);
}

.xp-badge {
    font-size: 12px;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    color: var(--text-muted);
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ─── TAB SWITCHER ──────────────────────────────────────────── */
.tab-switcher {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: 12px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 7px 16px;
    border: none;
    background: transparent;
    border-radius: 9px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    font-family: 'Inter', -apple-system, sans-serif;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    background: var(--accent);
    color: #0A0E17;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ─── RESULT PANEL ──────────────────────────────────────────── */
.admin-result {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 16px;
    padding: 24px 28px;
    margin-top: 24px;
    animation: fadeInSection 0.25s ease;
}

.admin-result.show {
    display: block;
}

.admin-result-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.result-url-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 12px;
}

.result-url-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--accent);
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    cursor: text;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-url-input:focus {
    border-color: var(--accent);
}

.result-copy-btn {
    padding: 10px 18px;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: 10px;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    font-family: 'Inter', -apple-system, sans-serif;
    flex-shrink: 0;
}

.result-copy-btn:hover {
    background: rgba(94, 234, 212, 0.2);
}

.result-expiry {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

#qrCode {
    display: inline-block;
    padding: 10px;
    background: #fff;
    border-radius: 10px;
}

/* ─── USER DRAWER ───────────────────────────────────────────── */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.user-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 400;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.user-drawer.show {
    transform: translateX(0);
}

.drawer-header {
    padding: 24px 24px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.drawer-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.drawer-close-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.drawer-body::-webkit-scrollbar {
    width: 4px;
}

.drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.drawer-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.drawer-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ─── Capability level grid (inside user drawer) ────────────── */
.cap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 4px;
}

.cap-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 6px 8px;
}

.cap-icon {
    font-size: 20px;
    line-height: 1;
}

.cap-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.cap-input {
    width: 100%;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 2px;
    outline: none;
    -moz-appearance: textfield;
}
.cap-input::-webkit-outer-spin-button,
.cap-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cap-input:focus { border-color: var(--accent); }

/* ─── KEY MODAL ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--card-shadow);
}

.modal-icon {
    font-size: 36px;
    text-align: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    margin-bottom: 2px;
}

.modal-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

/* ─── PASSWORD SHOW/HIDE TOGGLE ─────────────────────────────── */
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrap .form-input {
    flex: 1;
    padding-right: 40px;
}

.password-toggle-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.password-toggle-btn:hover {
    color: var(--text);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ─── LOADING OVERLAY ───────────────────────────────────────── */
.admin-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.admin-loading-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.admin-loading-overlay .loader-ring {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(94, 234, 212, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.admin-loading-label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── TOAST ─────────────────────────────────────────────────── */
.admin-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text);
    box-shadow: var(--card-shadow);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
}

.admin-toast.show {
    opacity: 1;
}

.admin-toast.success {
    border-color: var(--accent);
    color: var(--accent);
}

.admin-toast.error {
    border-color: var(--hard);
    color: var(--hard);
}

/* ─── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.empty-state-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ─── CONDITIONAL FORM BLOCK ────────────────────────────────── */
.conditional-block {
    display: none;
    padding: 16px;
    background: var(--surface-2);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.conditional-block.show {
    display: block;
}

/* ─── JSON SCHEMA HINT ──────────────────────────────────────── */
.json-schema-hint {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
.json-schema-hint summary {
    cursor: pointer;
    user-select: none;
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 4px 0;
}
.json-schema-hint summary:hover { opacity: 0.8; }
.json-schema-pre {
    margin: 8px 0 0;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre;
    overflow-x: auto;
}

/* ─── FORM ERROR ─────────────────────────────────────────────── */
.form-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--hard);
    line-height: 1.4;
}

/* ─── QUESTIONS LOAD STATUS ──────────────────────────────────── */
.lt-questions-status {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface-2);
}
.lt-questions-status.loading { color: var(--text-muted); font-style: italic; }
.lt-questions-status.ok      { color: var(--easy); border-color: var(--easy); background: rgba(94,234,212,0.06); }
.lt-questions-status.error   { color: var(--hard); border-color: var(--hard); background: rgba(244,67,54,0.06); }

/* ─── RADIO GROUP ───────────────────────────────────────────── */
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.radio-label input[type="radio"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* ─── TOOLS TOOLBAR ─────────────────────────────────────────── */
.tools-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tool-btn:hover {
    color: var(--text);
    background: var(--accent-glow);
    border-color: var(--accent);
}

.tool-btn.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: var(--accent);
    font-weight: 600;
}

.tool-btn svg {
    flex-shrink: 0;
}

.tools-panel {
    /* container for tool content panels */
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

/* ── Vocab tools section: stretch editor to bottom of viewport ── */
#sec-tools.admin-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#sec-tools .tools-toolbar {
    flex-shrink: 0;
}

#sec-tools .tools-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#tool-vocab.tool-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Search card stays at natural height */
#tool-vocab > .admin-card {
    flex-shrink: 0;
}

/* Editor area fills the rest */
#vocabMgrEditorArea {
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

/* ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .vocab-setting-row {
        align-items: stretch;
    }

    .vocab-placement-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* ─── LIGHT THEME OVERRIDES ─────────────────────────────────── */
[data-theme="light"] .admin-sidebar {
    background: var(--surface);
    border-right-color: var(--border);
}

[data-theme="light"] .sidebar-nav-item.active {
    background: rgba(15, 118, 110, 0.07);
}

[data-theme="light"] .sidebar-nav-item:hover {
    background: rgba(15, 118, 110, 0.05);
}

[data-theme="light"] .admin-content {
    background: var(--bg);
}

[data-theme="light"] .admin-card {
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .user-card {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .user-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select,
[data-theme="light"] .form-textarea {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-select:focus,
[data-theme="light"] .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

[data-theme="light"] .search-input {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="light"] .search-input:focus {
    border-color: var(--accent);
}

[data-theme="light"] .tab-switcher {
    background: var(--surface-2);
}

[data-theme="light"] .tab-btn.active {
    background: var(--accent);
    color: #fff;
}

[data-theme="light"] .btn-primary {
    color: #fff;
}

[data-theme="light"] .level-badge {
    background: rgba(15, 118, 110, 0.1);
    border-color: rgba(15, 118, 110, 0.3);
}

[data-theme="light"] .admin-result {
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .result-url-input {
    background: var(--surface-2);
}

[data-theme="light"] .result-copy-btn {
    background: rgba(15, 118, 110, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

[data-theme="light"] .result-copy-btn:hover {
    background: rgba(15, 118, 110, 0.16);
}

[data-theme="light"] .modal-card {
    background: var(--surface);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .user-drawer {
    background: var(--surface);
}

[data-theme="light"] .conditional-block {
    background: var(--surface-2);
}

[data-theme="light"] .admin-loading-overlay .loader-ring {
    border-color: rgba(15, 118, 110, 0.12);
    border-top-color: var(--accent);
}

[data-theme="light"] .admin-toast {
    background: var(--surface);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ─── RESPONSIVE — 900px BREAKPOINT ────────────────────────── */
@media (max-width: 900px) {
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        bottom: auto;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border);
        z-index: 200;
        padding: 0 8px;
    }

    .sidebar-logo {
        padding: 14px 16px;
        border-bottom: none;
        border-right: 1px solid var(--border);
        white-space: nowrap;
        flex-shrink: 0;
    }

    .sidebar-nav {
        flex: 1;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar-nav-item {
        padding: 14px 14px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 13px;
    }

    .sidebar-nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }

    .sidebar-bottom {
        border-top: none;
        border-left: 1px solid var(--border);
        padding: 8px;
        flex-direction: row;
        flex-shrink: 0;
    }

    .btn-icon,
    .btn-logout {
        width: auto;
        padding: 8px 12px;
        font-size: 12px;
    }

    .admin-content {
        margin-left: 0;
        padding: 20px 16px;
    }

    .user-drawer {
        width: 100%;
        max-width: 100%;
    }

    .users-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .group-user-row,
    .group-user-row.expanded {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .group-user-row {
        --group-user-card-height: auto;
    }

    .user-summary-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .user-card-detail-panel {
        transform: translateY(-6px);
    }

    .group-user-row.expanded .user-card-detail-panel {
        height: auto;
        transform: translateY(0);
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .users-grid {
        grid-template-columns: 1fr;
    }

    .user-summary-stats {
        grid-template-columns: 1fr;
    }

    .user-summary-edit-btn {
        top: 10px;
        right: 10px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-row {
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .admin-content {
        padding: 16px 12px;
    }

    .admin-card {
        padding: 20px 16px;
    }
}

/* ─── USER CARD ⋮ BUTTON ────────────────────────────────────── */

/* ─── TASK DETAIL MODAL ─────────────────────────────────────── */
.task-detail-card {
    width: 520px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.task-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.task-detail-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.task-detail-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.task-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 16px 24px;
    flex-shrink: 0;
}

.task-stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.task-stat-pill:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.task-stat-pill.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.task-stat-count {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Roboto Mono', monospace;
    color: var(--text);
}
.task-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* colour coding */
.task-stat-pill.stat-completed .task-stat-count { color: var(--easy); }
.task-stat-pill.stat-pending   .task-stat-count { color: var(--accent); }
.task-stat-pill.stat-expired   .task-stat-count { color: var(--hard); }

.task-detail-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-detail-list-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 0 4px;
    flex-shrink: 0;
}

.task-detail-item {
    display: grid;
    grid-template-columns: 40px 52px auto 1fr auto auto 24px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
}

.task-detail-item-type {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--accent-glow);
    color: var(--accent);
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
}

.task-detail-item-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 5px;
    text-align: center;
    white-space: nowrap;
}
.task-detail-item-status.st-completed { background: rgba(52,211,153,0.12); color: var(--easy); }
.task-detail-item-status.st-pending   { background: var(--accent-glow); color: var(--accent); }
.task-detail-item-status.st-expired   { background: rgba(248,113,113,0.12); color: var(--hard); }

.task-detail-item-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.task-detail-item-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.5;
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}

.task-detail-item-score,
.task-detail-item-xp {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid rgba(94,234,212,0.2);
    border-radius: 6px;
    padding: 1px 6px;
    white-space: nowrap;
    text-align: center;
}
.task-detail-item-xp {
    color: var(--easy);
    background: rgba(52,211,153,0.08);
    border-color: rgba(52,211,153,0.2);
}

.task-detail-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.7;
    margin-bottom: 8px;
}

#vocabAssignSection {
    margin-top: 8px;
}

.vocab-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 24px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

.vocab-assign-row:hover {
    background: rgba(94, 234, 212, 0.05);
    border-color: rgba(94, 234, 212, 0.25);
    color: var(--accent);
}

.vocab-assign-row-label {
    flex: 1;
    text-align: center;
}

.vocab-assign-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.vocab-assign-chevron.open {
    transform: rotate(180deg);
}

.vocab-assign-list-collapsed {
    max-height: 0;
    overflow: hidden !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0;
    transition: max-height 0.25s ease, margin-top 0.25s ease;
}

.vocab-assign-list-expanded {
    max-height: 600px;
    overflow-y: auto !important;
    margin-top: 8px;
    transition: max-height 0.25s ease, margin-top 0.25s ease;
}

.task-detail-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}

.task-detail-more {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    padding: 6px 0 2px;
    opacity: 0.7;
}

.task-delete-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.task-detail-item:hover .task-delete-btn {
    opacity: 1;
}
.task-delete-btn:hover {
    background: rgba(248,113,113,0.15);
    color: var(--hard);
}

[data-theme="light"] .task-stat-pill {
    background: var(--surface-2);
}
[data-theme="light"] .task-detail-item {
    background: var(--surface-2);
}

/* ─── Task Word Detail Modal ─────────────────────────── */
.task-word-detail-card {
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* ─── SPEAKING DETAIL MODAL ──────────────────────────────── */
.spk-detail-card {
    width: 100%;
    max-width: 520px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}
.spk-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.spk-loading {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 13px;
}
.spk-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 0 14px;
}
.spk-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.spk-chip-xp   { color: var(--easy);   background: rgba(52,211,153,0.08); border-color: rgba(52,211,153,0.2); }
.spk-chip-word { color: var(--accent);  background: var(--accent-glow);    border-color: rgba(94,234,212,0.2); }
.spk-word-highlight {
    background: rgba(94, 234, 212, 0.18);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}
.spk-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 8px;
}
.spk-bubble {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
}
.spk-ai {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
}
.spk-user {
    align-self: flex-end;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-bottom-right-radius: 4px;
    color: var(--accent);
}

/* ─── LISTENING DETAIL MODAL ─────────────────────────────── */
.lt-detail-card {
    width: 100%;
    max-width: 580px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    gap: 0;
}

/* Audio player row */
.lt-detail-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}
.lt-detail-play-btn,
.lt-detail-stop-btn {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.lt-detail-play-btn:hover { border-color: var(--accent); color: var(--accent); }
.lt-detail-stop-btn:hover { border-color: var(--hard); color: var(--hard); }
.lt-detail-seek-wrap { flex: 1; }
.lt-detail-seek {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(to right, var(--accent) 0%, var(--surface-2) 0%);
}
.lt-detail-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}
.lt-detail-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

/* Score row */
.lt-detail-score {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.lt-score-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}
.lt-score-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--border);
}
.lt-score-dot.ok    { background: var(--easy); }
.lt-score-dot.wrong { background: var(--hard); }
.lt-score-xp {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: var(--easy);
}

/* Scrollable body */
.lt-detail-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
}
.lt-detail-body .lt-detail-q,
.lt-detail-body .lt-detail-loading {
    margin-bottom: 12px;
}
.lt-detail-body .lt-detail-q:last-child,
.lt-detail-body .lt-detail-loading:last-child {
    margin-bottom: 0;
}
.lt-detail-loading {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Question block */
.lt-detail-q {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.lt-detail-q-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.lt-detail-q-num {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--surface);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.lt-detail-q-text {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
}
.lt-q-icon { font-size: 14px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.lt-q-icon.ok    { color: var(--easy); }
.lt-q-icon.wrong { color: var(--hard); }

.lt-detail-q-body {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* MCQ options */
.lt-detail-opt {
    font-size: 13px;
    color: var(--text-muted);
    padding: 5px 8px;
    border-radius: 6px;
    line-height: 1.4;
}
.lt-detail-opt.opt-correct       { color: var(--easy); background: rgba(52,211,153,0.08); font-weight: 600; }
.lt-detail-opt.opt-wrong         { color: var(--hard); background: rgba(244,67,54,0.08);  font-weight: 600; }
.lt-detail-opt.opt-correct-unsel { color: var(--easy); opacity: 0.65; }

/* Fill / matching shared value */
.lt-fill-label   { font-size: 12px; color: var(--text-muted); min-width: 36px; }
.lt-fill-val     { font-size: 13px; color: var(--text); font-weight: 500; }
.lt-fill-val.ok  { color: var(--easy); }
.lt-fill-val.wrong { color: var(--hard); }
.lt-detail-fill-row { display: flex; align-items: center; gap: 6px; }

/* Matching rows */
.lt-detail-match-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    flex-wrap: wrap;
}
.lt-match-item-label { color: var(--text-muted); min-width: 70px; }
.lt-match-arrow { color: var(--text-muted); font-size: 11px; }

.task-word-detail-legend {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 8px;
    padding: 6px 14px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.task-word-detail-body {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.twd-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.twd-row:last-child { border-bottom: none; }

.twd-word {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.twd-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.twd-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.twd-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}

.twd-stat {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    min-width: 28px;
}

.twd-quality {
    text-align: center;
    min-width: 20px;
}
.twd-dict-correct { color: #34d399; font-weight: 700; font-size: 15px; }
.twd-dict-wrong   { color: var(--hard); font-weight: 700; font-size: 15px; }
.twd-dict-none    { color: var(--text-muted); font-size: 13px; }

.task-detail-item.vocab-clickable:hover {
    border-color: var(--accent);
    background: rgba(94, 234, 212, 0.05);
}

/* ─── Vocab Assignment Items ─────────────────────────── */
.vocab-assign-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    position: relative;
}

.vocab-assign-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.vocab-assign-item-words {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    word-break: break-all;
}

.word-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    word-break: normal;
}

.word-progress-chip {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    user-select: none;
}

.word-progress-chip:hover {
    border-color: var(--hard);
    color: var(--hard);
    background: rgba(248, 113, 113, 0.08);
}

.vocab-assign-item .task-delete-btn {
    opacity: 0;
    margin-left: auto;
    flex-shrink: 0;
}

.vocab-assign-item:hover .task-delete-btn {
    opacity: 1;
}
.task-detail-item.task-viewed {
    opacity: 0.5;
}

[data-theme="light"] .twd-dot {
    background: var(--surface-2);
}
[data-theme="light"] .task-word-detail-card {
    background: var(--surface);
}

/* ─── READING DETAIL MODAL ─────────────────────────────── */
.rd-detail-card {
    width: 100%;
    max-width: 640px;
    height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    gap: 0;
}

/* Collapsible article */
.rd-article-wrap {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.rd-article-summary {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    background: var(--surface-2);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.rd-article-summary::-webkit-details-marker { display: none; }
.rd-article-summary::before {
    content: '▶';
    font-size: 9px;
    transition: transform 0.15s;
    display: inline-block;
}
details[open] .rd-article-summary::before { transform: rotate(90deg); }
.rd-article-body {
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    max-height: 260px;
    overflow-y: auto;
    background: var(--surface);
}

/* ─── GRAMMAR DETAIL MODAL ──────────────────────────────── */
.gr-detail-md-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    margin-left: auto;
    margin-right: 8px;
    white-space: nowrap;
}
.gr-detail-md-link:hover { text-decoration: underline; }

.gr-detail-type-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    flex-shrink: 0;
}
.gr-detail-type-tag.fill      { border-color: rgba(139,233,253,0.35); color: var(--blue-accent, #8be9fd); }
.gr-detail-type-tag.mcq       { border-color: rgba(94,234,212,0.35);  color: var(--accent); }
.gr-detail-type-tag.truefalse { border-color: rgba(189,147,249,0.35); color: #bd93f9; }

.gr-detail-gp {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    flex-shrink: 0;
}

.gr-detail-explanation {
    margin-top: 8px;
    padding: 7px 11px;
    border-radius: 7px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
    background: var(--surface-2);
    border-left: 3px solid var(--border);
}

/* ─── VOCAB MANAGER (系统工具 > 词汇管理) ────────────────────────────────── */

.vocab-mgr-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.vocab-mgr-tier-select {
    flex-shrink: 0;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    appearance: auto;
}

.vocab-mgr-tier-select:focus {
    outline: none;
    border-color: var(--accent);
}

.vocab-mgr-input {
    flex: 1 1 200px;
    min-width: 0;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 14px;
}

.vocab-mgr-search-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.vocab-mgr-nav-group {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.vocab-mgr-nav-btn {
    padding: 8px 14px;
    font-size: 13px;
}

.vocab-mgr-delete-confirm {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(244, 67, 54, 0.06);
    border: 1px solid rgba(244, 67, 54, 0.25);
    border-radius: 8px;
}

.vocab-mgr-delete-msg {
    flex: 1;
    font-size: 13px;
    color: var(--hard);
}

.vocab-mgr-confirm-btn {
    padding: 7px 14px;
    font-size: 13px;
    flex-shrink: 0;
}

.vocab-mgr-current-word {
    margin-top: 14px;
    font-size: 22px;
    font-weight: 700;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    color: var(--accent);
    letter-spacing: 0.04em;
}

/* Three-column layout: editor / image / summary */
.vocab-mgr-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.82fr) minmax(0, 1.08fr);
    gap: 20px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.vocab-mgr-editor-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Editor card fills the column height */
.vocab-mgr-editor-col > .admin-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}

.vocab-mgr-preview-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.vocab-mgr-image-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.vocab-image-card {
    margin-bottom: 0;
}

.vocab-image-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.vocab-image-card-hint {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
}

.vocab-image-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        radial-gradient(circle at 20% 20%, rgba(94, 234, 212, 0.12), transparent 38%),
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015)),
        var(--surface-2);
}

.vocab-image-empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vocab-image-empty-text {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.vocab-image-el {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: rgba(10, 14, 23, 0.72);
}

.vocab-policy-card {
    margin-bottom: 0;
}

.vocab-policy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.vocab-policy-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.vocab-policy-hint {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
}

.vocab-policy-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vocab-policy-empty {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
    background: var(--surface-2);
}

.vocab-policy-summary-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vocab-policy-summary-word {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
}

.vocab-policy-summary-chips,
.vocab-policy-summary-pos-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vocab-policy-chip,
.vocab-policy-pos-pill,
.vocab-policy-pos-badge,
.vocab-policy-role-badge,
.vocab-policy-source-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.vocab-policy-chip,
.vocab-policy-pos-pill {
    padding: 5px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.vocab-policy-pos-pill.primary {
    color: var(--accent);
    border-color: rgba(94, 234, 212, 0.28);
    background: rgba(94, 234, 212, 0.1);
}

.vocab-policy-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.vocab-policy-summary-label {
    font-size: 12px;
    color: var(--text-muted);
}

.vocab-policy-summary-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.vocab-policy-summary-flow {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.vocab-policy-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vocab-policy-row {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.vocab-policy-row.primary {
    background: linear-gradient(180deg, rgba(94, 234, 212, 0.08) 0%, var(--surface-2) 100%);
}

.vocab-policy-row-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.vocab-policy-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.vocab-policy-pos-badge {
    padding: 4px 10px;
    background: var(--accent-glow);
    color: var(--accent);
}

.vocab-policy-role-badge,
.vocab-policy-source-badge {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.vocab-policy-role-badge.primary {
    color: var(--accent);
    border-color: rgba(94, 234, 212, 0.2);
}

.vocab-policy-source-badge.changed {
    color: #f6c453;
    border-color: rgba(246, 196, 83, 0.24);
    background: rgba(246, 196, 83, 0.1);
}

.vocab-policy-stage-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.vocab-policy-stage-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.vocab-policy-stage-chip.emphasis {
    color: var(--accent);
    background: rgba(94, 234, 212, 0.1);
    border-color: rgba(94, 234, 212, 0.22);
}

.vocab-policy-flow-arrow {
    font-size: 12px;
    color: var(--text-muted);
}

.vocab-policy-form-grid,
.vocab-policy-static-grid,
.vocab-policy-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.vocab-policy-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vocab-policy-field span,
.vocab-policy-static-item span,
.vocab-policy-meta-item span {
    font-size: 11px;
    color: var(--text-muted);
}

.vocab-policy-field-help {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-muted);
}

.vocab-policy-field-full {
    margin-top: 12px;
}

.vocab-policy-static-item,
.vocab-policy-meta-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
}

.vocab-policy-static-item strong,
.vocab-policy-meta-item strong {
    font-size: 13px;
    color: var(--text);
}

.vocab-policy-number:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.vocab-policy-row-note {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
}

.vocab-policy-row-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

/* Tab bar */
.vocab-mgr-tab-bar {
    display: flex;
    gap: 0;
    padding: 10px 12px 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    background: var(--surface-2);
}

.vocab-mgr-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    border: none;
    border-radius: 7px 7px 0 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;
    white-space: nowrap;
}

.vocab-mgr-tab:hover {
    color: var(--text);
    background: var(--accent-glow);
}

.vocab-mgr-tab.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-bottom: 2px solid var(--accent);
}

/* JSON editor body */
.vocab-mgr-editor-body {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.vocab-mgr-json-textarea {
    width: 100%;
    flex: 1;
    height: 0;           /* flex determines height; min-height sets the floor */
    min-height: 200px;
    padding: 16px;
    background: var(--surface-2);
    border: none;
    border-radius: 0;
    color: var(--text);
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.65;
    resize: none;
    outline: none;
    display: block;
    box-sizing: border-box;
}

.vocab-mgr-json-error {
    margin: 0 14px 10px;
    padding: 8px 12px;
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.3);
    border-radius: 8px;
    color: #ff5555;
    font-size: 12px;
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

/* Footer */
.vocab-mgr-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.vocab-mgr-editor-status {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 1360px) {
    .vocab-mgr-editor-layout {
        grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
    }

    .vocab-mgr-editor-col {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .vocab-mgr-image-col {
        grid-column: 2;
        grid-row: 1;
    }

    .vocab-mgr-preview-col {
        grid-column: 2;
        grid-row: 2;
    }
}

@media (max-width: 980px) {
    .vocab-mgr-editor-layout {
        grid-template-columns: 1fr;
    }

    .vocab-mgr-editor-col,
    .vocab-mgr-image-col,
    .vocab-mgr-preview-col {
        grid-column: auto;
        grid-row: auto;
    }

    .vocab-policy-card-header,
    .vocab-policy-row-head {
        flex-direction: column;
        align-items: stretch;
    }

    .vocab-policy-card-actions {
        justify-content: flex-start;
    }

    .vocab-policy-form-grid,
    .vocab-policy-static-grid,
    .vocab-policy-meta-grid {
        grid-template-columns: 1fr;
    }
}
