/* ==========================================================
   CalcEon — Design System
   Version 1.0
   ========================================================== */

/* 01. Design tokens
   ========================================================== */

:root {
    color-scheme: light;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;

    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --surface-hover: #f1f5f9;

    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --success: #059669;
    --success-bg: #ecfdf5;

    --danger: #dc2626;
    --danger-bg: #fef2f2;

    --warning: #b45309;
    --warning-bg: #fffbeb;

    --header-bg: rgba(255, 255, 255, 0.96);
    --hero-bg: linear-gradient(135deg, #eff6ff, #f5f3ff);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10);

    --container: 1240px;
    --header-height: 72px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Arial, sans-serif;

    --transition: 160ms ease;
}

/* 02. Dark theme
   ========================================================== */

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

    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --primary-soft: #172b49;

    --bg: #0b1120;
    --surface: #111c2e;
    --surface-alt: #152135;
    --surface-hover: #1c2a40;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --muted: #94a3b8;

    --border: #263449;
    --border-strong: #3b4b62;

    --success: #34d399;
    --success-bg: #10352d;

    --danger: #fca5a5;
    --danger-bg: #3b1b24;

    --warning: #fbbf24;
    --warning-bg: #382c18;

    --header-bg: rgba(11, 17, 32, 0.96);
    --hero-bg: linear-gradient(135deg, #13233d, #201c38);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.25);
}

/* 03. Reset and typography
   ========================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-padding-top: 90px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 16px;
    color: var(--text);
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: clamp(23px, 3vw, 30px);
}

h3 {
    font-size: 20px;
}

h4 {
    font-size: 17px;
}

p {
    margin: 0 0 16px;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

img,
svg {
    max-width: 100%;
}

img {
    display: block;
    height: auto;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

::selection {
    background: var(--primary);
    color: #ffffff;
}

[hidden] {
    display: none !important;
}

/* 04. Layout
   ========================================================== */

.container {
    width: min(calc(100% - 48px), var(--container));
    margin-inline: auto;
}

.site-main {
    flex: 1;
    min-width: 0;
}

.section {
    padding-block: 36px;
}

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

.section-header h2 {
    margin: 0;
}

.page-header {
    padding-block: 20px 28px;
}

.page-header p {
    max-width: 850px;
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 17px;
}

.page-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px;
    align-items: start;
}

.page-content,
.page-sidebar {
    min-width: 0;
}

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

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

.skip-link {
    position: fixed;
    top: -100px;
    left: 16px;
    z-index: 2000;
    padding: 12px 20px;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.skip-link:focus {
    top: 12px;
}

/* 05. Header and navigation
   ========================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.header-inner {
    position: relative;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: var(--text);
}

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

.brand-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.brand-name {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1;
}

.brand-name span {
    color: var(--primary);
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 6px;
}

.header-nav a {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.header-nav a:hover,
.header-nav a[aria-current] {
    background: var(--primary-soft);
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    transition: background var(--transition),
        color var(--transition),
        border-color var(--transition);
}

.icon-button:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

.menu-toggle {
    display: none;
}

.theme-icon-sun {
    display: none;
}

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

html[data-theme="dark"] .theme-icon-sun {
    display: block;
}

/* 06. Breadcrumbs
   ========================================================== */

.breadcrumbs {
    padding-block: 20px 4px;
    font-size: 13px;
    color: var(--muted);
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.breadcrumbs a {
    color: var(--muted);
}

.breadcrumbs a:hover {
    color: var(--primary);
}

.breadcrumbs [aria-current] {
    color: var(--text-secondary);
}

.breadcrumb-separator {
    color: var(--muted);
    opacity: 0.6;
}

/* 07. Hero
   ========================================================== */

.hero {
    padding: 64px 0 56px;
    background: var(--hero-bg);
    border-bottom: 1px solid var(--border);
}

.hero-inner {
    max-width: 860px;
    margin-inline: auto;
    text-align: center;
}

.hero-eyebrow {
    display: inline-block;
    margin-bottom: 18px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--surface);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero h1 {
    margin-bottom: 20px;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.12;
    letter-spacing: -0.045em;
}

.hero h1 span {
    color: var(--primary);
}

.hero-description {
    max-width: 680px;
    margin: 0 auto 30px;
    color: var(--text-secondary);
    font-size: clamp(16px, 2vw, 19px);
}

.hero-search {
    max-width: 720px;
    margin-inline: auto;
}

.quick-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.quick-links a {
    padding: 7px 15px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.quick-links a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.hero-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px 32px;
    margin-top: 32px;
    color: var(--muted);
    font-size: 14px;
}

.hero-stats strong {
    color: var(--text);
}

/* 08. Buttons
   ========================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 11px 22px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    transition: background var(--transition),
        border-color var(--transition),
        color var(--transition);
}

.btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d4ed8;
    color: #ffffff;
}

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

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.btn-block {
    width: 100%;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
}

/* 09. Forms and search
   ========================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.form-group label,
.form-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.form-control {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding: 12px 15px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    transition: border-color var(--transition),
        box-shadow var(--transition);
}

.form-control::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-control[aria-invalid="true"] {
    border-color: var(--danger);
}

.form-hint {
    color: var(--muted);
    font-size: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.search-form input {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    padding: 10px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    outline: none;
}

.search-form:focus-within {
    border-color: var(--primary);
}

.search-form .btn {
    flex-shrink: 0;
}

/* 10. Cards
   ========================================================== */

.card {
    min-width: 0;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.category-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition),
        border-color var(--transition),
        box-shadow var(--transition);
}

.category-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
    color: var(--text);
}

.category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
}

.category-card h3 {
    margin: 0;
    font-size: 19px;
}

.category-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.category-count {
    margin-top: auto;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
}

.calculator-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.calculator-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition),
        box-shadow var(--transition);
}

.calculator-card:hover {
    border-color: var(--primary);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.calculator-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
}

.calculator-card-body {
    flex: 1;
    min-width: 0;
}

.calculator-card h3 {
    margin: 0 0 7px;
    font-size: 16px;
    line-height: 1.4;
}

.calculator-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.calculator-card-arrow {
    flex-shrink: 0;
    color: var(--muted);
}

/* 11. Calculator interface
   ========================================================== */

.calculator-panel {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.calculator-panel h2 {
    font-size: 23px;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.calculator-form .form-group label {
    display: flex;
    align-items: flex-end;
    min-height: 44px;
}

.calculator-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.calculator-actions .btn-primary {
    min-width: 160px;
}

.result-panel {
    margin-top: 28px;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--primary-soft);
}

.result-label {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.result-value {
    margin-bottom: 18px;
    color: var(--primary);
    font-size: clamp(30px, 5vw, 48px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.result-details {
    display: grid;
    gap: 0;
}

.result-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

.result-detail strong {
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.result-error {
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 14px;
}

.formula-box {
    margin-block: 20px;
    padding: 20px;
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    overflow-wrap: anywhere;
}

/* 12. Content and related tools
   ========================================================== */

.content-section {
    margin-top: 28px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.prose {
    color: var(--text-secondary);
}

.prose h2 {
    margin-top: 30px;
    margin-bottom: 16px;
}

.prose h3 {
    margin-top: 24px;
    margin-bottom: 12px;
}

.prose h2:first-child,
.prose h3:first-child {
    margin-top: 0;
}

.prose ul,
.prose ol {
    padding-left: 24px;
    margin-block: 16px;
}

.prose li {
    margin-bottom: 8px;
}

.prose a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.related-list {
    display: flex;
    flex-direction: column;
}

.related-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.related-link:last-child {
    border-bottom: 0;
}

.related-link:hover {
    color: var(--primary);
}

.sidebar-card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.sidebar-card + .sidebar-card {
    margin-top: 20px;
}

.sidebar-card h2,
.sidebar-card h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

/* 13. Tables
   ========================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.data-table th {
    background: var(--surface-alt);
    color: var(--text);
    font-weight: 600;
}

.data-table td {
    color: var(--text-secondary);
}

.data-table tr:last-child td {
    border-bottom: 0;
}

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

/* 14. FAQ
   ========================================================== */

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.faq-item summary {
    padding: 16px 20px;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.faq-item[open] summary {
    color: var(--primary);
}

.faq-answer {
    padding: 0 20px 18px;
    color: var(--text-secondary);
    font-size: 15px;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

/* 15. Empty states and error pages
   ========================================================== */

.empty-state,
.error-page {
    padding: 64px 24px;
    text-align: center;
}

.empty-state p,
.error-page p {
    max-width: 600px;
    margin: 0 auto 24px;
    color: var(--muted);
}

.error-code {
    margin-bottom: 12px;
    color: var(--primary);
    font-size: clamp(72px, 14vw, 140px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.06em;
}

/* 16. Advertising
   ========================================================== */

.ad-slot {
    margin-block: 24px;
    min-width: 0;
    text-align: center;
}

.ad-label {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ad-slot img {
    max-width: 100%;
    margin-inline: auto;
    border-radius: var(--radius-sm);
}

/* 17. Footer
   ========================================================== */

.site-footer {
    margin-top: 48px;
    padding-top: 42px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 40px;
    padding-bottom: 36px;
}

.footer-brand .brand {
    margin-bottom: 18px;
}

.footer-description {
    max-width: 350px;
    color: var(--muted);
    font-size: 14px;
}

.footer-slogan {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.footer-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.footer-heading {
    margin-bottom: 6px;
    font-size: 15px;
    letter-spacing: 0;
}

.footer-column a {
    color: var(--muted);
    font-size: 14px;
}

.footer-column a:hover {
    color: var(--primary);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-block: 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}

/* 18. Responsive layout
   ========================================================== */

@media (max-width: 1100px) {
    .header-nav {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        left: 0;
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--surface);
        box-shadow: var(--shadow-lg);
    }

    .header-nav.is-open {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .header-nav a {
        padding: 12px 16px;
        white-space: normal;
    }

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

    .page-layout {
        grid-template-columns: minmax(0, 1fr) 260px;
        gap: 20px;
    }

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

@media (max-width: 850px) {
    .page-layout {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 28px;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    :root {
        --header-height: 64px;
    }

    .container {
        width: calc(100% - 28px);
    }

    .header-inner {
        gap: 12px;
    }

    .brand-name {
        font-size: 25px;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
    }

    .header-actions {
        gap: 5px;
    }

    .icon-button {
        width: 38px;
        height: 38px;
    }

    .hero {
        padding-block: 38px 34px;
    }

    .hero-description {
        margin-bottom: 22px;
    }

    .hero-stats {
        gap: 10px 20px;
        font-size: 13px;
    }

    .section {
        padding-block: 26px;
    }

    .section-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 18px;
    }

    .category-grid {
        gap: 12px;
    }

    .category-card {
        padding: 16px;
        gap: 10px;
    }

    .category-card h3 {
        font-size: 16px;
    }

    .category-card p {
        font-size: 12px;
    }

    .category-icon {
        width: 44px;
        height: 44px;
    }

    .calculator-grid,
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .calculator-form .form-group label {
        min-height: 0;
    }

    .card,
    .calculator-panel,
    .content-section,
    .sidebar-card {
        padding: 20px;
    }

    .result-panel {
        padding: 20px;
    }

    .calculator-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .calculator-actions .btn {
        width: 100%;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-footer {
        margin-top: 30px;
        padding-top: 30px;
    }
}

@media (max-width: 380px) {
    .brand {
        gap: 7px;
    }

    .brand-name {
        font-size: 22px;
    }

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

    .search-form .btn {
        padding-inline: 14px;
    }

    .search-form input {
        padding-inline: 8px;
    }
}

/* 19. Accessibility
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 20. Print
   ========================================================== */

@media print {
    .site-header,
    .site-footer,
    .breadcrumbs,
    .page-sidebar,
    .calculator-actions,
    .ad-slot,
    .skip-link {
        display: none !important;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    .container {
        width: 100%;
        max-width: none;
    }

    .page-layout {
        display: block;
    }

    .calculator-panel,
    .content-section,
    .result-panel {
        box-shadow: none;
        background: #ffffff;
        color: #000000;
        break-inside: avoid;
    }

    .result-value,
    .result-label,
    .result-detail,
    .result-detail strong,
    .form-control,
    h1,
    h2,
    h3 {
        color: #000000;
    }
}
/* ==========================================================
   21. Favorite buttons
   ========================================================== */

.icon-button[data-favorite-id].is-favorite {
    color: #e11d48;
    background: #fff1f2;
    border-color: #fda4af;
}

.icon-button[data-favorite-id].is-favorite svg {
    fill: currentColor;
}

.icon-button[data-favorite-id].is-favorite:hover {
    color: #be123c;
    background: #ffe4e6;
    border-color: #e11d48;
}

html[data-theme="dark"]
.icon-button[data-favorite-id].is-favorite {
    color: #fb7185;
    background: #3b1827;
    border-color: #9f1239;
}

html[data-theme="dark"]
.icon-button[data-favorite-id].is-favorite:hover {
    color: #fda4af;
    background: #4c1d30;
    border-color: #fb7185;
}

/* ==========================================================
   22. Calculator layout refinements
   ========================================================== */

.calculator-panel > .section-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
    margin-bottom: 24px;
}

.calculator-panel > .section-header h2 {
    min-width: 0;
    margin: 0;
}

.calculator-panel > .section-header .icon-button {
    flex-shrink: 0;
}

/* Mobile calculator layout */

@media (max-width: 600px) {

    .calculator-panel > .section-header {
        margin-bottom: 20px;
    }

    .calculator-panel > .section-header h2 {
        font-size: 20px;
        line-height: 1.3;
    }

    .calculator-form .form-group label {
        min-height: 0;
    }

    .calculator-panel,
    .page-content,
    .page-sidebar,
    .form-grid > * {
        min-width: 0;
    }

    .result-value,
    .formula-box,
    .result-detail strong {
        overflow-wrap: anywhere;
    }
}

/* ==========================================================
   23. Calculator catalog
   ========================================================== */

.catalog-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.catalog-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.catalog-stat strong {
    color: var(--primary);
    font-size: clamp(24px, 3vw, 36px);
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.catalog-stat span {
    font-size: 14px;
    color: var(--text-secondary);
}

.catalog-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0;
}

.catalog-navigation a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.catalog-navigation a:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.catalog-navigation a span {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
}

.catalog-category {
    scroll-margin-top: 100px;
}

.catalog-category-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.catalog-category-heading .category-icon {
    flex-shrink: 0;
}

.catalog-category-heading h2 {
    margin: 0 0 4px;
}

.catalog-category-heading .text-muted {
    font-size: 13px;
}

.catalog-category-description {
    margin: 0 0 24px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.catalog-more {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.page-catalog .search-form input {
    flex: 1;
    min-width: 0;
}

.page-catalog .search-form > svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.page-catalog .calculator-card-body {
    min-width: 0;
}

@media (max-width: 600px) {

    .catalog-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .catalog-stat {
        padding: 16px;
    }

    .catalog-stat:last-child {
        grid-column: 1 / -1;
    }

    .catalog-navigation {
        gap: 8px;
    }

    .catalog-navigation a {
        padding: 8px 12px;
        font-size: 13px;
    }

    .catalog-category-heading {
        gap: 10px;
    }

    .catalog-category-description {
        margin-bottom: 18px;
    }

    .catalog-more .btn {
        width: 100%;
        text-align: center;
        white-space: normal;
    }

    .page-catalog .search-form {
        flex-wrap: wrap;
    }

    .page-catalog .search-form > svg {
        display: none;
    }

    .page-catalog .search-form input,
    .page-catalog .search-form button {
        flex: 1 1 100%;
        width: 100%;
    }
}
/* ==========================================================
   Favorites
   ========================================================== */

.favorites-header-link {
    position: relative;
    flex-shrink: 0;
}

.favorites-header-link[aria-current="page"] {
    color: #dc2626;
}

.favorites-header-link[aria-current="page"] svg {
    fill: currentColor;
}

.favorites-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    border-radius: 20px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    pointer-events: none;
}

.favorites-count[hidden],
[data-favorites-page] [hidden] {
    display: none !important;
}

.favorite-card {
    cursor: default;
    min-width: 0;
}

.favorite-card .calculator-card-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.favorite-card-icon {
    flex-shrink: 0;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.10);
    font-size: 24px;
    font-weight: 700;
}

.favorite-card h3 a {
    color: inherit;
    text-decoration: none;
}

.favorite-card h3 a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.favorite-remove {
    flex-shrink: 0;
}

.favorite-remove:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.08);
}

[data-favorites-empty] > svg {
    color: #dc2626;
    margin-bottom: 16px;
}

[data-favorites-status]:empty {
    display: none;
}

[data-theme="dark"] .favorite-card-icon {
    color: #93c5fd;
    background: rgba(96, 165, 250, 0.12);
}

[data-theme="dark"] .favorite-card h3 a:hover {
    color: #93c5fd;
}

[data-theme="dark"] .favorite-remove:hover,
[data-theme="dark"] .favorites-header-link[aria-current="page"] {
    color: #f87171;
}

@media (max-width: 430px) {
    .header-actions {
        gap: 4px;
    }

    .page-favorites [data-favorites-page] > .section-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .favorite-card {
        gap: 10px;
    }

    .favorites-count {
        min-width: 17px;
        height: 17px;
        line-height: 17px;
    }
}
/* ==========================================================
   Calculation history
   ========================================================== */

[data-history-page] [hidden] {
    display: none !important;
}

[data-history-status]:empty {
    display: none;
}

.history-list {
    display: grid;
    gap: 32px;
}

.history-group {
    min-width: 0;
}

.history-group-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.history-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    padding: 20px;
}

.history-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.10);
    color: #2563eb;
    font-size: 24px;
    font-weight: 700;
}

.history-card-heading {
    flex: 1;
    min-width: 0;
}

.history-card-heading h3 {
    margin: 0 0 4px;
    font-size: 16px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.history-card-heading a {
    color: inherit;
    text-decoration: none;
}

.history-card-heading a:hover {
    color: #2563eb;
}

.history-time {
    font-size: 12px;
    color: #64748b;
}

.history-icon-button {
    flex-shrink: 0;
}

.history-remove:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.08);
}

.history-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
}

.history-input {
    min-width: 0;
}

.history-input dt {
    margin-bottom: 5px;
    color: #64748b;
    font-size: 13px;
}

.history-input dd {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.history-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.10);
}

.history-result-body {
    flex: 1;
    min-width: 0;
}

.history-result-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #64748b;
}

.history-result-value {
    display: block;
    color: #2563eb;
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    line-height: 1.3;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.history-card-footer {
    margin-top: auto;
}

.history-open-link {
    color: #2563eb;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.history-open-link:hover {
    text-decoration: underline;
}

[data-history-empty] > svg {
    color: #2563eb;
    margin-bottom: 16px;
}

/* Dark theme */

[data-theme="dark"] .history-group-title,
[data-theme="dark"] .history-time,
[data-theme="dark"] .history-input dt,
[data-theme="dark"] .history-result-label {
    color: #94a3b8;
}

[data-theme="dark"] .history-card-icon {
    background: rgba(96, 165, 250, 0.12);
    color: #93c5fd;
}

[data-theme="dark"] .history-result {
    background: rgba(96, 165, 250, 0.08);
    border-color: rgba(96, 165, 250, 0.15);
}

[data-theme="dark"] .history-result-value,
[data-theme="dark"] .history-open-link,
[data-theme="dark"] .history-card-heading a:hover,
[data-theme="dark"] [data-history-empty] > svg {
    color: #93c5fd;
}

[data-theme="dark"] .history-remove:hover {
    color: #f87171;
}

/* Responsive */

@media (max-width: 700px) {
    .history-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 430px) {
    .page-history [data-history-page] > .section-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .history-card {
        padding: 16px;
        gap: 16px;
    }

    .history-card-icon {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .history-inputs {
        gap: 12px;
    }

    .history-result {
        padding: 12px;
    }
}

/* ==================================================
   Calculator result actions
   ================================================== */

.result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.result-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    text-decoration: none;
    text-align: center;
}

.result-actions .btn svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Mobile result actions */

@media (max-width: 480px) {

    .result-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 16px;
    }

    .result-actions .btn {
        width: 100%;
        box-sizing: border-box;
    }

}

/* ==================================================
   CalcEon — Footer layout v2
   ================================================== */

.footer-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1.4fr)
        minmax(0, 1fr)
        minmax(0, .85fr)
        minmax(0, 1.2fr);

    align-items: start;
    gap: 32px;

    padding-bottom: 36px;
}

.footer-brand {
    min-width: 0;
    grid-column: auto;
}

.footer-brand .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    margin-bottom: 18px;
}

.footer-logo {
    display: block;

    width: 38px;
    height: 38px;

    flex-shrink: 0;
    object-fit: contain;
}

.footer-description {
    max-width: 320px;
    margin-bottom: 14px;

    font-size: 14px;
    line-height: 1.7;
    color: var(--muted);
}

.footer-slogan {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;

    color: var(--text-secondary);
}

.footer-column {
    min-width: 0;
    gap: 12px;
}

.footer-heading {
    margin: 0 0 6px;

    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;

    color: var(--text);
}

.footer-column a {
    max-width: 100%;

    font-size: 14px;
    line-height: 1.5;

    color: var(--muted);
    text-decoration: none;
    overflow-wrap: anywhere;

    transition: color .15s ease;
}

.footer-column a:hover {
    color: var(--primary);
}

.footer-column a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
    border-radius: 3px;
}

/* Tablet */

@media (max-width: 1000px) {

    .footer-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 32px;
    }

    .footer-brand {
        grid-column: auto;
    }

}

/* Mobile */

@media (max-width: 540px) {

    .site-footer {
        margin-top: 32px;
        padding-top: 30px;
    }

    .footer-grid {
        grid-template-columns: minmax(0, 1fr);

        gap: 26px;
        padding-bottom: 28px;
    }

    .footer-brand {
        grid-column: auto;
    }

    .footer-description {
        max-width: 100%;
    }

    .footer-column {
        gap: 12px;
    }

    .footer-heading {
        margin-bottom: 4px;
        font-size: 16px;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;

        gap: 8px;
        line-height: 1.6;
    }

}

@media (prefers-reduced-motion: reduce) {

    .footer-column a {
        transition: none;
    }

}