:root {
    --bg: #f3f4f6;
    --bg-panel: #ffffff;
    --bg-panel-secondary: #f9fafb;
    --accent: #3c8fd6;
    --accent-strong: #1273c8;
    --muted: #6b7280;
    --text: #111827;
    --border: rgba(15, 23, 42, 0.08);
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    font-size: 16px;
}

@media (max-width: 768px) {
    :root {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }
}


.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1.25rem clamp(1rem, 4vw, 3rem);
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.04);
}

.brand h1 {
    margin: 0;
    font-size: clamp(1.35rem, 4vw, 2.3rem);
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: var(--text);
}

.tagline {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    line-height: 1.4;
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.25rem;
    padding: clamp(0.75rem, 3vw, 2.5rem);
    padding-top: 1.5rem;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    overflow-x: hidden;
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
}


.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: clamp(1rem, 2.4vw, 1.6rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
}

.panel-secondary {
    background: var(--bg-panel-secondary);
    border: 1px solid rgba(60, 143, 214, 0.18);
}

.panel-nested {
    background: #f9fafb;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 0.9rem;
}

.panel h2,
.panel h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}

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

.section-copy {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}


.grid {
    display: grid;
    gap: 0.85rem;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
}

.grid.three {
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
}

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


.mode-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.75rem;
}

.mode-panel.is-hidden {
    display: none;
}


.field,
.field-switch {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field span {
    font-size: 0.92rem;
    color: var(--text);
}

.field-switch span:first-child {
    font-size: 0.92rem;
    color: var(--text);
}


.field-switch input[type="checkbox"] {
    width: 44px;
    height: 22px;
    border-radius: 11px;
    appearance: none;
    background: rgba(148, 163, 184, 0.4);
    position: relative;
    cursor: pointer;
    transition: background 0.25s ease;
}

.field-switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
    transition: transform 0.25s ease;
}

.field-switch input[type="checkbox"]:checked {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
}

.field-switch input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}

.field-switch input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-switch.error-switch span:first-child {
    color: var(--danger);
}

.field-switch.error-switch input[type="checkbox"] {
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}


.field input[type="file"] {
    padding: 0.45rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    color: var(--text);
    font-size: 0.92rem;
    cursor: pointer;
}

.field input[type="file"]:hover {
    border-color: rgba(148, 163, 184, 0.6);
}

.field input[type="file"]::file-selector-button {
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(60, 143, 214, 0.08);
    color: var(--accent-strong);
    font-size: 0.82rem;
    cursor: pointer;
    margin-right: 0.7rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.field input[type="file"]::file-selector-button:hover {
    background: rgba(60, 143, 214, 0.16);
    border-color: rgba(60, 143, 214, 0.4);
}


.field input[type="text"],
.field input[type="number"],
.field textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 0.7rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #ffffff;
    color: var(--text);
    font-size: 0.92rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input[type="text"]::placeholder,
.field input[type="number"]::placeholder,
.field textarea::placeholder {
    color: #9ca3af;
}

.field.error input[type="text"],
.field.error input[type="number"],
.field.error textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.22);
}

.field.error span:first-child::after {
    content: "*";
    color: var(--danger);
    margin-left: 0.25rem;
}

.field input[type="text"]:focus,
.field input[type="number"]:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 2px rgba(18, 115, 200, 0.22);
    background: #ffffff;
}

.field textarea {
    resize: vertical;
    min-height: 110px;
}

.field-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}


.toggle-option {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
}

.toggle-option input {
    appearance: none;
    width: 0;
    height: 0;
    margin: 0;
}

.toggle-option span {
    font-size: 0.9rem;
    color: var(--text);
}

.toggle-option input:checked+span,
.toggle-option input:checked~span {
    color: var(--accent-strong);
    font-weight: 600;
}

.toggle-option:has(input:checked) {
    border-color: var(--accent-strong);
    background: rgba(60, 143, 214, 0.08);
    box-shadow: 0 0 0 1px rgba(60, 143, 214, 0.16);
}

.mode-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    border-radius: 999px;
    gap: 8px;
    max-width: 100%;
}

.toggle-option {
    flex: 1;
    position: relative;
    text-align: center;
}

.toggle-option input {
    display: none;
}

.toggle-option span {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
}


@media (max-width: 480px) {
    .mode-toggle {
        padding: 6px;
    }

    .toggle-option span {
        font-size: 13px;
        padding: 8px 0;
    }
}



.custom-charsets summary {
    cursor: pointer;
    color: var(--accent-strong);
    font-weight: 600;
    user-select: none;
}

.custom-charsets summary:hover {
    color: #0b63b5;
}

.custom-charsets[open],
.mask-options[open],
.wordlist-options[open],
.advanced-settings[open],
.mask-reference[open] {
    border: 1px solid rgba(60, 143, 214, 0.25);
    border-radius: 1rem;
    padding: 0.9rem;
    margin-top: 0.75rem;
    background: rgba(60, 143, 214, 0.04);
}

.mask-options summary,
.wordlist-options summary,
.advanced-settings summary,
.mask-reference summary {
    cursor: pointer;
    color: var(--accent-strong);
    font-weight: 600;
    user-select: none;
    padding: 0.45rem;
    margin: -0.45rem;
}

.mask-options summary:hover,
.wordlist-options summary:hover,
.advanced-settings summary:hover,
.mask-reference summary:hover {
    color: #0b63b5;
}

.mask-options[open] summary,
.wordlist-options[open] summary,
.advanced-settings[open] summary,
.mask-reference[open] summary {
    margin-bottom: 0.75rem;
}

.mask-reference,
.rules-reference {
    background: #f9fafb;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 1rem;
    padding: 0;
    margin: 0.9rem 0;
}

.mask-reference summary,
.rules-reference summary {
    padding: 0.85rem 1.15rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-strong);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    user-select: none;
    transition: background 0.2s ease;
}

.mask-reference summary:hover,
.rules-reference summary:hover {
    background: rgba(60, 143, 214, 0.06);
}

.docs-content {
    padding: 0 1.15rem 1.15rem 1.15rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.docs-intro {
    margin: 0 0 1rem 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
}


.placeholder-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.placeholder-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.8rem 0.95rem;
    background: #f9fafb;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.placeholder-item:hover {
    background: #ffffff;
    border-color: rgba(60, 143, 214, 0.4);
    transform: translateX(3px);
}

.placeholder-item code {
    font-family: "Consolas", "Monaco", monospace;
    background: rgba(60, 143, 214, 0.08);
    color: var(--accent-strong);
    padding: 0.2rem 0.45rem;
    border-radius: 0.35rem;
    font-size: 0.86rem;
    font-weight: 600;
    width: fit-content;
}

.placeholder-desc {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
}

.placeholder-example {
    color: var(--muted);
    font-size: 0.83rem;
    font-style: italic;
    padding-left: 0.9rem;
    border-left: 2px solid rgba(60, 143, 214, 0.3);
}

.placeholder-mappings {
    color: var(--muted);
    font-size: 0.78rem;
    padding-left: 0.9rem;
    margin-top: 0.2rem;
}


.rules-categories {
    display: grid;
    gap: 1.1rem;
    margin-bottom: 1.1rem;
}

.rule-category {
    background: #f9fafb;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 0.75rem;
    padding: 0.4rem 0.4rem 0.8rem;
}

.rule-category details {
    border-radius: 0.6rem;
}

.rule-category details summary {
    list-style: none;
    cursor: pointer;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-strong);
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.rule-category details summary::marker {
    display: none;
}

.rule-category details summary::after {
    content: "▾";
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: 0.4rem;
}

.rule-category details[open] summary::after {
    transform: rotate(180deg);
}

.rule-category details[open] summary {
    border-bottom: 1px solid rgba(60, 143, 214, 0.25);
    margin-bottom: 0.45rem;
}

.rule-doc-item {
    padding: 0.7rem;
    margin-bottom: 0.7rem;
    background: #ffffff;
    border-radius: 0.5rem;
    border-left: 3px solid var(--accent-strong);
}

.rule-doc-item:last-child {
    margin-bottom: 0;
}

.rule-doc-item strong {
    color: var(--text);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.3rem;
}

.rule-example {
    font-family: "Consolas", "Monaco", monospace;
    color: var(--accent-strong);
    font-size: 0.84rem;
    padding: 0.45rem 0.7rem;
    background: rgba(60, 143, 214, 0.08);
    border-radius: 0.35rem;
    margin-top: 0.45rem;
    border: 1px solid rgba(60, 143, 214, 0.25);
}


.docs-tip {
    background: rgba(234, 179, 8, 0.06);
    border: 1px solid rgba(234, 179, 8, 0.45);
    border-radius: 0.75rem;
    padding: 0.9rem;
    margin-top: 1rem;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.6;
}

.docs-tip strong {
    color: var(--warning);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.docs-tip code {
    background: rgba(234, 179, 8, 0.16);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 0.82rem;
}


.rule-card {
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 1rem;
    padding: 0.9rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.rule-card:hover:not(.is-disabled) {
    border-color: rgba(60, 143, 214, 0.5);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.rule-card.active {
    border-color: var(--accent-strong);
    background: rgba(60, 143, 214, 0.04);
    box-shadow: 0 10px 26px rgba(60, 143, 214, 0.25);
    transform: translateY(-1px);
}

.rule-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.7rem;
}

.rule-card h3 {
    margin: 0;
    font-size: 0.96rem;
    color: var(--text);
}

.rule-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.4;
}

.rule-card button {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
}

.rule-card.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.rule-card.is-disabled h3,
.rule-card.is-disabled p {
    color: var(--muted);
}

.rule-card.is-disabled button {
    opacity: 0.6;
}


.primary,
.secondary,
.ghost-button {
    border-radius: 999px;
    padding: 0.6rem 1.3rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(60, 143, 214, 0.3);
}

.primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary {
    background: rgba(60, 143, 214, 0.08);
    color: var(--accent-strong);
    border: 1px solid rgba(60, 143, 214, 0.35);
}

.secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ghost-button {
    background: transparent;
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.5);
}

.ghost-button:hover:not(:disabled),
.secondary:hover:not(:disabled),
.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.ghost-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.action-bar.secondary-actions {
    margin-top: 0.4rem;
}


.summary {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.summary-chip {
    background: rgba(60, 143, 214, 0.07);
    color: var(--accent-strong);
    border: 1px solid rgba(60, 143, 214, 0.35);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}


.progress-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.progress-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.progress-bar {
    width: 100%;
    height: 9px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.3);
    overflow: hidden;
}

.progress-indicator {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transition: width 0.3s ease;
}


.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    margin: 0;
}

.metrics div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.metrics dt {
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--muted);
}

.metrics dd {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}


.log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 220px;
    overflow-y: auto;
}

.log li {
    font-size: 0.83rem;
    color: var(--muted);
    padding: 0.45rem 0.7rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #f9fafb;
}

.log li strong {
    color: var(--text);
}


#rule-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}


@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .panel-secondary {
        order: 10;
    }
}

@media (max-width: 900px) {
    #rule-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem 1rem;
        align-items: center;
        flex-direction: column;
        gap: 0.4rem;
        text-align: center;
    }

    .panel {
        padding: 1.1rem;
        border-radius: 1rem;
    }

    .app-shell {
        gap: 1rem;
        padding: 0.9rem;
        padding-top: 1.2rem;
    }

    .grid.two,
    .grid.three {
        gap: 0.75rem;
    }

    .rule-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .metrics {
        gap: 0.45rem;
    }

    .action-bar {
        flex-direction: column;
        gap: 0.55rem;
    }

    .primary,
    .secondary,
    .ghost-button {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1.4rem;
        font-size: 0.9rem;
    }

    textarea {
        font-size: 0.88rem;
    }

    .log {
        max-height: 180px;
        -webkit-overflow-scrolling: touch;
    }

    body {
        overflow-x: hidden;
    }

    .field-help,
    .section-copy,
    .docs-intro {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .mask-reference summary,
    .rules-reference summary {
        padding: 0.8rem 0.95rem;
        font-size: 0.9rem;
    }

    .docs-content {
        padding: 0 0.95rem 0.95rem 0.95rem;
    }

    .placeholder-item {
        padding: 0.7rem 0.8rem;
    }

    .rule-category {
        padding: 0.4rem 0.4rem 0.7rem;
    }

    .placeholder-item:hover {
        transform: none;
    }

    .rule-card header {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .app-shell {
        padding: 0.7rem;
        padding-top: 1rem;
        gap: 0.9rem;
    }

    .panel {
        padding: 0.95rem;
        gap: 0.9rem;
    }

    .panel h2 {
        font-size: 1rem;
    }

    .panel h3 {
        font-size: 0.93rem;
    }

    .field span,
    .field-help {
        font-size: 0.85rem;
    }

    input[type="text"],
    input[type="number"],
    textarea,
    select {
        font-size: 0.88rem;
        padding: 0.55rem 0.8rem;
    }

    .summary-chip {
        font-size: 0.78rem;
        padding: 0.3rem 0.65rem;
    }

    .log li {
        font-size: 0.78rem;
        padding: 0.4rem 0.6rem;
    }

    .metrics dt {
        font-size: 0.72rem;
    }

    .metrics dd {
        font-size: 0.88rem;
    }

    details summary {
        font-size: 0.88rem;
        padding: 0.7rem 0.8rem;
    }

    .grid.two.nested {
        grid-template-columns: 1fr;
    }

    button,
    input[type="checkbox"],
    input[type="radio"],
    summary {
        min-height: 40px;
        min-width: 40px;
    }

    .mask-reference,
    .rules-reference {
        margin: 0.6rem 0;
    }

    .placeholder-item code {
        font-size: 0.8rem;
    }

    .placeholder-desc {
        font-size: 0.88rem;
    }

    .placeholder-example {
        font-size: 0.78rem;
        padding-left: 0.7rem;
    }
}


@media (max-width: 768px) and (orientation: landscape) {
    .app-shell {
        grid-template-columns: 1fr 1fr;
        gap: 0.9rem;
    }

    .panel-secondary {
        order: initial;
    }
}


@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .progress-bar {
        border: 0.5px solid rgba(148, 163, 184, 0.15);
    }
}