/* ---------- Advanced page styles with side gutters ---------- */
:root {
    --primary: #0b57d0;
    --on-primary: #fff;
    --primary-container: #d3e3fd;
    --surface: #fff;
    --surface-container: #f0f4f9;
    --surface-container-high: #e9ebf0;
    --on-surface-default: #1b1c1d;
    --on-surface-de-emphasis: #444746;
    --outline: #747775;
    --stroke-default: #dcdfe5;
    --ff-sans: "Google Sans", "Roboto", sans-serif;
    --ff-mono: "Google Code", "SF Mono", monospace;
    --control-label-width: 170px;
    --component-height-default: 36px;
    --radius-m: 12px;
    --gutter-width: 48px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #a8c7fa;
        --surface: #101218;
        --surface-container: #282a2c;
        --surface-container-high: #2a2b36;
        --on-surface-default: #fff;
        --on-surface-de-emphasis: #c4c7c5;
        --outline: #9a9b9c;
        --stroke-default: #2d2f38;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    height: 100%;
    font-family: var(--ff-sans);
    background: var(--surface-container);
}

.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.site-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--surface);
}

/* Header */
.widget-header {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--stroke-default);
}

.header-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
}

.widget-title {
    font-size: 1.3rem;
    font-weight: 500;
    margin: 0;
}

.widget-title a {
    text-decoration: none;
    color: var(--on-surface-default);
}

.action-buttons-top {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

.button {
    font-family: var(--ff-sans);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    border: none;
    cursor: pointer;
    background: var(--surface-container-high);
    color: var(--on-surface-default);
    transition: 0.2s;
}

.button.primary-action {
    background: var(--primary);
    color: var(--on-primary);
}

.button:hover {
    filter: brightness(0.95);
}

.full-width {
    width: 100%;
}

/* Main content with gutters */
.main-with-gutters {
    display: flex;
    flex: 1;
    position: relative;
    background: var(--surface);
}

.content-area {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    background: var(--surface);
}

.gutter-left, .gutter-right {
    width: var(--gutter-width);
    flex-shrink: 0;
    background: var(--surface);
}

/* Mini navigation */
.mini-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--stroke-default);
}
.mini-nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.3rem 1rem;
    border-radius: 2rem;
    text-decoration: none;
    color: var(--on-surface-de-emphasis);
    background: transparent;
    transition: all 0.2s;
}
.mini-nav-link.active {
    background: var(--primary-container);
    color: var(--on-surface-primary);
    font-weight: 600;
}
.mini-nav-link:hover:not(.active) {
    background: var(--surface-container-high);
}

/* Panels */
.split-panels {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-m);
    border: 1px solid var(--stroke-default);
    overflow: hidden;
    min-height: 300px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--surface-container);
    border-bottom: 1px solid var(--stroke-default);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--on-surface-de-emphasis);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.output-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.7rem;
    flex-wrap: wrap;
}

textarea {
    flex: 1;
    background: var(--surface);
    border: none;
    padding: 1rem;
    font-family: var(--ff-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    color: var(--on-surface-default);
}

/* Controls */
.controls-root {
    background: var(--surface);
    border-top: 1px solid var(--stroke-default);
    padding: 1rem;
}

.process-button-row {
    text-align: center;
    margin-bottom: 1.5rem;
}

.process-btn {
    padding: 0.6rem 2rem;
    font-size: 1rem;
}

.controls-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 280px;
    min-width: 240px;
}

.controls-label {
    width: var(--control-label-width);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--on-surface-de-emphasis);
    flex-shrink: 0;
}

.row-findreplace {
    flex: 1 1 100%;
    flex-wrap: wrap;
}

.findreplace-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.findreplace-wrapper .input-field {
    flex: 1;
}

.arrow-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--on-surface-de-emphasis);
}

.row-input-toggle {
    flex-wrap: wrap;
}

.input-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.input-toggle-wrapper .input-field {
    flex: 1;
}

.row-slider-like {
    flex-wrap: wrap;
}

.length-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.small-select {
    height: var(--component-height-default);
    background: var(--surface-container-high);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    padding: 0 0.5rem;
    font-family: var(--ff-sans);
    font-size: 0.8rem;
    color: var(--on-surface-default);
    outline: none;
    flex: 1;
}

.small-number {
    width: 90px;
}

/* Toggle switch */
.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--surface-container-high);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--outline);
    transition: background 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    flex-shrink: 0;
}

.toggle-switch.active {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-knob {
    width: 18px;
    height: 18px;
    background: var(--on-surface-de-emphasis);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1), background 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-switch.active .toggle-knob {
    background: var(--on-primary);
    transform: translateX(20px);
}

.input-field {
    height: var(--component-height-default);
    background: var(--surface-container-high);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    padding: 0 0.75rem;
    font-family: var(--ff-sans);
    font-size: 0.8rem;
    color: var(--on-surface-default);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary);
}

.button-bar-bottom {
    margin-top: 1.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    color: var(--on-surface-de-emphasis);
}

.icon-btn:hover {
    background: var(--surface-container-high);
}

/* Footer */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--stroke-default);
    text-align: center;
    padding: 0.8rem 1rem;
    font-size: 0.75rem;
    color: var(--on-surface-de-emphasis);
}

.footer-links {
    display: flex;
    justify-content: center;
	font-size: 0.9rem;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--on-surface-de-emphasis);
    text-decoration: none;
}

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

.footer-copyright {
    opacity: 0.6;
	font-size: 0.9rem;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
    :root {
        --gutter-width: 12px;
        --control-label-width: 100%;
    }

    .split-panels {
        flex-direction: column;
        gap: 1rem;
    }

    .panel {
        min-height: 200px;
    }

    textarea {
        min-height: 150px;
    }

    .process-btn {
        width: 100%;
    }

    .controls-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        min-width: 100%;
    }

    .controls-label {
        width: 100%;
    }

    .findreplace-wrapper {
        width: 100%;
        flex-wrap: wrap;
    }
    .findreplace-wrapper .input-field {
        width: 100%;
        flex: auto;
    }
    .arrow-icon {
        align-self: center;
        transform: rotate(90deg);
        margin: 0.25rem 0;
    }

    .input-toggle-wrapper {
        width: 100%;
        flex-wrap: wrap;
    }
    .input-toggle-wrapper .input-field {
        width: 100%;
        flex: auto;
    }
    .toggle-switch {
        align-self: flex-start;
    }

    .length-filter-wrapper {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .small-select, .small-number {
        width: 100%;
    }

    .input-field {
        width: 100%;
    }

    .button-bar-bottom {
        margin-top: 1rem;
    }

    .footer-links {
        gap: 1rem;
        font-size: 0.8rem;
    }

    .output-stats {
        font-size: 0.65rem;
        gap: 0.5rem;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .action-buttons-top {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .widget-title {
        font-size: 1.1rem;
    }
    .gutter-left, .gutter-right {
        width: 6px;
    }
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .output-stats {
        justify-content: center;
    }
    .button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    .footer-links {
        gap: 0.75rem;
        font-size: 0.75rem;
    }
}
/* ---------- Help / How to use section ---------- */
.help-section {
    border-top: 1px solid var(--stroke-default);
    background: var(--surface);
    margin: 0 0 0 0;
}

.help-section-title {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--on-surface-de-emphasis);
}

.help-body {
    padding: 0 1rem 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.help-intro {
    font-size: 0.82rem;
    color: var(--on-surface-de-emphasis);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.help-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.help-card {
    flex: 1 1 280px;
    background: var(--surface-container);
    border-radius: var(--radius-m);
    padding: 0.85rem 1rem;
    border: 1px solid var(--stroke-default);
}

.help-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--on-surface-default);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.help-badge {
    font-size: 0.68rem;
    font-weight: 500;
    background: var(--primary-container);
    color: var(--primary);
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
}

.help-card p {
    font-size: 0.78rem;
    color: var(--on-surface-de-emphasis);
    line-height: 1.55;
    margin-bottom: 0.6rem;
}

.help-example {
    background: var(--surface);
    border: 1px solid var(--stroke-default);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.75rem;
    color: var(--on-surface-default);
    line-height: 1.6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.help-example code {
    font-family: var(--ff-mono);
    font-size: 0.73rem;
    background: none;
}

.help-ex-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--outline);
    width: 100%;
}

.help-ex-arrow {
    font-weight: bold;
    color: var(--primary);
    font-size: 1rem;
    margin: 0 0.25rem;
}

.help-tip {
    font-size: 0.78rem;
    color: var(--on-surface-de-emphasis);
    background: var(--surface-container);
    border-left: 3px solid var(--primary);
    padding: 0.6rem 0.9rem;
    border-radius: 0 0.5rem 0.5rem 0;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .help-grid {
        flex-direction: column;
    }
    .help-card {
        flex: 1 1 100%;
    }
    .help-body {
        padding: 0 0.75rem 1rem;
    }
}
