/* StudioTools theme — aligned with Cartwall */

:root {
    --st-bg: #141618;
    --st-surface: #1c1f24;
    --st-surface-2: #262a31;
    --st-border: rgba(255, 255, 255, 0.1);
    --st-text: #e6eaf0;
    --st-text-dim: #9aa3b2;
    --st-text-muted: #6b7280;
    --st-accent: #c9a227;
    --st-accent-hover: #dbb42e;
    --st-accent-soft: rgba(201, 162, 39, 0.18);
    --st-danger: #c53030;
    --st-success: #3d8f5f;
    --st-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --st-mono: 'JetBrains Mono', ui-monospace, monospace;
    --st-radius: 10px;
    --st-inset-bg: rgba(0, 0, 0, 0.18);
    --st-hover: rgba(255, 255, 255, 0.05);
    --st-row-divider: rgba(255, 255, 255, 0.05);
    --st-row-hover: rgba(255, 255, 255, 0.035);
    --st-scroll-thumb: rgba(255, 255, 255, 0.14);
    --st-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
    --st-modal-shadow: 0 -8px 32px rgba(0, 0, 0, 0.42);
    --st-btn-hover-border: rgba(255, 255, 255, 0.18);
    --st-badge-on-accent: #141618;
    --st-flash-bg: rgba(197, 48, 48, 0.14);
    --st-urgent-bg: rgba(234, 179, 8, 0.1);
    --st-new-bg: rgba(201, 162, 39, 0.09);
    --st-selected-bg: rgba(201, 162, 39, 0.11);
    --st-input-bg: rgba(255, 255, 255, 0.04);
    --st-btn-bg: var(--st-surface-2);
    --st-btn-hover-bg: #323842;
    --st-subtle-bg: rgba(255, 255, 255, 0.04);
    --st-subtle-bg-2: rgba(255, 255, 255, 0.06);
    --st-subtle-border: rgba(255, 255, 255, 0.08);
    --st-strong-border: rgba(255, 255, 255, 0.12);
    --st-accent-border: rgba(201, 162, 39, 0.35);
    --st-accent-border-strong: rgba(201, 162, 39, 0.5);
    --st-accent-muted-bg: rgba(201, 162, 39, 0.12);
    --st-accent-pill-bg: rgba(201, 162, 39, 0.14);
    --st-card-bg: var(--st-surface-2);
    --st-quote-bg: rgba(255, 255, 255, 0.03);
    --st-quote-border: rgba(255, 255, 255, 0.12);
    --st-thumb-logo-bg: rgba(255, 255, 255, 0.04);
    --st-cat-bg: rgba(255, 255, 255, 0.02);
    --st-backdrop: rgba(0, 0, 0, 0.55);
    --st-on-accent: #141618;
    --st-warning: #eab308;
    --st-warning-bg: rgba(234, 179, 8, 0.2);
    --st-warning-border: rgba(234, 179, 8, 0.4);
    --st-danger-soft-bg: rgba(197, 48, 48, 0.1);
    --st-danger-soft-border: rgba(197, 48, 48, 0.5);
    --st-topline-bg: linear-gradient(90deg, rgba(197, 48, 48, 0.25), rgba(197, 48, 48, 0.08));
    --st-topline-border: rgba(197, 48, 48, 0.45);
    --st-topline-urgent-bg: linear-gradient(90deg, rgba(234, 88, 12, 0.2), rgba(234, 88, 12, 0.06));
    --st-topline-urgent-border: rgba(234, 88, 12, 0.4);
    --st-panel-shadow: none;
    --st-status-idle: #6b7280;

    /* Franceinfo tokens → StudioTools */
    --fi-yellow: #c9a227;
    --fi-yellow-alt: #dbb42e;
    --fi-black: #141618;
    --fi-white: #eceff4;
    --fi-gray-900: #eceff4;
    --fi-gray-800: #1c1f24;
    --fi-gray-700: #262a31;
    --fi-gray-600: #323842;
    --fi-gray-500: #6b7280;
    --fi-gray-400: #9aa3b2;
    --fi-gray-300: #b8c0cc;
    --fi-gray-200: rgba(255, 255, 255, 0.14);
    --fi-gray-100: rgba(255, 255, 255, 0.08);
    --fi-gray-050: #141618;
    --fi-info: #5b8fd4;
    --fi-success: var(--st-success);
    --fi-warning: #eab308;
    --fi-danger: var(--st-danger);
    --fi-focus: var(--st-accent);
    --fi-selection-bg: rgba(201, 162, 39, 0.28);
    --fi-font-sans: var(--st-font);
    --fi-font-mono: var(--st-mono);
}

html[data-theme="light"] {
    color-scheme: light;
    --st-bg: #edeae4;
    --st-surface: #ffffff;
    --st-surface-2: #f5f2ec;
    --st-border: #d9d3c8;
    --st-text: #1c1917;
    --st-text-dim: #44403c;
    --st-text-muted: #78716c;
    --st-accent: #8a5a08;
    --st-accent-hover: #a06a0a;
    --st-accent-soft: rgba(138, 90, 8, 0.11);
    --st-danger: #b91c1c;
    --st-success: #15803d;
    --st-inset-bg: #e8e4dc;
    --st-hover: rgba(28, 25, 23, 0.045);
    --st-row-divider: rgba(28, 25, 23, 0.06);
    --st-row-hover: rgba(28, 25, 23, 0.035);
    --st-scroll-thumb: rgba(28, 25, 23, 0.16);
    --st-shadow: 0 10px 32px rgba(28, 25, 23, 0.1);
    --st-modal-shadow: 0 20px 48px rgba(28, 25, 23, 0.14);
    --st-btn-hover-border: #c4b9a8;
    --st-badge-on-accent: #1c1917;
    --st-flash-bg: rgba(185, 28, 28, 0.08);
    --st-urgent-bg: rgba(202, 138, 4, 0.1);
    --st-new-bg: rgba(138, 90, 8, 0.08);
    --st-selected-bg: rgba(138, 90, 8, 0.1);
    --st-input-bg: #ffffff;
    --st-btn-bg: #ffffff;
    --st-btn-hover-bg: #ebe6dd;
    --st-subtle-bg: rgba(28, 25, 23, 0.04);
    --st-subtle-bg-2: rgba(28, 25, 23, 0.06);
    --st-subtle-border: rgba(28, 25, 23, 0.1);
    --st-strong-border: rgba(28, 25, 23, 0.14);
    --st-accent-border: rgba(138, 90, 8, 0.32);
    --st-accent-border-strong: rgba(138, 90, 8, 0.48);
    --st-accent-muted-bg: rgba(138, 90, 8, 0.1);
    --st-accent-pill-bg: rgba(138, 90, 8, 0.12);
    --st-card-bg: #ffffff;
    --st-quote-bg: #f5f2ec;
    --st-quote-border: #d9d3c8;
    --st-thumb-logo-bg: #f5f2ec;
    --st-cat-bg: rgba(28, 25, 23, 0.025);
    --st-backdrop: rgba(28, 25, 23, 0.38);
    --st-on-accent: #1c1917;
    --st-warning: #b45309;
    --st-warning-bg: rgba(202, 138, 4, 0.14);
    --st-warning-border: rgba(180, 83, 9, 0.35);
    --st-danger-soft-bg: rgba(185, 28, 28, 0.08);
    --st-danger-soft-border: rgba(185, 28, 28, 0.35);
    --st-topline-bg: linear-gradient(90deg, rgba(185, 28, 28, 0.12), rgba(185, 28, 28, 0.04));
    --st-topline-border: rgba(185, 28, 28, 0.28);
    --st-topline-urgent-bg: linear-gradient(90deg, rgba(180, 83, 9, 0.14), rgba(180, 83, 9, 0.04));
    --st-topline-urgent-border: rgba(180, 83, 9, 0.3);
    --st-panel-shadow: 0 1px 0 var(--st-border), 0 4px 14px rgba(28, 25, 23, 0.05);
    --st-status-idle: #a8a29e;
    --fi-yellow: #a06a0a;
    --fi-yellow-alt: #8a5a08;
    --fi-black: #1c1917;
    --fi-white: #ffffff;
    --fi-gray-900: #1c1917;
    --fi-gray-800: #ffffff;
    --fi-gray-700: #f5f2ec;
    --fi-gray-600: #ebe6dd;
    --fi-gray-500: #78716c;
    --fi-gray-400: #57534e;
    --fi-gray-300: #44403c;
    --fi-gray-200: rgba(28, 25, 23, 0.1);
    --fi-gray-100: rgba(28, 25, 23, 0.05);
    --fi-gray-050: #edeae4;
    --fi-selection-bg: rgba(138, 90, 8, 0.2);
}

html[data-theme="light"] body {
    background: var(--st-bg) !important;
    color: var(--st-text) !important;
}

html[data-theme="dark"] body,
body {
    font-family: var(--st-font) !important;
    background: var(--st-bg) !important;
    color: var(--st-text) !important;
}

/* ── Topbar (Cartwall-style header) ── */
.app-header.topbar {
    height: auto;
    min-height: var(--header-height);
    padding: clamp(0.45rem, 1.2vmin, 0.65rem) clamp(0.75rem, 2vw, 1.25rem);
    background: var(--st-surface);
    border-bottom: 1px solid var(--st-border);
    box-shadow: none;
    font-size: clamp(0.95rem, 1.8vw, 1.05rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.app-header.topbar::after {
    background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.08), transparent);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--st-text);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
    transition: color 0.12s;
}

.app-header .brand:hover {
    color: var(--st-accent);
    text-decoration: none;
}

.app-header .brand svg {
    flex-shrink: 0;
    color: var(--st-accent);
}

.badge-live {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.45rem;
    border-radius: 3px;
    background: var(--st-danger);
    color: #fff;
    flex-shrink: 0;
}

.app-header .menu-toggle {
    background: var(--st-surface-2);
    border: 1px solid var(--st-border);
    color: var(--st-text-dim);
    margin-right: 0;
    padding: 0.45rem 0.55rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    box-shadow: none;
}

.app-header .menu-toggle:hover {
    color: var(--st-text);
    border-color: rgba(255, 255, 255, 0.22);
    background: #323842;
    transform: none;
}

.app-header .menu-toggle .icon {
    filter: brightness(1.2);
}

/* ── Surfaces & panels ── */
.admin-modal,
.article-content,
.admin-panel,
.parser-dropdown,
.parser-dropdown option {
    background: var(--st-surface) !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}

.parser-dropdown option:hover {
    background: var(--st-surface-2) !important;
}

.stat-card,
.logs-section {
    background: var(--st-surface-2) !important;
}

.admin-btn,
.admin-btn.secondary {
    background: var(--st-surface-2) !important;
    color: var(--st-text) !important;
}

.admin-btn.primary,
.back-btn {
    background: var(--st-accent) !important;
    color: #1a1a1a !important;
}

.back-btn:hover,
.article-link:hover {
    background: var(--st-accent-hover) !important;
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.25) !important;
}

.form-group input,
.toolbar input[type="text"] {
    background: var(--st-surface-2) !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}

.toolbar input[type="text"]:focus {
    background: var(--st-surface) !important;
}

/* ── Toolbar ── */
.toolbar button {
    background: var(--st-surface-2) !important;
    border-color: var(--st-border) !important;
    color: var(--st-text-dim) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
}

.toolbar button:hover {
    background: #323842 !important;
    color: var(--st-text) !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
    transform: none !important;
}

.toolbar button[title="Administration"] {
    background: var(--st-accent) !important;
    color: #1a1a1a !important;
    border-color: var(--st-accent) !important;
}

.toolbar button[title="Administration"]:hover {
    background: var(--st-accent-hover) !important;
    border-color: var(--st-accent-hover) !important;
    color: #1a1a1a !important;
}

.toolbar select {
    background: var(--st-surface-2) !important;
    border-color: var(--st-border) !important;
    color: var(--st-text) !important;
    border-radius: 8px !important;
}

.toolbar select:hover,
.toolbar select:focus {
    border-color: var(--st-accent) !important;
}

/* ── Sidebar ── */
.sidebar {
    background: var(--st-surface) !important;
    border-right: 1px solid var(--st-border) !important;
    box-shadow: none !important;
}

.sidebar::after {
    display: none !important;
}

.sidebar .toolbar {
    padding: 0.5rem 0.65rem !important;
    gap: 0.4rem !important;
    border-bottom: 1px solid var(--st-border) !important;
    background: var(--st-surface) !important;
}

.sidebar .toolbar button {
    flex: 1;
    padding: 0.45rem 0.6rem !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    background: var(--st-surface-2) !important;
    border: 1px solid var(--st-border) !important;
    color: var(--st-text-dim) !important;
    box-shadow: none !important;
    transform: none !important;
}

.sidebar .toolbar button:hover {
    background: #323842 !important;
    color: var(--st-text) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
}

.sidebar .toolbar #collapseBtn {
    flex: 0 0 auto;
    min-width: 2.25rem;
    padding: 0.45rem !important;
}

.feed-list {
    padding: 0.35rem 0 0.75rem !important;
}

.feed-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12) !important;
}

.feed-list::-webkit-scrollbar-thumb:hover {
    background: var(--st-accent) !important;
}

/* En-têtes de section */
.category-header {
    padding: 0.85rem 0.85rem 0.35rem !important;
    margin: 0.5rem 0.65rem 0.15rem !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--st-border) !important;
    border-radius: 0 !important;
    font-family: var(--st-mono) !important;
    font-size: 0.62rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.12em !important;
    color: var(--st-text-muted) !important;
    text-transform: uppercase !important;
}

.category-header::after {
    display: none !important;
}

/* Items unifiés — catégories et flux */
.feed-item,
.category-item,
.feed-list > li {
    padding: 0.55rem 0.65rem !important;
    margin: 0.15rem 0.5rem !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--st-text-dim) !important;
    font-size: 0.84rem !important;
    font-weight: 500 !important;
    gap: 0.55rem !important;
    transform: none !important;
    box-shadow: none !important;
    transition: background 0.12s, border-color 0.12s, color 0.12s !important;
}

.feed-item:hover,
.category-item:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
    color: var(--st-text) !important;
    transform: none !important;
    box-shadow: none !important;
}

.feed-item.active,
.category-item.active,
.feed-list li.active {
    background: var(--st-accent-soft) !important;
    border-color: rgba(201, 162, 39, 0.35) !important;
    color: var(--st-text) !important;
    font-weight: 600 !important;
    transform: none !important;
    box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.12) !important;
}

.feed-item.active::before,
.category-item.active::before {
    width: 3px !important;
    background: var(--st-accent) !important;
    border-radius: 0 2px 2px 0 !important;
}

/* Icônes flux */
.feed-icon {
    width: 22px !important;
    height: 22px !important;
    border-radius: 5px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.feed-icon.default {
    width: 22px !important;
    height: 22px !important;
    background: var(--st-surface-2) !important;
    color: var(--st-accent) !important;
    border: 1px solid rgba(201, 162, 39, 0.25) !important;
    border-radius: 5px !important;
}

.feed-icon.default .icon {
    width: 13px !important;
    height: 13px !important;
    opacity: 0.9;
}

.feed-item:hover .feed-icon,
.category-item:hover .feed-icon {
    transform: none !important;
}

.feed-item.active .feed-icon.default {
    background: rgba(201, 162, 39, 0.22) !important;
    border-color: rgba(201, 162, 39, 0.45) !important;
}

/* Compteurs */
.unread-count.has-count::after {
    font-family: var(--st-mono) !important;
    font-size: 0.62rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    padding: 0.2rem 0.45rem !important;
    min-width: 1.4rem !important;
    border-radius: 4px !important;
    background: var(--st-surface-2) !important;
    color: var(--st-text-muted) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
}

.feed-item:hover .unread-count.has-count::after,
.category-item:hover .unread-count.has-count::after {
    transform: none !important;
    color: var(--st-text-dim) !important;
}

.feed-item.active .unread-count.has-count::after,
.category-item.active .unread-count.has-count::after {
    background: var(--st-accent) !important;
    color: #1a1a1a !important;
    border-color: var(--st-accent) !important;
}

.sidebar.collapsed .toolbar #collapseBtn {
    background: var(--st-surface-2) !important;
    color: var(--st-text-dim) !important;
    border-color: var(--st-border) !important;
}

.sidebar.collapsed .toolbar #collapseBtn:hover {
    background: #323842 !important;
    color: var(--st-accent) !important;
    border-color: rgba(201, 162, 39, 0.35) !important;
}

.sidebar.collapsed .feed-list li::after {
    background: var(--st-surface-2) !important;
    color: var(--st-text) !important;
    border: 1px solid var(--st-border) !important;
}

/* ── Article list ── */
.article-list {
    background: var(--st-bg) !important;
}

.article-item {
    background: var(--st-surface) !important;
    border-color: var(--st-border) !important;
}

.article-item:hover {
    border-color: var(--st-accent) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
}

.article-item.active,
.article-item.keyboard-selected {
    border-color: var(--st-accent) !important;
    box-shadow: 0 0 0 2px var(--st-accent-soft) !important;
    background: rgba(201, 162, 39, 0.06) !important;
}

.article-item .image-container {
    background: var(--st-surface-2) !important;
}

.image-placeholder {
    background: var(--st-surface-2) !important;
}

/* ── Article reader ── */
.article-content {
    border: 1px solid var(--st-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55) !important;
}

.article-content .content,
.article-content .content h1,
.article-content .content h2,
.article-content .content h3,
.article-content .content h4 {
    color: var(--st-text) !important;
}

.article-content .meta,
.article-content .content figcaption,
.stat-label {
    color: var(--st-text-dim) !important;
}

.article-content .content figcaption span:first-child {
    color: var(--st-text) !important;
}

.article-content .content blockquote {
    background: var(--st-surface-2) !important;
    border-left-color: var(--st-accent) !important;
    color: var(--st-text-dim) !important;
}

.article-content .content a,
.article-content .meta a {
    color: var(--st-accent) !important;
}

.article-link {
    background: var(--st-accent) !important;
    color: #1a1a1a !important;
}

.article-header-image[src*="data:image/svg+xml"],
.article-content .content img[src*="data:image/svg+xml"] {
    background: var(--st-surface-2) !important;
    border-color: var(--st-border) !important;
    color: var(--st-text-muted) !important;
}

.reading-progress {
    background: rgba(255, 255, 255, 0.06) !important;
}

/* ── Icons ── */
.icon {
    filter: none;
    opacity: 0.85;
}

button:hover .icon,
.feed-list li.active .icon {
    opacity: 1;
}

/* ── Scroll & misc ── */
.scroll-to-top {
    background: var(--st-accent) !important;
    color: #1a1a1a !important;
    border-color: var(--st-accent) !important;
    border-radius: 8px !important;
    font-family: var(--st-mono);
    font-weight: 700;
}

.scroll-to-top:hover {
    background: var(--st-accent-hover) !important;
}

.scroll-indicator {
    background: var(--st-accent) !important;
}

.progress-bar {
    background: linear-gradient(90deg, var(--st-accent), var(--st-accent-hover)) !important;
}

.loading-text {
    background: rgba(20, 22, 24, 0.92) !important;
    color: var(--st-text) !important;
    border: 1px solid var(--st-border);
    font-family: var(--st-mono);
    font-size: 0.75rem;
}
.notification {
    background: var(--st-surface) !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}

.notification.success {
    background: rgba(61, 143, 95, 0.12) !important;
    border-left-color: var(--st-success) !important;
}

.notification.error {
    background: rgba(197, 48, 48, 0.12) !important;
    border-left-color: var(--st-danger) !important;
}

.notification.warning {
    background: rgba(234, 179, 8, 0.12) !important;
    border-left-color: #eab308 !important;
}

.notification.info {
    background: rgba(91, 143, 212, 0.12) !important;
    border-left-color: #5b8fd4 !important;
}

.notification.loading {
    background: var(--st-accent-soft) !important;
    border-left-color: var(--st-accent) !important;
}

/* ── Article extracted content ── */
.content article,
.article-header-content h1 {
    color: var(--st-text) !important;
}

.content article p,
.content p.article__paragraph {
    color: var(--st-text-dim) !important;
}

.content figcaption,
.content .article__legend {
    color: var(--st-text-muted) !important;
}

.content article a {
    color: var(--st-accent) !important;
}

.content article a:hover {
    color: var(--st-accent-hover) !important;
}

.content article blockquote {
    background: var(--st-surface-2) !important;
    border-left-color: var(--st-accent) !important;
}

/* ── Toolbar icon buttons ── */
.toolbar .btn-icon svg {
    color: currentColor;
}

.toolbar #collapseBtn svg {
    display: block;
}
