:root {
    --json-ink: #0f172a;
    --json-muted: #64748b;
    --json-line: rgba(30, 41, 59, .12);
    --json-blue: #2563eb;
    --json-violet: #7c3aed;
    --json-green: #16a34a;
}

body.json-csv-page {
    min-height: 100vh;
    font-family: Inter, "Noto Sans KR", system-ui, sans-serif;
    color: var(--json-ink);
    background:
        radial-gradient(circle at 5% 16%, rgba(34, 197, 94, .12), transparent 26rem),
        radial-gradient(circle at 95% 8%, rgba(124, 58, 237, .16), transparent 28rem),
        linear-gradient(180deg, #f8fbff 0%, #ffffff 48%, #fffaf0 100%);
}

.json-header .logo {
    text-decoration: none;
    white-space: nowrap;
}

.json-header .top-nav {
    gap: clamp(.7rem, 1.2vw, 1.1rem);
    flex-wrap: nowrap;
}

.json-header .tools-dropdown.mega-tools {
    right: 0;
    left: auto;
    width: min(980px, calc(100vw - 2rem));
    grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.json-header .tools-dropdown {
    max-height: min(72vh, 620px);
    overflow: auto;
}

.json-header .ec-tool-search {
    min-width: min(12rem, 16vw);
}

.json-main {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.4rem 0 4rem;
}

.json-breadcrumb {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--json-muted);
    font-size: .9rem;
    font-weight: 800;
}

.json-breadcrumb a {
    color: inherit;
    text-decoration: none;
}

.json-hero {
    text-align: center;
    padding: 2.3rem 1rem 2.7rem;
}

.json-flow-icon {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.1rem;
    color: var(--json-blue);
}

.json-flow-icon span {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 14px 32px rgba(37, 99, 235, .12);
}

.json-hero h1 {
    margin: 0;
    font-size: clamp(2.15rem, 5.3vw, 4.1rem);
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0;
}

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

.json-hero p {
    max-width: 720px;
    margin: 1rem auto 0;
    color: #475569;
    font-size: 1.05rem;
    line-height: 1.65;
}

.json-benefits {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
}

.json-benefits span {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .8rem;
    border: 1px solid rgba(37, 99, 235, .09);
    border-radius: 999px;
    color: #31559d;
    background: rgba(255, 255, 255, .72);
    font-weight: 850;
    font-size: .86rem;
}

.json-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
}

.json-input-card,
.json-output-card,
.json-info-grid article {
    border: 1px solid var(--json-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 26px 70px rgba(37, 99, 235, .08);
}

.json-input-card,
.json-output-card {
    min-width: 0;
    padding: 1.25rem;
}

.json-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.json-toolbar p {
    margin: 0 0 .25rem;
    color: var(--json-blue);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.json-toolbar h2 {
    margin: 0;
    font-size: 1.1rem;
}

.json-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: flex-end;
}

.json-toolbar-actions button,
.json-file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 2.5rem;
    border: 1px solid var(--json-line);
    border-radius: 10px;
    padding: .55rem .75rem;
    color: #334155;
    background: white;
    font: inherit;
    font-weight: 850;
    cursor: pointer;
}

.json-toolbar-actions button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

#jsonInput,
#csvOutput {
    width: 100%;
    border: 1px solid rgba(30, 41, 59, .14);
    border-radius: 14px;
    padding: 1rem;
    color: #0f172a;
    background: rgba(248, 250, 252, .82);
    font: 700 .92rem/1.6 Consolas, "Courier New", monospace;
    outline: none;
    resize: vertical;
}

#jsonInput {
    min-height: 360px;
}

#csvOutput {
    min-height: 150px;
    margin-top: 1rem;
}

#jsonInput:focus,
#csvOutput:focus {
    border-color: rgba(37, 99, 235, .5);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}

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

.json-options label {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 2.8rem;
    border: 1px solid rgba(30, 41, 59, .1);
    border-radius: 12px;
    padding: .55rem .75rem;
    color: #334155;
    background: rgba(255, 255, 255, .78);
    font-weight: 850;
}

.json-options select {
    min-width: 0;
    border: 0;
    background: transparent;
    color: #0f172a;
    font: inherit;
    font-weight: 850;
    outline: none;
}

.json-convert-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    width: 100%;
    min-height: 3.35rem;
    border: 0;
    border-radius: 12px;
    color: white;
    background: linear-gradient(135deg, var(--json-blue), var(--json-violet));
    box-shadow: 0 18px 34px rgba(37, 99, 235, .2);
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.json-status {
    min-height: 1.5rem;
    margin: .85rem 0 0;
    color: var(--json-muted);
    font-weight: 800;
}

.json-status.success {
    color: var(--json-green);
}

.json-status.error {
    color: #dc2626;
}

.csv-preview-shell {
    position: relative;
    overflow: auto;
    min-height: 360px;
    max-height: 360px;
    border: 1px solid rgba(30, 41, 59, .12);
    border-radius: 14px;
    background: white;
}

#csvPreviewTable {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}

#csvPreviewTable th,
#csvPreviewTable td {
    max-width: 220px;
    padding: .72rem .8rem;
    border-bottom: 1px solid rgba(30, 41, 59, .08);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#csvPreviewTable th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #1e3a8a;
    background: #eff6ff;
    font-weight: 900;
}

.csv-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: .45rem;
    color: var(--json-muted);
    text-align: center;
}

.csv-empty i {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 18px;
    color: var(--json-blue);
    background: rgba(37, 99, 235, .1);
    font-size: 1.3rem;
}

.csv-empty[hidden] {
    display: none;
}

.json-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.json-info-grid article {
    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: .85rem;
    align-items: center;
    padding: 1.1rem;
}

.json-info-grid i {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: 16px;
    color: var(--json-blue);
    background: rgba(37, 99, 235, .1);
}

.json-info-grid strong,
.json-info-grid span {
    grid-column: 2;
}

.json-info-grid span {
    color: var(--json-muted);
    font-size: .9rem;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .json-header .top-nav {
        flex-wrap: wrap;
        justify-content: flex-start !important;
    }

    .json-header .ec-tool-search {
        order: 20;
        width: min(100%, 18rem);
    }

    .json-workspace,
    .json-info-grid,
    .json-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .json-main {
        width: min(100% - 1rem, 1180px);
    }

    .json-hero {
        padding: 1.7rem .35rem 2rem;
    }

    .json-input-card,
    .json-output-card {
        padding: 1rem;
    }

    .json-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .json-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
