/* JSON Formatter
-------------------------------------- */

.jfmt-page {
    --jfmt-accent: #6c5ce7;
    --jfmt-accent-90: #6c5ce7e6;
    --jfmt-border: var(--flex-gray-15, rgba(0, 0, 0, 0.08));
    --jfmt-surface: var(--solid-white, #fff);
    --jfmt-radius: var(--round-7, 7px);
    --jfmt-radius-sm: var(--round-3, 3px);
    --jfmt-shadow: 0 2px 12px var(--shadow-12, rgba(0, 0, 0, 0.12));
    --jfmt-transition: var(--effect, 0.25s ease);
    position: relative;
    padding: 36px 0 80px;
}

/* Hero
-------------------------------------- */

.jfmt-hero {
    max-width: 800px;
    margin: 0 auto;
    padding: 18px 0 24px;
    text-align: center;
}

.jfmt-title {
    margin-bottom: 12px;
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.jfmt-subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
    line-height: 1.65;
    color: var(--excerpt-color);
}

/* Tool Section
-------------------------------------- */

.jfmt-tool-section {
    margin-bottom: 28px;
}

.jfmt-tool-inner {
    border: 1px solid #ddd;
    border-radius: var(--jfmt-radius);
    background: var(--jfmt-surface);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03), 0 6px 24px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

/* Tabs
-------------------------------------- */

.jfmt-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    border-bottom: 1px solid var(--jfmt-border);
    background: #fafbfc;
}

.jfmt-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    font-family: var(--meta-family);
    font-size: 0.82rem;
    font-weight: var(--meta-b-fweight, 600);
    color: var(--body-fcolor, #666);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: var(--jfmt-transition);
    white-space: nowrap;
}

.jfmt-tab::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    border-radius: 2px 2px 0 0;
    transition: var(--jfmt-transition);
}

.jfmt-tab svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.jfmt-tab:hover {
    color: var(--headline-fcolor, #111);
}

.jfmt-tab:hover svg {
    opacity: 1;
}

.jfmt-tab-active {
    color: var(--jfmt-accent);
    font-weight: 700;
}

.jfmt-tab-active::after {
    background: var(--jfmt-accent);
}

.jfmt-tab-active svg {
    opacity: 1;
}

/* Tab Panels
-------------------------------------- */

.jfmt-tab-panel {
    display: none;
    padding: 28px 24px;
}

.jfmt-tab-panel-active {
    display: block;
}

/* Labels
-------------------------------------- */

.jfmt-label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--meta-family);
    font-size: var(--meta-fsize);
    font-weight: var(--meta-b-fweight, 600);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--body-fcolor);
}

/* Textareas
-------------------------------------- */

.jfmt-textarea-wrap {
    margin-bottom: 16px;
}

.jfmt-textarea-wrap:last-child {
    margin-bottom: 0;
}

.jfmt-textarea {
    display: block;
    width: 100%;
    padding: 14px 16px;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--headline-fcolor, #111);
    background: var(--jfmt-surface);
    border: 1px solid var(--jfmt-border);
    border-radius: var(--jfmt-radius);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.jfmt-textarea:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--jfmt-accent) 50%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jfmt-accent) 8%, transparent);
}

.jfmt-textarea-output {
    background: #f9f9fb;
    color: var(--headline-fcolor, #222);
    border-style: dashed;
}

.jfmt-textarea::placeholder {
    color: var(--body-fcolor, #999);
    opacity: 0.6;
}

.jfmt-textarea-hidden {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.jfmt-textarea-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 2px;
}

.jfmt-char-count {
    font-family: var(--meta-family);
    font-size: var(--meta-fsize, 0.75rem);
    font-weight: var(--meta-b-fweight, 600);
    color: var(--excerpt-color, #888);
    letter-spacing: 0.02em;
}

.jfmt-textarea-actions {
    display: flex;
    gap: 4px;
}

/* Output Pre (syntax highlighted)
-------------------------------------- */

.jfmt-output-wrap {
    position: relative;
    min-height: 200px;
    border: 1px dashed var(--jfmt-border);
    border-radius: var(--jfmt-radius);
    background: #f9f9fb;
    overflow: hidden;
}

.jfmt-output-pre {
    margin: 0;
    padding: 14px 16px;
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--headline-fcolor, #222);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.jfmt-output-pre:empty::before {
    content: "Formatted output will appear here...";
    color: var(--body-fcolor, #999);
    opacity: 0.6;
}

/* Syntax highlighting */
.jfmt-key {
    color: #6c5ce7;
}

.jfmt-string {
    color: #00b894;
}

.jfmt-number {
    color: #e17055;
}

.jfmt-boolean {
    color: #0984e3;
}

.jfmt-null {
    color: #b2bec3;
    font-style: italic;
}

.jfmt-bracket {
    color: #636e72;
}

/* Icon Buttons
-------------------------------------- */

.jfmt-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--body-fcolor, #666);
    border: 1px solid transparent;
    border-radius: var(--jfmt-radius-sm);
    background: transparent;
    cursor: pointer;
    transition: var(--jfmt-transition);
}

.jfmt-btn-icon svg {
    width: 16px;
    height: 16px;
}

.jfmt-btn-icon:hover {
    color: var(--jfmt-accent);
    background: color-mix(in srgb, var(--jfmt-accent) 8%, transparent);
    border-color: color-mix(in srgb, var(--jfmt-accent) 20%, transparent);
}

.jfmt-btn-icon-label {
    width: auto;
    gap: 5px;
    padding: 0 10px;
    height: 30px;
    border-color: var(--jfmt-border);
}

.jfmt-btn-icon-label svg {
    width: 14px;
    height: 14px;
}

.jfmt-btn-icon-label span {
    font-family: var(--meta-family);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Options
-------------------------------------- */

.jfmt-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    margin-bottom: 16px;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 1px solid var(--jfmt-border);
    border-radius: var(--jfmt-radius);
}

.jfmt-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--headline-fcolor, #333);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.jfmt-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--jfmt-accent);
    cursor: pointer;
}

.jfmt-live-toggle {
    margin-left: auto;
}

.jfmt-live-indicator {
    display: inline-block;
    padding: 2px 8px;
    font-family: var(--meta-family);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
    background: var(--jfmt-accent);
    border-radius: 10px;
    transition: var(--jfmt-transition);
}

.jfmt-live-indicator-off {
    background: var(--body-fcolor, #999);
}

/* Indent Toggle Group
-------------------------------------- */

.jfmt-indent-group {
    display: inline-flex;
    border: 1px solid var(--jfmt-border);
    border-radius: var(--jfmt-radius-sm);
    overflow: hidden;
}

.jfmt-indent-btn {
    padding: 5px 12px;
    font-family: var(--meta-family);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--body-fcolor, #666);
    background: var(--jfmt-surface);
    border: 0;
    border-right: 1px solid var(--jfmt-border);
    cursor: pointer;
    transition: var(--jfmt-transition);
    white-space: nowrap;
}

.jfmt-indent-btn:last-child {
    border-right: 0;
}

.jfmt-indent-btn:hover {
    color: var(--jfmt-accent);
    background: color-mix(in srgb, var(--jfmt-accent) 5%, transparent);
}

.jfmt-indent-active {
    color: #fff;
    background: var(--jfmt-accent);
}

.jfmt-indent-active:hover {
    color: #fff;
    background: var(--jfmt-accent-90);
}

/* Action Row
-------------------------------------- */

.jfmt-action-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

/* Buttons
-------------------------------------- */

.jfmt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--btn-family);
    font-size: var(--btn-fsize, 12px);
    font-weight: var(--btn-fweight, 700);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border: 1px solid transparent;
    border-radius: var(--jfmt-radius-sm);
    cursor: pointer;
    transition: var(--jfmt-transition);
    white-space: nowrap;
    line-height: 1;
}

.jfmt-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.jfmt-btn-primary {
    color: #fff;
    background: var(--jfmt-accent);
    border-color: var(--jfmt-accent);
}

.jfmt-btn-primary:hover {
    background: var(--jfmt-accent-90);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--jfmt-accent) 30%, transparent);
}

.jfmt-btn-secondary {
    color: var(--headline-fcolor, #333);
    background: var(--jfmt-surface);
    border-color: var(--jfmt-border);
}

.jfmt-btn-secondary:hover {
    border-color: var(--jfmt-accent);
    color: var(--jfmt-accent);
}

.jfmt-btn-small {
    padding: 6px 14px;
    font-size: 0.72rem;
    color: var(--headline-fcolor, #333);
    background: var(--jfmt-surface);
    border-color: var(--jfmt-border);
}

.jfmt-btn-small:hover {
    border-color: var(--jfmt-accent);
    color: var(--jfmt-accent);
}

.jfmt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Validation Status
-------------------------------------- */

.jfmt-validation {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--jfmt-radius);
    transition: var(--jfmt-transition);
}

.jfmt-validation-valid {
    color: #00b894;
    background: rgba(0, 184, 148, 0.06);
    border: 1px solid rgba(0, 184, 148, 0.2);
}

.jfmt-validation-invalid {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.06);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.jfmt-validation-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Error Display
-------------------------------------- */

.jfmt-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.06);
    border: 1px solid rgba(220, 53, 69, 0.2);
    border-radius: var(--jfmt-radius);
}

.jfmt-error svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Tree View
-------------------------------------- */

.jfmt-tree-empty {
    padding: 48px 32px;
    text-align: center;
    color: var(--excerpt-color, #888);
}

.jfmt-tree-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.jfmt-tree-empty p {
    margin: 0;
    font-size: 0.95rem;
}

.jfmt-tree-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.jfmt-tree-stats {
    margin-left: auto;
    font-family: var(--meta-family);
    font-size: var(--meta-fsize, 0.75rem);
    font-weight: var(--meta-b-fweight, 600);
    color: var(--excerpt-color, #888);
}

.jfmt-tree {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 600px;
    overflow-y: auto;
    padding: 4px 0;
}

.jfmt-tree ul {
    list-style: none;
    margin: 0;
    padding-left: 20px;
}

.jfmt-tree>ul {
    padding-left: 0;
}

.jfmt-tree li {
    position: relative;
}

.jfmt-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-right: 4px;
    font-size: 0.7rem;
    color: var(--body-fcolor, #666);
    border: 1px solid var(--jfmt-border);
    border-radius: 3px;
    background: var(--jfmt-surface);
    cursor: pointer;
    transition: var(--jfmt-transition);
    vertical-align: middle;
}

.jfmt-tree-toggle:hover {
    color: var(--jfmt-accent);
    border-color: var(--jfmt-accent);
}

.jfmt-tree-key {
    color: #6c5ce7;
    font-weight: 600;
}

.jfmt-tree-colon {
    color: #636e72;
    margin: 0 4px;
}

.jfmt-tree-string {
    color: #00b894;
}

.jfmt-tree-number {
    color: #e17055;
}

.jfmt-tree-boolean {
    color: #0984e3;
}

.jfmt-tree-null {
    color: #b2bec3;
    font-style: italic;
}

.jfmt-tree-count {
    font-family: var(--meta-family);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--excerpt-color, #888);
    margin-left: 6px;
}

.jfmt-tree-collapsed>ul {
    display: none;
}

/* SEO Content
-------------------------------------- */

.jfmt-seo-content {
    margin-top: 54px;
    padding-top: 36px;
    border-top: 1px solid var(--jfmt-border);
}

/* FAQ Section
-------------------------------------- */

.jfmt-faq {
    margin-top: 54px;
    padding-top: 36px;
    border-top: 1px solid var(--jfmt-border);
}

.jfmt-faq-inner {
    padding: 0;
}

.jfmt-faq-label {
    display: inline-block;
    margin-bottom: 6px;
    padding: 3px 12px;
    font-family: var(--meta-family);
    font-size: var(--meta-fsize);
    font-weight: var(--meta-b-fweight, 600);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--jfmt-accent);
    background: color-mix(in srgb, var(--jfmt-accent) 10%, transparent);
    border-radius: 20px;
}

.jfmt-faq-title {
    margin-bottom: 24px;
    font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.jfmt-faq-list {
    position: relative;
}

.jfmt-faq-item {
    border-bottom: 1px solid var(--jfmt-border);
}

.jfmt-faq-item:last-child {
    border-bottom: none;
}

.jfmt-faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 18px 0;
    text-align: left;
    color: inherit;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    gap: 20px;
    cursor: pointer;
}

.jfmt-faq-question:hover,
.jfmt-faq-question:focus {
    color: var(--jfmt-accent);
    background: transparent;
    box-shadow: none;
}

.jfmt-faq-question-text {
    font-family: var(--h4-family);
    font-size: clamp(1rem, 2vw, 1.125rem);
    font-weight: var(--h4-fweight, 700);
    line-height: 1.45;
}

.jfmt-faq-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: var(--jfmt-accent);
    border: 1px solid var(--jfmt-border);
    border-radius: 50%;
    background: color-mix(in srgb, var(--jfmt-accent) 8%, transparent);
    transition: var(--jfmt-transition);
}

.jfmt-faq-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.jfmt-faq-item.jfmt-faq-open .jfmt-faq-toggle svg {
    transform: rotate(180deg);
}

.jfmt-faq-answer {
    display: none;
    padding-bottom: 18px;
}

.jfmt-faq-item.jfmt-faq-open .jfmt-faq-answer {
    display: block;
}

.jfmt-faq-item:first-child .jfmt-faq-answer {
    display: block;
}

.jfmt-faq-item:first-child .jfmt-faq-toggle svg {
    transform: rotate(180deg);
}

.jfmt-faq-item:first-child:not(.jfmt-faq-open):not(.jfmt-faq-touched) .jfmt-faq-answer {
    display: block;
}

.jfmt-faq-item:first-child:not(.jfmt-faq-open).jfmt-faq-touched .jfmt-faq-answer {
    display: none;
}

.jfmt-faq-item:first-child:not(.jfmt-faq-open).jfmt-faq-touched .jfmt-faq-toggle svg {
    transform: rotate(0deg);
}

.jfmt-faq-answer-inner {
    max-width: 840px;
    color: var(--excerpt-color);
    line-height: 1.7;
    font-size: 0.95rem;
}

.jfmt-faq-answer-inner p {
    margin: 0;
}

/* Toast Notifications
-------------------------------------- */

.jfmt-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.jfmt-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--dark-accent, #191c20);
    border-radius: var(--jfmt-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    animation: jfmtToastIn 0.3s ease;
}

.jfmt-toast.jfmt-toast-out {
    animation: jfmtToastOut 0.25s ease forwards;
}

@keyframes jfmtToastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes jfmtToastOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Responsive
-------------------------------------- */

@media (max-width: 1024px) {
    .jfmt-page {
        padding-top: 28px;
    }
}

@media (max-width: 767px) {
    .jfmt-page {
        padding: 18px 0 56px;
    }

    .jfmt-hero {
        padding: 24px 0 20px;
    }

    .jfmt-tab-panel {
        padding: 16px;
    }

    .jfmt-tab {
        padding: 12px 16px;
        font-size: 0.78rem;
    }

    .jfmt-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
    }

    .jfmt-live-toggle {
        margin-left: 0;
    }

    .jfmt-action-row {
        flex-direction: column;
    }

    .jfmt-seo-content {
        margin-top: 42px;
    }

    .jfmt-faq {
        margin-top: 42px;
    }

    .jfmt-faq-question {
        gap: 14px;
    }

    .jfmt-toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .jfmt-tree-toolbar {
        flex-wrap: wrap;
    }
}