:root {
    color-scheme: dark;
    --bg: #070b11;
    --panel: rgba(15, 22, 31, .88);
    --panel-strong: #111a25;
    --text: #f4f7fb;
    --muted: #8995a4;
    --cyan: #69e3ee;
    --cyan-dark: #123f49;
    --green: #76e6aa;
    --red: #ff8b8b;
    --border: rgba(255, 255, 255, .09);
    --radius: 18px;
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--text); background: radial-gradient(circle at 70% 0, #102633 0, transparent 30%), var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(100px); pointer-events: none; opacity: .14; }
.ambient-one { width: 34rem; height: 34rem; top: -20rem; right: -12rem; background: #27cada; }
.ambient-two { width: 24rem; height: 24rem; top: 45%; left: -18rem; background: #3764e6; }

.tool-header { height: 5.4rem; max-width: 1380px; margin: auto; padding: 0 clamp(1.25rem, 4vw, 4rem); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: .7rem; letter-spacing: .08em; }
.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: .28rem; color: var(--cyan); font-size: .5rem; letter-spacing: .23em; }
.brand-mark { height: 24px; display: flex; align-items: end; gap: 3px; }
.brand-mark i { width: 4px; display: block; border-radius: 4px; background: var(--cyan); box-shadow: 0 0 14px rgba(105,227,238,.6); }
.brand-mark i:nth-child(1) { height: 11px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 16px; }
.brand-mark i:nth-child(4) { height: 8px; }
.privacy-badge { display: inline-flex; align-items: center; gap: .5rem; color: #aeb8c5; font-size: .72rem; letter-spacing: .04em; }
.privacy-badge svg { width: 1rem; color: var(--green); }

.tool-shell { width: min(1180px, calc(100% - 2rem)); margin: auto; padding-bottom: 6rem; }
.hero { padding: clamp(4.5rem, 9vw, 7rem) 0 clamp(3rem, 6vw, 5rem); }
.eyebrow { margin: 0 0 1.4rem; color: var(--cyan); font-size: .65rem; font-weight: 800; letter-spacing: .28em; }
.hero h1 { max-width: 850px; margin: 0; font-size: clamp(3rem, 7vw, 6.3rem); line-height: .92; letter-spacing: -.06em; }
.hero h1 em { color: transparent; font-style: normal; -webkit-text-stroke: 1px rgba(255,255,255,.42); }
.hero > p:last-child { max-width: 680px; margin: 1.8rem 0 0; color: var(--muted); font-size: clamp(.95rem, 1.6vw, 1.15rem); line-height: 1.7; }

.workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; align-items: start; }
.step-card { min-width: 0; padding: clamp(1.25rem, 2.5vw, 2rem); border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(18,27,39,.92), rgba(12,18,27,.9)); box-shadow: 0 20px 60px rgba(0,0,0,.18); backdrop-filter: blur(18px); }
.metadata-card, .result-card { grid-column: 1 / -1; }
.step-heading { display: flex; align-items: start; gap: 1rem; margin-bottom: 1.6rem; }
.step-heading h2 { margin: .05rem 0 .3rem; font-size: 1.08rem; letter-spacing: -.025em; }
.step-heading p { margin: 0; color: var(--muted); font-size: .77rem; }
.step-heading code { padding: .08rem .3rem; border-radius: 4px; color: #b8c2cf; background: rgba(255,255,255,.06); }
.step-number { width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(105,227,238,.25); border-radius: 50%; color: var(--cyan); background: rgba(105,227,238,.06); font-size: .62rem; font-weight: 800; }

.drop-zone { min-height: 245px; padding: 2rem; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed rgba(105,227,238,.28); border-radius: 13px; text-align: center; background: rgba(6,11,17,.38); cursor: pointer; transition: border-color .2s, background .2s, transform .2s; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--cyan); background: rgba(105,227,238,.055); transform: translateY(-2px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { width: 3.5rem; height: 3.5rem; display: grid; place-items: center; margin-bottom: 1rem; border-radius: 50%; color: var(--cyan); background: var(--cyan-dark); }
.drop-zone strong { font-size: .95rem; }
.drop-zone > span:not(.upload-icon) { margin-top: .35rem; color: var(--muted); font-size: .8rem; }
.drop-zone small { margin-top: 1.25rem; color: #657282; font-size: .68rem; }
.file-summary { min-height: 245px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; padding: 1.5rem; border: 1px solid rgba(118,230,170,.22); border-radius: 13px; background: rgba(118,230,170,.035); }
.file-type { width: 3.2rem; height: 3.2rem; display: grid; place-items: center; border-radius: 9px; color: #07150f; background: var(--green); font-size: .65rem; font-weight: 900; }
.file-summary div { min-width: 0; display: grid; gap: .3rem; }
.file-summary strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-summary small { color: var(--muted); }
.file-summary button, .reset-time, .code-toolbar button { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 7px; color: #b9c2ce; background: rgba(255,255,255,.035); cursor: pointer; }

.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: .5rem; }
.field-wide { grid-column: span 2; }
.field > span { color: #aeb8c4; font-size: .72rem; font-weight: 650; }
.field > span b { color: var(--cyan); }
.field > span small { color: #626f7f; font-weight: 400; }
.field input, .time-input { width: 100%; height: 2.9rem; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: rgba(5,9,14,.46); transition: border-color .2s, background .2s; }
.field input { padding: 0 .85rem; }
.field input:focus, .time-input:focus-within { border-color: rgba(105,227,238,.55); outline: 0; background: rgba(5,9,14,.7); }
.field input::placeholder { color: #505c69; }
.publish-field { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); cursor: pointer; }
.publish-field > span { display: grid; gap: .25rem; }
.publish-field strong { font-size: .82rem; }
.publish-field small { color: var(--muted); font-size: .7rem; }
.publish-field input { position: absolute; opacity: 0; }
.publish-field i { width: 2.6rem; height: 1.45rem; padding: 3px; flex: 0 0 auto; border-radius: 999px; background: #343e4a; transition: background .2s; }
.publish-field i::after { content: ""; display: block; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: #fff; transition: transform .2s; }
.publish-field input:checked + i { background: var(--cyan); }
.publish-field input:checked + i::after { transform: translateX(1.15rem); background: #071318; }
.guide-format-field { margin-top: 0; }

.timing-control { display: grid; grid-template-columns: auto auto minmax(110px, 1fr) auto auto; gap: .45rem; align-items: end; }
.time-nudge { height: 2.9rem; padding: 0 .7rem; border: 1px solid var(--border); border-radius: 8px; color: #aeb8c4; background: rgba(255,255,255,.035); cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.time-nudge:hover { color: var(--cyan); border-color: rgba(105,227,238,.35); background: rgba(105,227,238,.06); }
.timing-control label { display: grid; gap: .45rem; color: #aeb8c4; font-size: .72rem; }
.time-input { display: flex; align-items: center; }
.time-input input { min-width: 0; width: 100%; height: 100%; padding: 0 .65rem; border: 0; outline: 0; color: var(--text); background: transparent; text-align: center; font-weight: 750; }
.time-input b { padding-right: .65rem; color: var(--muted); font-size: .72rem; }
.timing-example { min-height: 1.1rem; margin: 1.15rem 0 .8rem; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.reset-time { font-size: .7rem; }
.part-options { margin-top: 1.25rem; padding-top: 1.15rem; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; border-top: 1px solid var(--border); }
.part-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.part-switch > span { display: grid; gap: .25rem; }
.part-switch strong { font-size: .78rem; }
.part-switch small { color: var(--muted); font-size: .68rem; font-weight: 400; }
.part-switch input { position: absolute; opacity: 0; }
.part-switch i { width: 2.6rem; height: 1.45rem; padding: 3px; flex: 0 0 auto; border-radius: 999px; background: #343e4a; transition: background .2s; }
.part-switch i::after { content: ""; display: block; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: #fff; transition: transform .2s; }
.part-switch input:checked + i { background: var(--cyan); }
.part-switch input:checked + i::after { transform: translateX(1.15rem); background: #071318; }
.gap-field { display: grid; gap: .4rem; color: #aeb8c4; font-size: .68rem; }
.gap-field > span:last-child { height: 2.5rem; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: rgba(5,9,14,.46); }
.gap-field input { width: 4rem; height: 100%; padding: 0 .35rem 0 .7rem; border: 0; outline: 0; color: var(--text); background: transparent; font-weight: 750; }
.gap-field b { padding-right: .7rem; color: var(--muted); font-size: .63rem; font-weight: 500; }
.gap-field input:disabled { opacity: .35; }

.result-heading { align-items: center; }
.result-heading > div { flex: 1; }
.validation-badge { padding: .45rem .65rem; border: 1px solid; border-radius: 999px; font-size: .62rem; font-weight: 750; letter-spacing: .04em; }
.validation-badge.is-waiting { color: var(--muted); border-color: var(--border); }
.validation-badge.is-valid { color: var(--green); border-color: rgba(118,230,170,.25); background: rgba(118,230,170,.06); }
.validation-badge.is-invalid { color: var(--red); border-color: rgba(255,139,139,.25); background: rgba(255,139,139,.06); }
.validation-badge.is-dirty { color: #ffd285; border-color: rgba(255,210,133,.25); background: rgba(255,210,133,.06); }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stats article { padding: 1rem; display: grid; gap: .25rem; border: 1px solid var(--border); border-radius: 10px; background: rgba(4,8,13,.3); }
.stats strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; }
.message { padding: .8rem 1rem; border: 1px solid rgba(255,139,139,.22); border-radius: 8px; color: #ffaaaa; background: rgba(255,91,91,.055); font-size: .75rem; line-height: 1.6; }
.message ul { margin: 0; padding-left: 1.1rem; }
.validation-errors li + li { margin-top: .28rem; }
.error-link { padding: 0; border: 0; color: inherit; background: transparent; text-align: left; line-height: inherit; cursor: pointer; }
.error-link:hover { color: #ffd0d0; text-decoration: underline; text-underline-offset: .16rem; }
.error-link::after { content: " Ir al JSON"; margin-left: .35rem; color: var(--cyan); font-size: .65rem; white-space: nowrap; }
.error-message { margin-top: 1rem; }
.preview-panel { margin-top: 1rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: rgba(4,8,13,.36); }
.preview-panel summary { height: 3.2rem; padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; color: #b6c0cb; cursor: pointer; list-style: none; font-size: .78rem; }
.preview-panel summary::-webkit-details-marker { display: none; }
.preview-panel[open] summary svg { transform: rotate(180deg); }
.code-toolbar { padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--muted); font-size: .68rem; }
.code-toolbar > span > b { color: #aab5c2; font-weight: 650; }
.code-toolbar > span > b.is-dirty { color: #ffd285; }
.code-toolbar > span > b.is-saved { color: var(--green); }
.code-actions { display: flex; align-items: center; gap: .45rem; }
.code-toolbar button { padding: .38rem .65rem; font-size: .68rem; }
.code-toolbar .save-json { color: #071318; border-color: transparent; background: var(--cyan); font-weight: 750; }
.code-toolbar button:disabled { opacity: .35; cursor: not-allowed; }
.preview-panel textarea { display: block; width: 100%; min-height: 430px; max-height: 70vh; margin: 0; padding: 1rem; resize: vertical; overflow: auto; border: 0; outline: 0; color: #b9cad5; background: transparent; font: .72rem/1.6 "Cascadia Code", Consolas, monospace; tab-size: 2; white-space: pre; }
.preview-panel textarea:focus { background: rgba(2,6,10,.38); box-shadow: inset 0 0 0 1px rgba(105,227,238,.22); }
.preview-panel textarea[readonly] { color: #778592; cursor: default; }
.editor-help { margin: 0; padding: .65rem 1rem; border-top: 1px solid var(--border); color: #687584; font-size: .65rem; line-height: 1.5; }
.export-button { width: 100%; min-height: 4.2rem; margin-top: 1rem; padding: .8rem 1.2rem; border: 0; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: .8rem; color: #061216; background: var(--cyan); cursor: pointer; box-shadow: 0 12px 35px rgba(105,227,238,.16); transition: transform .2s, filter .2s, opacity .2s; }
.export-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.export-button:disabled { opacity: .28; cursor: not-allowed; box-shadow: none; }
.export-button span { display: grid; gap: .18rem; text-align: left; }
.export-button strong { font-size: .83rem; }
.export-button small { font-size: .63rem; opacity: .72; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 1.5rem; padding: .7rem 1rem; border: 1px solid var(--border); border-radius: 8px; color: #dce4ec; background: rgba(10,16,24,.94); box-shadow: 0 12px 40px rgba(0,0,0,.35); transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: .75rem; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
    .workspace { grid-template-columns: 1fr; }
    .metadata-card, .result-card { grid-column: auto; }
    .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-wide { grid-column: span 2; }
}

@media (max-width: 560px) {
    .tool-header { padding: 0 1rem; }
    .privacy-badge { font-size: 0; }
    .privacy-badge svg { width: 1.2rem; }
    .tool-shell { width: min(100% - 1rem, 1180px); }
    .hero { padding-left: .5rem; padding-right: .5rem; }
    .hero h1 { font-size: clamp(2.8rem, 16vw, 4.5rem); }
    .step-card { border-radius: 14px; }
    .field-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .timing-control { grid-template-columns: repeat(4, 1fr); }
    .timing-control label { grid-column: 1 / -1; grid-row: 1; }
    .time-nudge { padding: 0 .3rem; }
    .part-options { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .result-heading { flex-wrap: wrap; }
    .validation-badge { margin-left: 3rem; }
    .file-summary { grid-template-columns: auto 1fr; }
    .file-summary button { grid-column: 1 / -1; }
    .code-toolbar { align-items: flex-start; flex-direction: column; gap: .65rem; }
    .code-actions { width: 100%; flex-wrap: wrap; }
}

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