/* Presentation layer only. Uses the existing theme palette and Bootstrap layout. */
body {
    --ui-line: var(--gray-200, #e2e8f0);
    --ui-shadow: 0 5px 22px rgba(24, 39, 65, .045);
    --ui-radius: 6px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body[data-theme-style="dark"] {
    --ui-shadow: 0 5px 22px rgba(0, 0, 0, .16);
}
h1, h2, h3, .h1, .h2, .h3 {
    letter-spacing: -.025em;
    line-height: 1.25;
    overflow-wrap: break-word;
}
.card {
    border-color: var(--ui-line);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
}
.card-header, .card-footer {
    border-color: var(--ui-line);
}
.card-header:first-child { border-radius: var(--ui-radius) var(--ui-radius) 0 0; }
.card-footer:last-child { border-radius: 0 0 var(--ui-radius) var(--ui-radius); }
.card-header { padding-top: 1rem; padding-bottom: 1rem; }
.btn {
    border-radius: var(--ui-radius);
    font-weight: 600;
    letter-spacing: .005em;
    transition: background-color .16s, border-color .16s, box-shadow .16s;
}
.btn:not(.btn-sm):not(.btn-link) { padding-top: .7rem; padding-bottom: .7rem; }
.btn-primary { box-shadow: 0 3px 9px rgba(24, 39, 65, .12); }
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}
.form-control, .custom-select, .input-group-text {
    border-radius: var(--ui-radius);
    border-color: var(--ui-line);
    font-size: 1rem;
}
.form-control:not(textarea):not([type="file"]), .custom-select {
    min-height: 2.9rem;
}
.form-control-sm, .custom-select-sm { min-height: 2.25rem !important; }
.form-control:focus, .custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}
label { font-weight: 550; margin-bottom: .5rem; }
.form-text { line-height: 1.55; }
.form-group { margin-bottom: 1.35rem; }
textarea.form-control { line-height: 1.6; }
.input-group > .form-control { min-width: 0; }
.input-group > .input-group-prepend > .btn,
.input-group > .input-group-append > .btn { height: 100%; }
.table { font-size: .95rem; }
.table thead th {
    font-size: .8rem;
    letter-spacing: .025em;
    color: var(--gray-600);
    font-weight: 650;
    background: var(--gray-50);
    border-bottom: 1px solid var(--ui-line);
    padding-top: 1rem;
    padding-bottom: 1rem;
}
.table td { vertical-align: middle; }
.table tbody tr:hover { background-color: var(--gray-50); }
.table-responsive, .table-custom-container { border-radius: var(--ui-radius); }
.table-responsive { overscroll-behavior-x: contain; }
.dropdown-menu {
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    box-shadow: 0 12px 35px rgba(24, 39, 65, .12);
    padding: .4rem;
}
.dropdown-item { border-radius: 4px; padding: .55rem .75rem; }
.badge { border-radius: 4px; font-weight: 550; line-height: 1.3; }
.alert { border-radius: var(--ui-radius); line-height: 1.6; }
.modal-content { border: 1px solid var(--ui-line); border-radius: 10px; }
.nav-pills .nav-link { border-radius: var(--ui-radius); }
.page-link { border-color: var(--ui-line); font-weight: 550; }
.navbar-main { border-bottom: 1px solid var(--ui-line); }
.navbar-expand-lg .navbar-nav .nav-link { font-size: .96rem; }
.app-footer {
    border-color: var(--ui-line);
    border-radius: var(--ui-radius);
    padding: 1.8rem;
    box-shadow: var(--ui-shadow);
}
#language_switch { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
#language_switch::after { content: attr(data-current-language); font-weight: 600; font-size: .88rem; }

/* Home: quiet geometric background, clearer hierarchy, no extra content or controls. */
body .index-background {
    position: relative;
    background:
        linear-gradient(0deg, var(--white) 0%, transparent 45%),
        radial-gradient(ellipse at 80% 8%, var(--primary-100), transparent 55%),
        linear-gradient(120deg, var(--gray-50), var(--white));
    border-bottom: 1px solid var(--gray-100);
    padding-top: clamp(3.5rem, 7vw, 6.5rem) !important;
    padding-bottom: clamp(3rem, 6vw, 5.5rem) !important;
}
body[data-theme-style="dark"] .index-background {
    background: radial-gradient(ellipse at 80% 0%, var(--primary-100), transparent 60%), linear-gradient(120deg, var(--gray-50), var(--white));
}
body .index-header {
    color: var(--gray-900);
    font-size: clamp(2.2rem, 4.2vw, 4rem);
    letter-spacing: -.04em;
    font-weight: 750;
    line-height: 1.1;
    margin-bottom: 1.3rem !important;
}
body .index-subheader { font-size: clamp(1.05rem, 1.4vw, 1.25rem); line-height: 1.7; }
body .index-button { padding: .9rem 2.25rem; font-size: 1rem; }
#search input[type="search"] {
    border: 1px solid var(--ui-line);
    box-shadow: var(--ui-shadow);
    min-height: 3.5rem;
    padding-inline: 1.2rem;
}
[data-tool-id] > .card {
    transition: border-color .16s, box-shadow .16s;
    border-radius: var(--ui-radius);
}
[data-tool-id] > .card:hover {
    border-color: var(--primary-300, var(--primary));
    box-shadow: 0 7px 24px rgba(24, 39, 65, .09);
}
[data-tool-id] .card-body {
    min-width: 0;
    padding: 1.35rem 1.2rem;
}
[data-tool-id] .card-body.text-truncate {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
[data-tool-id] .stretched-link {
    display: block;
    font-size: 1.05rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    margin-bottom: .4rem;
}
[data-tool-id] .card-body p.text-truncate {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    line-height: 1.6;
    font-size: .875rem;
}
[data-tool-id] .tool-icon-wrapper { padding-left: 1.1rem; padding-right: 0; flex-shrink: 0; }
[data-tool-id] .tool-icon { border-radius: 6px !important; }
[data-tool-id] > .card > .p-3 { padding-left: .4rem !important; }

/* Admin: preserve sidebar dimensions and all responsive toggling. */
.admin-sidebar { border-color: var(--ui-line); border-radius: 8px; box-shadow: var(--ui-shadow); }
.admin-sidebar-title { border-bottom: 1px solid var(--gray-100); }
.admin-sidebar-links-wrapper, .admin-sidebar-links-wrapper:hover {
    width: 100%;
    scrollbar-width: thin !important;
    scrollbar-color: var(--gray-300) transparent !important;
}
.admin-sidebar-links-wrapper::-webkit-scrollbar { width: 6px; }
.admin-sidebar-links-wrapper::-webkit-scrollbar-thumb { background: var(--gray-300); }
.admin-sidebar-links li > a { font-size: .94rem; border-radius: 5px; line-height: 1.5; }
.admin-sidebar-links li.active > a:not(.default) { font-weight: 650; }
.admin-sidebar-links .text-truncate { white-space: normal; overflow-wrap: break-word; }
.select2-container--default .select2-selection--single {
    min-height: 2.9rem;
    border-color: var(--ui-line);
    border-radius: var(--ui-radius);
}
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 2.8rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 2.8rem; }
.select2-dropdown { border-color: var(--ui-line); border-radius: var(--ui-radius); }
.ql-toolbar.ql-snow { border-color: var(--ui-line); border-radius: 6px 6px 0 0; background: var(--gray-50); }
.ql-container.ql-snow { border-color: var(--ui-line); border-radius: 0 0 6px 6px; font-size: 1rem; }
.ql-editor { min-height: 12rem; line-height: 1.7; }
.ce-popover, .ce-toolbar__settings-btn, .ce-toolbar__plus { color: #182238; }
html[lang="ru"] .ql-snow .ql-tooltip::before { content: "Ссылка:"; }
html[lang="ru"] .ql-snow .ql-tooltip.ql-editing a.ql-action::after { content: "Сохранить"; }
html[lang="ru"] .ql-snow .ql-tooltip a.ql-action::after { content: "Изменить"; }
html[lang="ru"] .ql-snow .ql-tooltip a.ql-remove::before { content: "Удалить"; }
html[lang="ru"] .ql-snow .ql-tooltip[data-mode="link"]::before { content: "Введите ссылку:"; }
html[lang="ru"] .ql-snow .ql-tooltip[data-mode="video"]::before { content: "Ссылка на видео:"; }
html[lang="ru"] .ql-snow .ql-tooltip[data-mode="formula"]::before { content: "Формула:"; }
html[lang="ru"] .ql-snow .ql-picker.ql-size .ql-picker-label::before,
html[lang="ru"] .ql-snow .ql-picker.ql-size .ql-picker-item::before { content: "Обычный"; }
html[lang="ru"] .ql-snow .ql-picker.ql-size [data-value="small"]::before { content: "Маленький"; }
html[lang="ru"] .ql-snow .ql-picker.ql-size [data-value="large"]::before { content: "Крупный"; }
html[lang="ru"] .ql-snow .ql-picker.ql-size [data-value="huge"]::before { content: "Огромный"; }
html[lang="ru"] .ql-snow .ql-picker.ql-header .ql-picker-label::before,
html[lang="ru"] .ql-snow .ql-picker.ql-header .ql-picker-item::before { content: "Текст"; }
html[lang="ru"] .ql-snow .ql-picker.ql-header [data-value="1"]::before { content: "Заголовок 1"; }
html[lang="ru"] .ql-snow .ql-picker.ql-header [data-value="2"]::before { content: "Заголовок 2"; }
@media (max-width: 575.98px) {
    .card-body { padding: 1.15rem; }
    .app-footer { padding: 1.25rem; }
    .index-background .col-11, .index-background .col-10 { flex: 0 0 100%; max-width: 100%; }
    [data-tool-id] { padding: .5rem .75rem !important; }
    [data-tool-id] .card-body { padding: 1rem .8rem; }
    [data-tool-id] .stretched-link { font-size: 1rem; }
    [data-tool-id] .tool-icon-wrapper { padding-left: .7rem; }
    [data-tool-id] .tool-icon { min-width: 2.25rem; width: 2.25rem; height: 2.25rem; }
    .ql-toolbar.ql-snow { padding: .45rem; }
    .ql-snow .ql-tooltip { max-width: calc(100vw - 2rem); white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .btn, [data-tool-id] > .card { transition: none; }
}
@media print {
    .card, .app-footer { box-shadow: none; }
    body .index-background { background: none; }
}
