/* Shared dark-mode layer.
   Enable by setting: <html data-theme-mode="dark"> */

:root[data-theme-mode="dark"] {
    color-scheme: dark;

    --bg: #111317;
    --card: #191d23;
    --border: rgba(241, 245, 249, 0.12);
    --surface: #14181e;
    --surface-soft: #1c222b;
    --surface-accent: rgba(59, 130, 246, 0.16);

    --text-main: #f3efe6;
    --text-muted: rgba(243, 239, 230, 0.72);
    --text-subtle: rgba(243, 239, 230, 0.44);

    --primary: #74a8ff;
    --primary-600: #5d92f1;
    --primary-700: #4678ce;
    --secondary: #9380ff;
    --secondary-600: #7a66e4;

    --success: #54b48c;
    --danger: #f07167;
    --danger-600: #d95c53;
    --warning: #f2a65a;

    --primary-soft: rgba(116, 168, 255, 0.18);
    --secondary-soft: rgba(147, 128, 255, 0.18);
    --success-soft: rgba(84, 180, 140, 0.18);
    --danger-soft: rgba(240, 113, 103, 0.16);
    --warning-soft: rgba(242, 166, 90, 0.18);
    --primary-soft-bg: rgba(116, 168, 255, 0.11);
    --info-soft: rgba(116, 168, 255, 0.16);
    --info-text: #d9e7ff;
    --tooltip-bg: rgba(9, 11, 16, 0.96);
    --tooltip-foreground: #f3efe6;
    --tooltip-border: rgba(243, 239, 230, 0.12);

    --widget-manual-1: #bda98e;
    --widget-manual-1-strong: #9f886d;
    --widget-manual-1-soft: rgba(189, 169, 142, 0.2);
    --widget-manual-2: #7f89ff;
    --widget-manual-2-strong: #6670df;
    --widget-manual-2-soft: rgba(127, 137, 255, 0.2);
    --widget-manual-3: #d98d3f;
    --widget-manual-3-strong: #b96d20;
    --widget-manual-3-soft: rgba(217, 141, 63, 0.2);

    --nav-bg: rgba(14, 18, 24, 0.94);
    --nav-border: rgba(243, 239, 230, 0.08);
    --nav-link: rgba(243, 239, 230, 0.62);
    --nav-link-hover: rgba(243, 239, 230, 0.92);
    --nav-link-hover-bg: rgba(243, 239, 230, 0.06);
    --nav-link-active: var(--primary);
    --nav-link-active-bg: rgba(116, 168, 255, 0.16);
    --nav-icon: rgba(243, 239, 230, 0.42);
    --nav-icon-hover: rgba(243, 239, 230, 0.72);
    --nav-icon-active: var(--primary);
    --nav-section: rgba(243, 239, 230, 0.36);
    --logo-color: var(--primary);

    --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
    --shadow-hover: 0 24px 54px rgba(0, 0, 0, 0.42);
}

:root[data-theme="calm"][data-theme-mode="dark"] {
    --bg: #13161a;
    --card: #191d22;
    --border: rgba(226, 232, 240, 0.12);
    --surface: #161b21;
    --surface-soft: #1f252d;
    --surface-accent: rgba(29, 78, 216, 0.18);

    --text-main: #f4efe7;
    --text-muted: rgba(244, 239, 231, 0.74);
    --text-subtle: rgba(244, 239, 231, 0.42);

    --primary: #83acff;
    --primary-600: #628ee7;
    --primary-700: #4f73c1;
    --secondary: #9a85ff;
    --secondary-600: #7c68df;
}

:root[data-theme="editorial"][data-theme-mode="dark"] {
    --bg: #11100d;
    --card: #181613;
    --border: rgba(244, 238, 227, 0.12);
    --surface: rgba(26, 23, 19, 0.94);
    --surface-soft: rgba(31, 28, 23, 0.98);
    --surface-accent: rgba(58, 151, 142, 0.18);

    --text-main: #f4eee3;
    --text-muted: rgba(244, 238, 227, 0.72);
    --text-subtle: rgba(244, 238, 227, 0.42);

    --primary: #4aa79d;
    --primary-600: #3f8e86;
    --primary-700: #32716b;
    --secondary: #f0a14a;
    --secondary-600: #d5842d;

    --success: #4aa79d;
    --danger: #d66a61;
    --danger-600: #b8564e;
    --warning: #f0a14a;

    --primary-soft: rgba(74, 167, 157, 0.18);
    --secondary-soft: rgba(240, 161, 74, 0.18);
    --success-soft: rgba(74, 167, 157, 0.18);
    --danger-soft: rgba(214, 106, 97, 0.16);
    --warning-soft: rgba(240, 161, 74, 0.18);
    --primary-soft-bg: rgba(74, 167, 157, 0.11);
    --info-soft: rgba(74, 167, 157, 0.16);
    --info-text: #d7f2ee;

    --nav-bg: rgba(14, 12, 10, 0.92);
    --nav-border: rgba(244, 238, 227, 0.08);
    --nav-link: rgba(244, 238, 227, 0.6);
    --nav-link-hover: rgba(244, 238, 227, 0.92);
    --nav-link-hover-bg: rgba(244, 238, 227, 0.05);
    --nav-link-active: var(--primary);
    --nav-link-active-bg: rgba(74, 167, 157, 0.18);
    --nav-icon: rgba(244, 238, 227, 0.4);
    --nav-icon-hover: rgba(244, 238, 227, 0.72);
    --nav-icon-active: var(--primary);
    --nav-section: rgba(244, 238, 227, 0.34);
    --logo-color: var(--primary);

    --shadow: none;
    --shadow-hover: none;
}

:root[data-theme-mode="dark"] body,
:root[data-theme-mode="dark"] .app-body {
    background: var(--bg);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .app-card,
:root[data-theme-mode="dark"] .widget-picker__panel,
:root[data-theme-mode="dark"] .auth-card,
:root[data-theme-mode="dark"] .page-hero__settings-panel {
    background: var(--card);
    border-color: var(--border);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .sidebar {
    background: var(--nav-bg);
    border-right-color: var(--nav-border);
}

:root[data-theme-mode="dark"] .form-input,
:root[data-theme-mode="dark"] .form-select,
:root[data-theme-mode="dark"] .auth-field input {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .form-input::placeholder,
:root[data-theme-mode="dark"] .auth-field input::placeholder {
    color: var(--text-subtle);
}

:root[data-theme-mode="dark"] .btn-outline,
:root[data-theme-mode="dark"] .btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .btn-outline:hover,
:root[data-theme-mode="dark"] .btn-ghost:hover {
    background: var(--surface-soft);
}

:root[data-theme-mode="dark"] .widget-empty,
:root[data-theme-mode="dark"] .widget-settings-list,
:root[data-theme-mode="dark"] .widget-picker__item {
    background: var(--surface);
    border-color: var(--border);
}

:root[data-theme-mode="dark"] .ds-toolbar,
:root[data-theme-mode="dark"] .ds-theme,
:root[data-theme-mode="dark"] .ds-kbd {
    border-color: rgba(244, 238, 227, 0.1);
    background: rgba(17, 19, 23, 0.78);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .ds-toolbar--sticky::before {
    background: linear-gradient(
        to bottom,
        rgba(17, 19, 23, 0.94),
        rgba(17, 19, 23, 0.64),
        transparent
    );
}

:root[data-theme-mode="dark"] .widget-card--gradient::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 65%);
}

:root[data-theme-mode="dark"] .widget-card--gradient::after {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 70%);
}

:root[data-theme-mode="dark"] .widget-icon {
    background: rgba(243, 239, 230, 0.08);
    color: var(--text-main);
    box-shadow: inset 0 0 0 1px rgba(243, 239, 230, 0.12);
}

:root[data-theme-mode="dark"] .widget-action {
    background: rgba(243, 239, 230, 0.06);
    border-color: rgba(243, 239, 230, 0.14);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .widget-action:hover {
    background: var(--surface-soft);
    border-color: var(--primary);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .widget-card--gradient .widget-icon {
    background: rgba(243, 239, 230, 0.08);
    color: var(--text-main);
    box-shadow: inset 0 0 0 1px rgba(243, 239, 230, 0.12);
}

:root[data-theme-mode="dark"] .widget-card--gradient .widget-action {
    background: rgba(243, 239, 230, 0.06);
    border-color: rgba(243, 239, 230, 0.14);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .widget-card--gradient .widget-action:hover {
    background: rgba(243, 239, 230, 0.12);
    border-color: var(--primary);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .widget-card .btn-outline,
:root[data-theme-mode="dark"] .widget-card--gradient .btn-outline {
    background: rgba(243, 239, 230, 0.08);
    border-color: rgba(243, 239, 230, 0.16);
    color: var(--text-main);
}

:root[data-theme-mode="dark"] .widget-card .btn-outline:hover,
:root[data-theme-mode="dark"] .widget-card--gradient .btn-outline:hover {
    background: rgba(243, 239, 230, 0.16);
    border-color: var(--primary);
    color: #ffffff;
}

:root[data-theme-mode="dark"] .gertoni-list-row--head {
    background: rgba(243, 239, 230, 0.06);
}

:root[data-theme-mode="dark"] .gertoni-list-rows .gertoni-list-row:nth-child(even) {
    background: rgba(243, 239, 230, 0.1);
}

:root[data-theme-mode="dark"] .gertoni-list-row:not(.gertoni-list-row--head):hover {
    background: rgba(243, 239, 230, 0.14);
}

:root[data-theme-mode="dark"] .gertoni-list-row.is-selected {
    background: color-mix(in srgb, var(--primary) 24%, rgba(243, 239, 230, 0.08));
}

:root[data-theme-mode="dark"] .gertoni-list-action-btn,
:root[data-theme-mode="dark"] .gertoni-list-action-menu {
    background: rgba(243, 239, 230, 0.06);
    border-color: rgba(243, 239, 230, 0.14);
}

:root[data-theme-mode="dark"] .gertoni-list-action-menu button:hover {
    background: rgba(243, 239, 230, 0.12);
}
