/* ============================================================
   StudyHelper — Design System & Global Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ---------- Theme Tokens ---------- */
:root {
    --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
    --font-heading: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --bg: #f9fafb;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-hover: #f3f4f6;
    --border: #e5e7eb;
    --border-light: #f1f5f9;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

    /* Legacy aliases for inline styles in templates */
    --sh-danger: var(--danger);
    --sh-primary: var(--accent);
    --sh-primary-light: var(--accent-light);
    --sh-text-muted: var(--text-muted);
    --sh-text-secondary: var(--text-secondary);
    --sh-border-light: var(--border-light);
    --sh-surface-hover: var(--surface-hover);
}

[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-raised: #232734;
    --surface-hover: #2a2d3a;
    --border: #2d3140;
    --border-light: #252836;
    --text: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-light: rgba(99, 102, 241, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   LAYOUT — Top Nav + Main
   ============================================================ */

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Top Navigation ---------- */
.app-topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav-inner {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 1.5rem;
    gap: 0.25rem;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    margin-right: 1.25rem;
    flex-shrink: 0;
}

.topnav-brand-icon {
    width: 26px;
    height: 26px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.topnav-brand-icon svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

.topnav-brand-name {
    font-weight: 800;
    font-size: 0.9375rem;
    letter-spacing: -0.02em;
}

.topnav-links {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex: 1;
}

.topnav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.topnav-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.topnav-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

.topnav-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.topnav-user {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 0.375rem;
    white-space: nowrap;
}

.topnav-user svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.topnav-theme-btn svg {
    width: 15px;
    height: 15px;
}

/* Show/hide theme icons based on current theme */
:root .theme-icon-dark,
[data-theme="light"] .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: inline;
}

.topnav-mobile-toggle {
    display: none;
}

/* Mobile dropdown menu */
.topnav-mobile-menu {
    display: none;
    flex-direction: column;
    padding: 0.5rem;
    border-top: 1px solid var(--border-light);
}

.topnav-mobile-menu.open {
    display: flex;
}

.topnav-mobile-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.topnav-mobile-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.topnav-mobile-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.topnav-mobile-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.topnav-mobile-user svg {
    width: 14px;
    height: 14px;
}

.topnav-mobile-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.25rem 0;
}

/* ---------- Main Content ---------- */
.app-main-content {
    flex: 1;
    padding: 0;
    background: var(--bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.app-main-content:has(.sh-dashboard-shell) {
    padding-bottom: 0;
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */

.sh-dashboard-shell {
    position: relative;
    padding: 1.5rem;
    border-radius: 0;
    background:
        radial-gradient(1200px circle at 15% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
        radial-gradient(900px circle at 90% 0%, rgba(59, 130, 246, 0.08), transparent 55%);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.sh-dashboard-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(135deg, rgba(15, 23, 42, 0.06) 0 1px, transparent 1px 24px);
    opacity: 0.35;
    pointer-events: none;
}

[data-theme="dark"] .sh-dashboard-shell {
    background:
        radial-gradient(1200px circle at 10% -20%, rgba(99, 102, 241, 0.22), transparent 60%),
        radial-gradient(900px circle at 90% 0%, rgba(14, 165, 233, 0.12), transparent 55%);
}

[data-theme="dark"] .sh-dashboard-shell::before {
    background-image:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 28px);
    opacity: 0.25;
}

.sh-explorer-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: stretch;
    flex: 1;
}

/* Hide sidebar and center cards during active study sessions */
.sh-explorer-shell:has(.sh-study-session-active) {
    grid-template-columns: 1fr;
    gap: 0;
}

.sh-explorer-shell:has(.sh-study-session-active) .sh-dashboard-sidebar {
    display: none;
}

.sh-explorer-detail {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sh-dashboard-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1.5rem;
    align-items: stretch;
    flex: 1;
}

.sh-dashboard-sidebar,
.sh-dashboard-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.sh-dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sh-sidebar-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.sh-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.sh-sidebar-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.sh-sidebar-empty {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.5rem 0.25rem;
}

.sh-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.sh-sidebar-item {
    border-radius: 12px;
}

.sh-sidebar-link {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sh-sidebar-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sh-sidebar-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--folder-color, var(--accent));
}

.sh-sidebar-icon svg {
    width: 16px;
    height: 16px;
}

.sh-sidebar-name {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sh-sidebar-badge {
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.sh-sidebar-cta {
    width: 100%;
    justify-content: center;
}

.sh-dashboard-search {
    margin-top: -0.25rem;
}

.sh-search-bar-lg .sh-input {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    border-radius: 14px;
    font-size: 0.9rem;
}

.sh-search-bar-lg .sh-search-icon {
    left: 0.9rem;
}

.sh-deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.sh-deck-tile {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.sh-deck-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--folder-color, var(--accent)) 35%, var(--border));
}

.sh-deck-cover {
    height: 120px;
    border-radius: 16px;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--folder-color, var(--accent)) 28%, #ffffff) 0%,
            color-mix(in srgb, var(--folder-color, var(--accent)) 8%, #ffffff) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .sh-deck-cover {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--folder-color, var(--accent)) 35%, #141826) 0%,
            color-mix(in srgb, var(--folder-color, var(--accent)) 10%, #141826) 100%);
}

.sh-deck-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(120px circle at 20% 20%, rgba(255, 255, 255, 0.3), transparent 65%);
    opacity: 0.7;
}

.sh-deck-cover-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--folder-color, var(--accent));
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .sh-deck-cover-icon {
    background: rgba(15, 17, 23, 0.75);
}

.sh-deck-cover-icon svg {
    width: 24px;
    height: 24px;
}

.sh-deck-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.sh-deck-edit-btn {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    z-index: 5;
    cursor: pointer;
    padding: 0;
}

.sh-deck-edit-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.1);
}

.sh-deck-edit-btn svg {
    width: 14px;
    height: 14px;
}

.sh-deck-test-btn {
    position: absolute;
    bottom: 0.75rem;
    right: 2.75rem;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    transition: all var(--transition-fast);
    z-index: 5;
    cursor: pointer;
    padding: 0;
}

.sh-deck-test-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.1);
}

.sh-deck-test-btn svg {
    width: 14px;
    height: 14px;
}

.sh-deck-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sh-deck-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.sh-deck-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sh-side-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.sh-side-card-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.sh-activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sh-activity-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.sh-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    margin-top: 0.35rem;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
    flex-shrink: 0;
}

.sh-activity-title {
    font-weight: 600;
    font-size: 0.8125rem;
}

.sh-activity-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sh-goal-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.sh-goal-value {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text);
}

.sh-goal-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================
   CARDS
   ============================================================ */

.sh-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}

.sh-card:hover {
    box-shadow: var(--shadow-md);
}

.sh-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sh-card-header-title {
    font-weight: 700;
    font-size: 0.875rem;
    margin: 0;
}

.sh-card-body {
    padding: 1.25rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.sh-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
}

.sh-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.sh-btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.sh-btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.sh-btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.sh-btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

.sh-btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.sh-btn-danger:hover {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.sh-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.375rem 0.5rem;
}

.sh-btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sh-btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
}

.sh-btn-icon {
    padding: 0.375rem;
    width: 32px;
    height: 32px;
    justify-content: center;
}

.sh-btn:disabled,
.sh-btn.is-disabled,
.sh-btn.htmx-request {
    opacity: 0.6;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* ============================================================
   BADGES
   ============================================================ */

.sh-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.sh-badge-muted {
    background: var(--border-light);
    color: var(--text-muted);
}

.sh-badge-primary {
    background: var(--accent-light);
    color: var(--accent);
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */

.sh-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

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

.sh-input::placeholder {
    color: var(--text-muted);
}

textarea.sh-input {
    resize: vertical;
    min-height: 80px;
}

.sh-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.375rem;
}

/* Checkbox */
.sh-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
    flex-shrink: 0;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */

.sh-search-bar {
    position: relative;
}

.sh-search-bar .sh-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.sh-search-bar .sh-search-icon svg {
    width: 14px;
    height: 14px;
}

.sh-search-bar .sh-input {
    padding-left: 2.25rem;
}

.sh-search-bar-sm .sh-input {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.sh-search-bar-sm .sh-search-icon {
    left: 0.625rem;
}

.sh-search-bar-sm .sh-search-icon svg {
    width: 12px;
    height: 12px;
}

.sh-form-group-stack {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */

.sh-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.sh-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.sh-breadcrumb a:hover {
    color: var(--text);
}

.sh-breadcrumb-sep {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    opacity: 0.6;
    font-weight: 400;
}



.sh-breadcrumb-current {
    color: var(--text);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
    text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.sh-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}

.sh-page-header:hover {
    box-shadow: var(--shadow-md);
}


.sh-page-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.sh-page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.sh-page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.sh-section-title {
    font-family: var(--font-heading);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}

/* ============================================================
   EXPLORER TREE
   ============================================================ */

.sh-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.sh-tree {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sh-tree-item {
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--folder-color, var(--accent));
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--folder-color, var(--accent)) 10%, var(--surface)) 0%,
            var(--surface) 45%,
            var(--surface) 100%);
}

.sh-tree-item:hover {
    box-shadow: var(--shadow-sm);
}

.sh-tree-header {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    gap: 0.5rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.sh-tree-header:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .sh-tree-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.sh-tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.sh-tree-toggle svg {
    width: 14px;
    height: 14px;
}

.sh-tree-toggle.expanded {
    transform: rotate(90deg);
}

.sh-tree-folder-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--folder-color, var(--accent));
}

.sh-tree-folder-icon svg {
    width: 16px;
    height: 16px;
}

.sh-tree-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 1.25rem;
    will-change: max-height;
}

.sh-tree-item.expanded .sh-tree-children {
    max-height: 2000px;
    /* Large enough for tree content */
    padding-bottom: 0.375rem;
}

.sh-tree-item.expanded .sh-tree-toggle {
    transform: rotate(90deg);
}


.sh-tree-deck {
    display: flex;
    align-items: center;
    padding: 0.4375rem 0.75rem;
    gap: 0.5rem;
    border-radius: var(--radius-sm);
    margin: 0.125rem 0.5rem;
    transition: background var(--transition-fast);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.8375rem;
}

.sh-tree-deck:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sh-tree-deck-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.sh-tree-deck-icon svg {
    width: 14px;
    height: 14px;
}

/* ============================================================
   SIDEBAR — Variant D (Pill with Colored Cap)
   ============================================================ */

.sh-d-folders {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.sh-d-folder,
.sh-d-pill,
.sh-d-row {
    --folder-tint: color-mix(in srgb, var(--folder-color, var(--accent)) 12%, var(--surface));
    --folder-tint-strong: color-mix(in srgb, var(--folder-color, var(--accent)) 28%, var(--surface));
    --folder-ink: color-mix(in srgb, var(--folder-color, var(--accent)) 70%, var(--text));
}

.sh-d-folder {
    margin-bottom: 0;
}

/* ---- Pill ---- */
.sh-d-pill {
    position: relative;
    display: flex;
    height: 48px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.sh-d-folder.is-active .sh-d-pill {
    border-color: color-mix(in srgb, var(--folder-color, var(--accent)) 35%, transparent);
    box-shadow:
        0 1px 0 color-mix(in srgb, var(--folder-color, var(--accent)) 14%, transparent),
        0 4px 12px color-mix(in srgb, var(--folder-color, var(--accent)) 12%, transparent);
}

.sh-d-pill-cap {
    width: 48px;
    height: 100%;
    border: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    background: var(--folder-color, var(--accent));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter var(--transition-fast);
}

.sh-d-pill-cap:hover {
    filter: brightness(1.08);
}

.sh-d-pill-cap-static {
    cursor: default;
}

.sh-d-pill-cap svg {
    width: 18px;
    height: 18px;
}

/* Toggle which cap icon shows based on open state */
.sh-d-cap-icon-open {
    display: none;
}

.sh-d-folder.is-open .sh-d-cap-icon-open {
    display: block;
}

.sh-d-folder.is-open .sh-d-cap-icon-closed {
    display: none;
}

.sh-d-pill-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 0.875rem;
    cursor: pointer;
    background: var(--surface);
    transition: background var(--transition-fast);
    text-decoration: none;
    color: var(--text);
}

.sh-d-pill-name:hover {
    background: var(--folder-tint);
    color: var(--folder-ink);
}

.sh-d-folder.is-active .sh-d-pill-name {
    background: var(--folder-tint);
    color: var(--folder-ink);
}

.sh-d-pill-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.875rem;
}

.sh-d-folder.is-active .sh-d-pill-text {
    font-weight: 600;
}

.sh-d-pill-count {
    font-size: 0.6875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: var(--surface-hover);
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.sh-d-folder.is-active .sh-d-pill-count {
    background: rgba(255, 255, 255, 0.6);
    color: var(--folder-ink);
}

[data-theme="dark"] .sh-d-folder.is-active .sh-d-pill-count {
    background: rgba(255, 255, 255, 0.08);
}

/* ---- Children (rail + rows) ---- */
.sh-d-children {
    position: relative;
    margin-top: 4px;
    padding-bottom: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sh-d-folder.is-open .sh-d-children {
    max-height: 1500px;
}

.sh-d-rail {
    position: absolute;
    left: 24px;
    top: 0;
    bottom: 4px;
    width: 2px;
    border-radius: 2px;
    background: var(--folder-tint-strong);
}

.sh-d-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    margin-left: 30px;
    padding: 0 0.625rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.8125rem;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sh-d-row:hover {
    background: var(--folder-tint);
    color: var(--folder-ink);
}

.sh-d-row.is-active {
    background: var(--folder-tint);
    color: var(--folder-ink);
    font-weight: 600;
}

.sh-d-row.is-active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    width: 6px;
    height: 2px;
    transform: translateY(-50%);
    border-radius: 2px;
    background: var(--folder-color, var(--accent));
}

.sh-d-row-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--folder-color, var(--accent));
    flex-shrink: 0;
}

.sh-d-row-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sh-d-row-count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.sh-d-row.is-active .sh-d-row-count {
    color: var(--folder-ink);
    opacity: 0.8;
}

/* ============================================================
   FOLDER CARDS (in folder detail page)
   ============================================================ */

.sh-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

/* (sh-folder-card and sh-folder-card-inner removed, replaced by sh-d-pill) */

.sh-folder-card-icon {
    width: 48px;
    height: 48px;
    background: var(--folder-color, var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.sh-folder-card-icon svg {
    width: 24px;
    height: 24px;
}

.sh-folder-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   DECK CARDS
   ============================================================ */

.sh-deck-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.sh-deck-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    transform: translateY(-2px);
    color: inherit;
}

.sh-deck-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sh-deck-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent);
    flex-shrink: 0;
}

.sh-deck-icon svg {
    width: 18px;
    height: 18px;
}

.sh-deck-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.sh-folder-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================================
   FILE TABLE
   ============================================================ */

.sh-file-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.sh-file-table thead th {
    padding: 0.625rem 1rem;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
    white-space: nowrap;
    background: var(--surface);
}

.sh-file-table thead th:hover {
    color: var(--text);
}

.sh-file-table thead th .sort-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    opacity: 0.4;
    font-size: 0.625rem;
}

.sh-file-table thead th.sorted .sort-indicator {
    opacity: 1;
    color: var(--accent);
}

.sh-file-table tbody tr {
    transition: background var(--transition-fast);
}

.sh-file-table tbody tr:hover {
    background: var(--surface-hover);
}

.sh-file-table tbody td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.sh-file-name {
    font-weight: 500;
    color: var(--text);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sh-file-meta {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ============================================================
   FLASHCARD GRID
   ============================================================ */

.sh-flashcard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.sh-flashcard {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all var(--transition);
    position: relative;
}
.sh-flashcard:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
    transform: translateY(-1px);
}

.sh-flashcard-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    cursor: pointer;
    color: color-mix(in srgb, var(--accent) 65%, var(--text-secondary));
    min-height: 160px;
    gap: 0.5rem;
    padding: 1.5rem;
    transition: all var(--transition);
    border-radius: var(--radius);
}

.sh-flashcard-add:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.sh-flashcard-add i {
    width: 40px;
    height: 40px;
    stroke-width: 2.2;
}

.sh-flashcard-add .sh-flashcard-label {
    margin-bottom: 0;
    color: inherit;
    font-size: 0.75rem;
    font-weight: 800;
}

.sh-flashcard-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.sh-flashcard-img-badge {
    width: 11px;
    height: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sh-flashcard-text {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    word-break: break-word;
    white-space: pre-wrap;
}

.sh-flashcard-front {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
}

.sh-flashcard-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sh-flashcard:hover .sh-flashcard-actions {
    opacity: 1;
}

/* ============================================================
   FLIP CARD — Study Session
   ============================================================ */

.sh-flip-container {
    perspective: 1200px;
}

.sh-flip-card {
    width: 100%;
    min-height: 360px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sh-flip-card.flipped {
    transform: rotateY(180deg);
}

.sh-flip-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.sh-flip-front {
    justify-content: space-between;
}

.sh-flip-back {
    transform: rotateY(180deg);
    justify-content: space-between;
}

.sh-study-face-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.sh-study-face-text {
    font-size: 1.2rem;
    line-height: 1.5;
    font-weight: 600;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}


/* ============================================================
   STUDY SESSION
   ============================================================ */

.sh-study-card-shell {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sh-study-card-root {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.sh-study-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sh-study-progress-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.sh-study-progress-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.sh-study-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sh-study-flip-container {
    min-height: 360px;
}

.sh-study-flip-card {
    min-height: 360px;
}

/* Round correct/incorrect buttons inside card back */
.sh-study-answer-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    padding-top: 0.5rem;
}

.sh-study-btn-answer {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sh-study-btn-answer svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.5;
}

.sh-study-btn-correct {
    background: var(--success);
    color: #fff;
}

.sh-study-btn-correct:hover {
    background: #059669;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
    transform: scale(1.08);
}

.sh-study-btn-incorrect {
    background: var(--danger);
    color: #fff;
}

.sh-study-btn-incorrect:hover {
    background: #dc2626;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25);
    transform: scale(1.08);
}

/* Setup page */
.sh-study-setup-card {
    border-radius: var(--radius-lg);
}

.sh-study-mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 420px));
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
    padding-bottom: 4rem;
    position: relative;
    perspective: 1000px;
}

.sh-study-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    cursor: pointer;
    transition: 
        transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.7s ease,
        border-color 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.6s ease,
        filter 0.7s ease;
    min-height: 400px;
    aspect-ratio: 1 / 1;
}

.sh-study-choice:hover .sh-study-choice-icon {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.sh-study-choice:hover {
    border-color: var(--accent);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
}

.sh-study-choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Animation States */
.sh-study-choice.is-unselected {
    opacity: 0 !important;
    transform: scale(0.9) translateY(10px) !important;
    filter: blur(10px);
    pointer-events: none;
}

.sh-study-choice.is-selected-animating {
    transform: translateX(var(--slide-x, 0)) scale(1.05) !important;
    z-index: 50;
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-xl), 0 0 40px var(--accent-glow) !important;
}



.sh-study-choice input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sh-study-choice-icon {
    width: 80px;
    height: 80px;
    background: var(--bg);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sh-study-choice:has(input:checked) .sh-study-choice-icon {
    background: var(--accent);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.sh-study-choice-icon svg {
    width: 38px;
    height: 38px;
}

.sh-study-choice-title {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    margin-bottom: 0.75rem;
    font-family: var(--font-heading);
}

.sh-study-choice-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 260px;
}

.sh-study-inline-choice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.sh-study-inline-choice input {
    accent-color: var(--accent);
}

.sh-study-deck-picker {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.75rem;
    max-height: 360px;
    overflow: auto;
    background: var(--surface);
}

.sh-study-deck-group+.sh-study-deck-group {
    margin-top: 0.875rem;
    padding-top: 0.875rem;
    border-top: 1px dashed var(--border);
}

.sh-study-deck-group.is-nested {
    margin-top: 0.5rem !important;
    padding-top: 0 !important;
    border-top: none !important;
}

.sh-study-deck-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.sh-study-deck-group-title:hover {
    color: var(--text-secondary);
}

.sh-study-deck-group-title .sh-checkbox {
    margin: 0;
}

.sh-study-deck-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sh-study-deck-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.625rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sh-study-deck-option:hover {
    background: var(--surface-hover);
}

.sh-study-deck-option-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sh-study-order-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sh-study-drag-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: grab;
    transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
    user-select: none;
}

.sh-study-drag-item:hover {
    background: var(--surface-hover, var(--bg));
    border-color: var(--accent);
}

.sh-study-drag-item.is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.sh-study-drag-item.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

.sh-study-drag-handle {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    cursor: grab;
}

.sh-study-order-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.sh-study-order-empty {
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.75rem;
    font-style: italic;
}

/* ============================================================
   Option B — Color-coded inline deck tree (Step 2 redesign)
   ============================================================ */

.vb-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.vb-select-all {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}
.vb-select-all svg { width: 13px; height: 13px; }
.vb-select-all:hover { background: var(--accent-light); }
.vb-select-all.is-on {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 14px var(--accent-glow);
}
.vb-select-all:disabled { opacity: 0.4; cursor: not-allowed; }

.vb-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* ---- Folder group ---- */
.vb-group {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    position: relative;
}
.vb-group::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--folder-color, var(--accent));
    z-index: 1;
}

.vb-group-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.7rem 1rem 0.7rem 1.1rem;
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 6%, var(--surface));
    border-bottom: 1px solid color-mix(in srgb, var(--folder-color, var(--accent)) 14%, var(--border-light));
    cursor: pointer;
    transition: background var(--transition-fast);
}
.vb-group-head:hover {
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 10%, var(--surface));
}

.vb-group-cap {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--folder-color, var(--accent));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vb-group-cap svg { width: 14px; height: 14px; }

.vb-group-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}
.vb-group-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.vb-group-body {
    padding: 0.5rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* ---- Subfolder ---- */
.vb-subgroup {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
}

.vb-subgroup-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    margin-left: 18px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 4%, transparent);
    border: 1px dashed color-mix(in srgb, var(--folder-color, var(--accent)) 28%, transparent);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.vb-subgroup-head:hover {
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 8%, transparent);
}

.vb-subgroup-cap {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 18%, transparent);
    color: var(--folder-color, var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vb-subgroup-cap svg { width: 12px; height: 12px; }

.vb-subgroup-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.vb-subgroup-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}
.vb-subgroup-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.35rem;
    margin-left: 18px;
}

/* ---- Deck row ---- */
.vb-deck {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.vb-deck:hover { border-color: var(--border); }
.vb-deck.is-selected {
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 7%, var(--surface));
    border-color: color-mix(in srgb, var(--folder-color, var(--accent)) 40%, transparent);
}
.vb-deck.is-empty { opacity: 0.55; cursor: not-allowed; }

.vb-deck-icon {
    width: 24px; height: 24px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 14%, transparent);
    color: var(--folder-color, var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vb-deck-icon svg { width: 12px; height: 12px; }

.vb-deck-name {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- File row ---- */
.vb-file {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.vb-file:hover { border-color: var(--border); }
.vb-file.is-selected {
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 7%, var(--surface));
    border-color: color-mix(in srgb, var(--folder-color, var(--accent)) 40%, transparent);
}
.vb-file.is-disabled { opacity: 0.55; cursor: not-allowed; }

.vb-file-icon {
    width: 24px; height: 24px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--folder-color, var(--accent)) 14%, transparent);
    color: var(--folder-color, var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.vb-file-icon svg { width: 12px; height: 12px; }

.vb-file-name {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}



/* ---- Empty deck label ---- */
.sh-mini-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--border-light);
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sh-mini-tag-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

/* Complete page */
.sh-study-complete-card {
    max-width: 640px;
    margin: 0 auto;
}

.sh-study-score-hero {
    text-align: center;
    padding: 2.5rem 0;
    margin-bottom: 2rem;
}

.sh-study-score-hero .sh-study-stat-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.sh-study-score-hero .sh-study-stat-value {
    font-size: 5rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.sh-study-score-hero.sh-study-score--good .sh-study-stat-value { color: var(--success); }
.sh-study-score-hero.sh-study-score--warn .sh-study-stat-value { color: var(--warning, #f59e0b); }
.sh-study-score-hero.sh-study-score--bad .sh-study-stat-value { color: var(--danger); }

.sh-study-stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    margin-bottom: 1.5rem;
}

.sh-study-stat {
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sh-study-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.sh-study-stat-icon {
    display: flex;
}

.sh-study-stat-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

.sh-study-stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.sh-study-stat-value {
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sh-study-stat--correct {
    border-color: color-mix(in srgb, var(--success) 20%, var(--border-light));
    background: color-mix(in srgb, var(--success) 5%, var(--surface));
}

.sh-study-stat--correct .sh-study-stat-icon,
.sh-study-stat--correct .sh-study-stat-value {
    color: var(--success);
}

.sh-study-stat--incorrect {
    border-color: color-mix(in srgb, var(--danger) 20%, var(--border-light));
    background: color-mix(in srgb, var(--danger) 5%, var(--surface));
}

.sh-study-stat--incorrect .sh-study-stat-icon,
.sh-study-stat--incorrect .sh-study-stat-value {
    color: var(--danger);
}

.sh-study-complete-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 2rem;
}

.sh-study-complete-actions form,
.sh-study-complete-actions .sh-btn {
    width: 100%;
    margin: 0;
}

.sh-study-score--good .sh-study-stat-value,
.sh-study-score--good .sh-study-stat-icon { color: var(--success); }

.sh-study-score--warn .sh-study-stat-value,
.sh-study-score--warn .sh-study-stat-icon { color: var(--warning, #f59e0b); }

.sh-study-score--bad .sh-study-stat-value,
.sh-study-score--bad .sh-study-stat-icon { color: var(--danger); }

.sh-study-score-message {
    text-align: center;
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    margin-bottom: 0;
}

/* ============================================================
   STUDY WIZARD
   ============================================================ */

.sh-wizard-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 0.5rem;
}

.sh-wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.sh-wizard-step-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.sh-wizard-step.is-active .sh-wizard-step-dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.sh-wizard-step.is-done .sh-wizard-step-dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    opacity: 0.5;
}

.sh-wizard-step-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sh-wizard-step.is-active .sh-wizard-step-label {
    color: var(--accent);
    font-weight: 600;
}

.sh-wizard-step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.5rem;
    margin-bottom: 1.25rem;
}

.sh-wizard-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 0;
}

.sh-wizard-panel {
    display: none;
    padding: 1.5rem;
    flex-direction: column;
    gap: 1.25rem;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sh-wizard-panel.is-active {
    display: flex;
}

.sh-wizard-panel.is-active-fade {
    opacity: 1;
}

.sh-wizard-panel.is-fading-out {
    display: flex;
    opacity: 0;
    pointer-events: none;
}

.sh-wizard-footer {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    z-index: 10;
}

.sh-wizard-validation-msg {
    color: var(--danger);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

/* ---- Test wizard warning/error banners ---- */
.sh-test-warn-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    background: #fff3cd;
    color: #856404;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid #ffc107;
}
.sh-test-warn-banner i { width: 16px; height: 16px; flex-shrink: 0; }

.sh-test-error-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    background: #f8d7da;
    color: #721c24;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid #f5c6cb;
}
.sh-test-error-banner i { width: 16px; height: 16px; flex-shrink: 0; }

/* ---- Segmented control ---- */
.sh-segmented-control {
    display: inline-flex;
    background: var(--border-light);
    border-radius: var(--radius);
    padding: 3px;
    gap: 1px;
}
.sh-segmented-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.85rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.sh-segmented-option:hover { color: var(--text); }
.sh-segmented-option:has(input:checked) {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.sh-segmented-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sh-study-search-wrap {
    position: relative;
    margin-bottom: 0.75rem;
}

.sh-study-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.sh-study-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

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

.sh-wizard-card-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.5rem 0 0;
    font-weight: 500;
}

.sh-wizard-card-count #sh-card-count {
    color: var(--accent);
    font-weight: 700;
}

/* ============================================================
   CUSTOM MODAL
   ============================================================ */

.sh-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.sh-modal.is-open {
    display: flex;
}

.sh-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.sh-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    animation: modalIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.sh-modal-dialog-sm {
    max-width: 340px;
}

.sh-modal-dialog-lg {
    max-width: 560px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.sh-modal-content {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.sh-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.sh-modal-title {
    font-weight: 700;
    font-size: 0.9375rem;
    margin: 0;
    color: var(--text);
}

.sh-modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.sh-modal-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sh-modal-close svg {
    width: 16px;
    height: 16px;
}

.sh-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.sh-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-light);
}

/* ============================================================
   ICON PICKER
   ============================================================ */

/* ---------- Icon Picker Tabs ---------- */
.sh-icon-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.sh-icon-tabs {
    display: flex;
    background: var(--surface-hover);
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    gap: 0.1rem;
}

.sh-icon-tab {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.sh-icon-tab.is-active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.sh-icon-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-hover);
}

.sh-icon-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color 0.1s, color 0.1s, background 0.1s;
    padding: 0;
}

.sh-icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light, color-mix(in srgb, var(--accent) 12%, var(--surface)));
}

.sh-icon-btn.is-selected {
    border-color: var(--accent);
    background: var(--accent-light, color-mix(in srgb, var(--accent) 12%, var(--surface)));
    color: var(--accent);
}

.sh-icon-btn svg,
.sh-icon-btn iconify-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

iconify-icon {
    display: inline-flex;
    vertical-align: middle;
}

.sh-edit-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--preview-color, var(--accent));
    color: #fff;
    flex-shrink: 0;
    transition: all 0.15s;
}

.sh-edit-preview svg {
    width: 22px;
    height: 22px;
}

/* ============================================================
   ALERTS
   ============================================================ */

.sh-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.sh-alert-danger {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--danger);
}

.sh-alert-info {
    background: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent);
}

.sh-alert-body {
    flex: 1;
}

.sh-alert-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0;
    display: flex;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.sh-alert-close:hover {
    opacity: 1;
}

.sh-alert-close svg {
    width: 16px;
    height: 16px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.sh-empty {
    text-align: center;
    padding: 2.5rem 1rem;
}

.sh-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.sh-empty-icon svg {
    width: 40px;
    height: 40px;
}

.sh-empty-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.sh-empty-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
    opacity: 0.7;
}

/* ============================================================
   DELETE WARNING
   ============================================================ */

.sh-warning-dialog {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    padding: 1rem;
}

.sh-warning-dialog-title {
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.sh-warning-dialog-text {
    font-size: 0.8125rem;
    color: var(--danger);
    opacity: 0.85;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1 1 0;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-5 {
    gap: 1.25rem;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-5 {
    margin-bottom: 1.5rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.ml-auto {
    margin-left: auto;
}

.mr-auto {
    margin-right: auto;
}

.m-0 {
    margin: 0;
}

.p-0 {
    padding: 0;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none;
}

.inline {
    display: inline;
}

.inline-flex {
    display: inline-flex;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

.sh-fade-in {
    animation: shFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* HTMX Swap Animations (restricted to main container) */
#study-session-content.htmx-swapping {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

#study-session-content.htmx-added {
    opacity: 0;
}

#study-session-content.htmx-added.sh-fade-in,
#study-session-content.htmx-added {
    animation: shFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.app-main-content>.sh-fade-in {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@keyframes shFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================================
   HTMX INDICATORS
   ============================================================ */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.sh-login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg) 0%, color-mix(in srgb, var(--accent) 6%, var(--bg)) 100%);
    padding: 1rem;
}

.sh-login-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.sh-login-icon {
    width: 52px;
    height: 52px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin: 0 auto 1rem;
}

.sh-login-icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 2;
}

.sh-login-brand {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 0.25rem;
}

.sh-login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.75rem;
}

.sh-login-field {
    margin-bottom: 1rem;
}

.sh-login-submit {
    margin-top: 0.5rem;
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 768px)
   ============================================================ */

@media (max-width: 1100px) {
    .sh-explorer-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .sh-dashboard-content {
        grid-template-columns: minmax(0, 1fr);
    }

    .sh-dashboard-aside {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sh-side-card {
        flex: 1 1 260px;
    }
}

@media (max-width: 900px) {
    .sh-explorer-shell {
        grid-template-columns: 1fr;
    }

    .sh-dashboard-sidebar,
    .sh-dashboard-aside {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .topnav-links {
        display: none;
    }

    .topnav-right {
        display: none;
    }

    .topnav-mobile-toggle {
        display: flex;
    }

    .topnav-inner {
        padding: 0 1rem;
    }

    .app-main-content {
        padding: 1rem;
    }

    .sh-dashboard-shell {
        padding: 0.75rem;
    }

    .sh-dashboard-search {
        margin-top: 0;
    }

    .sh-deck-grid {
        grid-template-columns: 1fr;
    }

    .sh-study-flip-container {
        min-height: 300px;
    }

    .sh-study-flip-card,
    .sh-flip-card {
        min-height: 300px;
    }

    .sh-study-face-text {
        font-size: 1rem;
    }

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

    .sh-flashcard-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   FLASHCARD IMAGE UPLOAD ZONE
   ============================================================ */

.sh-img-zone {
    position: relative;
    margin-top: 0.5rem;
}

.sh-img-drop-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    user-select: none;
}

.sh-img-drop-label:hover,
.sh-img-zone.is-dragover .sh-img-drop-label {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.sh-img-drop-label i {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.sh-img-drop-label.is-hidden {
    display: none;
}

.sh-img-file-input {
    display: none;
}

.sh-img-preview-wrap {
    position: relative;
    display: inline-flex;
    margin-bottom: 0.4rem;
}

.sh-img-preview {
    max-height: 80px;
    max-width: 100%;
    border-radius: var(--radius-sm);
    object-fit: contain;
    border: 1px solid var(--border);
    display: block;
}

.sh-img-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger, #ef4444);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #fff;
    transition: opacity 0.15s;
}

.sh-img-remove-btn:hover {
    opacity: 0.85;
}

.sh-img-remove-btn i {
    width: 11px;
    height: 11px;
}

.sh-img-edit-btn {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent, #6366f1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #fff;
    transition: opacity 0.15s;
}

.sh-img-edit-btn:hover {
    opacity: 0.85;
}

.sh-img-edit-btn i {
    width: 11px;
    height: 11px;
}

/* ============================================================
   STUDY CARD IMAGE
   ============================================================ */

.sh-study-card-image {
    max-height: 180px;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.sh-lightbox-trigger {
    cursor: zoom-in;
}

@media (max-width: 600px) {
    .sh-study-card-image {
        max-height: 140px;
    }
}

/* ============================================================
   IMAGE LIGHTBOX
   ============================================================ */

.sh-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sh-fade-in-fast 0.2s ease;
}

.sh-lightbox-img {
    max-width: min(90vw, 900px);
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

.sh-lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.sh-lightbox-close:hover {
    background: rgba(255,255,255,0.22);
}

.sh-lightbox-close i {
    width: 16px;
    height: 16px;
}

@keyframes sh-fade-in-fast {
    from { opacity: 0; }
    to   { opacity: 1; }
}