/* ============================================================
   demo.lumatic-labs.com — design system
   Overhauled after founder feedback ("UI looks extremely ugly").
   Principles: minimal single-column, typography-first, flat with
   soft shadows, brand palette (purple #6a48f5 ← logo gradient,
   green kept for success/semantic), system fonts only (zero
   external requests), stable hover (color/opacity — no layout
   shift), visible focus states, prefers-reduced-motion honored.
   Selectors are unchanged from the previous version on purpose:
   js/shared.js + the jsdom test suites depend on them.
   ============================================================ */

:root {
    /* palette */
    --bg: #f5f6fb;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --ink: #141a2e;            /* headings */
    --text: #363f58;           /* body */
    --muted: #5d6680;          /* secondary text (AA on white) */
    --faint: #7d859c;          /* hints only */
    --line: #e5e8f2;
    --line-strong: #d5daea;

    --brand: #6a48f5;          /* primary purple (logo start) */
    --brand-strong: #5335e0;   /* hover / emphasis */
    --brand-ink: #4c30cf;      /* text links (6.5:1 on white) */
    --brand-soft: #efeafd;
    --brand-border: #d8ccfb;

    --green: #1f9d55;          /* success / semantic */
    --green-soft: #e7f6ec;
    --green-border: #bfe6cd;

    --warn: #94660f;
    --warn-soft: #fdf3dd;
    --warn-border: #f0d9a0;

    --danger: #c23b3b;
    --danger-soft: #fdecec;
    --danger-border: #f3c4c4;

    --header-bg: #151a2c;

    /* shape & motion */
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(20, 26, 46, 0.05), 0 4px 14px rgba(20, 26, 46, 0.05);
    --shadow-md: 0 2px 4px rgba(20, 26, 46, 0.06), 0 12px 32px rgba(20, 26, 46, 0.09);
    --ease: 160ms ease;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- base ---------- */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    padding: 24px 20px 48px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(124, 92, 255, 0.07), transparent 60%),
        radial-gradient(900px 420px at 90% 0%, rgba(76, 175, 80, 0.05), transparent 55%),
        var(--bg);
    background-attachment: scroll;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: var(--brand-soft);
    color: var(--brand-ink);
}

a {
    color: var(--brand-ink);
}

h2, h3, h4 {
    color: var(--ink);
    letter-spacing: -0.015em;
    line-height: 1.25;
    text-wrap: balance;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 6px;
}

main {
    max-width: 880px;
    margin: 0 auto;
    padding: 0;
}

/* ---------- shared header (injected by js/shared.js) ---------- */
.ll-header {
    background: linear-gradient(180deg, #1a2036, var(--header-bg));
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    border-radius: var(--radius);
    margin: 0 auto 28px;
    max-width: 880px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ll-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
}

.ll-logo {
    display: block;
    flex-shrink: 0;
    border-radius: 7px;
}

.ll-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.ll-wordmark {
    font-size: 1.12em;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.ll-tagline {
    font-size: 0.74em;
    color: #a7b0cc;
    letter-spacing: 0.02em;
}

.ll-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.ll-nav a {
    color: #c9d0e6;
    text-decoration: none;
    font-size: 0.92em;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: 999px;
    transition: background-color var(--ease), color var(--ease);
}

.ll-nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.ll-nav a[aria-current="page"] {
    background-color: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 600;
}

/* ---------- hero ---------- */
.hero {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 40px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    text-align: center;
}

.hero h2 {
    margin: 0 auto 12px;
    max-width: 620px;
    font-size: clamp(1.55rem, 1.1rem + 2vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(100deg, #6a48f5 10%, #3f9e63 90%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--ink); /* fallback where background-clip:text is unsupported */
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
    .hero h2 { color: transparent; }
}

.hero p {
    margin: 0 auto;
    max-width: 640px;
    color: var(--muted);
    font-size: 1.06em;
}

/* ---------- generic sections & cards ---------- */
.tools-section,
.home-note,
.benefits,
.instructions,
.tool-section {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.tools-section h3,
.home-note h3,
.benefits h3 {
    margin: 0 0 18px;
    text-align: center;
    font-size: 1.25rem;
}

.home-note p {
    color: var(--muted);
    text-align: center;
    margin: 0;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.benefit-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 4px;
}

.benefit-item {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.benefit-item h4 {
    margin: 0 0 6px;
    font-size: 0.98em;
}

.benefit-item p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92em;
}

.instructions h3 {
    margin-top: 0;
    font-size: 1.15rem;
}

.instructions ol {
    padding-left: 22px;
    margin: 10px 0 0;
}

.instructions li {
    margin-bottom: 9px;
    color: var(--text);
}

.instructions li::marker {
    color: var(--brand-ink);
    font-weight: 700;
}

.instructions code,
.hero code,
.opt-check code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
    color: var(--brand-ink);
}

.privacy-line {
    color: var(--faint);
    font-size: 0.9em;
    border-top: 1px dashed var(--line);
    padding-top: 12px;
    margin-bottom: 0;
}

/* ---------- tool sections ---------- */
.tool-section h2 {
    margin-top: 0;
    text-align: center;
    font-size: 1.45rem;
}

.tool-section > p {
    text-align: center;
    color: var(--muted);
    margin: 8px auto 20px;
    max-width: 600px;
}

.tool-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field-label {
    display: block;
    font-weight: 700;
    color: var(--ink);
    font-size: 0.9em;
    letter-spacing: 0.01em;
}

/* inputs & textareas */
#input-json,
#output-json,
#input-url,
#b64-input,
#b64-output {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
    background: #fff;
    color: #1d2438;
    transition: border-color var(--ease), box-shadow var(--ease);
}

#input-json:focus,
#output-json:focus,
#input-url:focus,
#b64-input:focus,
#b64-output:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

#b64-input,
#b64-output {
    word-break: break-all;
}

#b64-output,
#rebuilt-url {
    background: var(--surface-2);
    color: var(--ink);
}

/* buttons */
button {
    padding: 10px 18px;
    background: var(--brand);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}

button:hover {
    background: var(--brand-strong);
}

button:active {
    background: #482dc4;
}

/* Secondary buttons (copy actions) — quieter */
.btn-secondary {
    padding: 8px 14px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-secondary:hover {
    border-color: var(--brand);
    color: var(--brand-ink);
    background: var(--brand-soft);
}

.copy-btn {
    padding: 5px 11px;
    background: #fff;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.copy-btn:hover {
    border-color: var(--brand);
    color: var(--brand-ink);
    background: var(--brand-soft);
}

.button-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- home page tool cards ---------- */
.tool-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 4px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}

.tool-card:hover {
    border-color: var(--brand-border);
    background: #fff;
    box-shadow: var(--shadow-md);
}

.tool-card h3 {
    margin: 0;
    font-size: 1.08em;
    color: var(--ink);
}

.tool-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.93em;
    flex-grow: 1;
}

.tool-card-cta {
    color: var(--brand-ink);
    font-weight: 700;
    font-size: 0.92em;
}

/* ---------- footer (injected by js/shared.js) ---------- */
.ll-footer {
    background: linear-gradient(180deg, #1a2036, var(--header-bg));
    color: #a7b0cc;
    padding: 28px 24px;
    margin-top: 36px;
    border-radius: var(--radius);
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ll-footer-inner {
    text-align: center;
}

.ll-footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 10px;
    border-radius: 8px;
}

.ll-footer-brand:hover { text-decoration: underline; }

.ll-footer-copy {
    margin: 8px 0 4px;
    font-size: 0.88em;
    color: #8a93b0;
}

.ll-footer-copy a { color: #c9d0e6; }

.ll-footer-note {
    margin: 0;
    font-size: 0.82em;
    color: #767f9d;
}

.ll-footer-tools {
    margin: 10px 0 4px;
    font-size: 0.93em;
}

.ll-footer-tools a {
    color: #c9d0e6;
    text-decoration: none;
    transition: color var(--ease);
}

.ll-footer-tools a:hover {
    color: #fff;
    text-decoration: underline;
}

.ll-footer-sep {
    margin: 0 8px;
    color: #525b78;
}

/* ============================================================
   URL Parameter Inspector
   ============================================================ */

.url-tool {
    text-align: left;
}

#input-url {
    width: 100%;
}

.url-status {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92em;
    text-align: left;
    border: 1px solid transparent;
}

.error-box {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: #8f2d2d;
}

.info-box {
    background: var(--brand-soft);
    border-color: var(--brand-border);
    color: #43329b;
}

/* breakdown chips */
.url-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.chip {
    font-family: var(--mono);
    font-size: 0.82em;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    word-break: break-all;
}

.chip-proto { background: var(--brand-soft); border-color: var(--brand-border); color: var(--brand-ink); }
.chip-host  { background: var(--green-soft); border-color: var(--green-border); color: #14683a; }
.chip-query { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }

/* parameter table */
.params-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.params-head h3 {
    margin: 0;
    font-size: 1.08rem;
    color: var(--ink);
}

.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

.params-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.params-table th {
    text-align: left;
    font-size: 0.76em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--faint);
    background: var(--surface-2);
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
}

.params-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #eef0f7;
    vertical-align: middle;
}

.params-table tr:last-child td {
    border-bottom: none;
}

.params-table tr.sensitive {
    background: var(--warn-soft);
}

.cell-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    font-family: var(--mono);
    font-size: 13px;
    color: #1d2438;
}

.cell-input:hover,
.cell-input:focus {
    border-color: var(--line-strong);
    background: #fff;
    outline: none;
}

.raw-cell {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--faint);
    word-break: break-all;
}

.copy-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.warn-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    color: var(--warn);
    font-size: 0.76em;
    font-weight: 700;
    white-space: nowrap;
}

.empty-note {
    text-align: center;
    color: var(--muted);
    padding: 14px;
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
}

/* rebuilt URL */
#rebuild-wrap h3 {
    margin: 0 0 10px;
    color: var(--ink);
    font-size: 1.08rem;
}

#rebuild-wrap .hint {
    font-size: 0.78em;
    font-weight: 400;
    color: var(--faint);
}

.rebuild-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#rebuilt-url {
    flex: 1;
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
}

/* ============================================================
   Base64 Encoder & Decoder (tool #3)
   ============================================================ */

.b64-tool {
    text-align: left;
}

/* mode segmented control (real radios, visually grouped) */
.b64-modes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mode-opt {
    position: relative;
    cursor: pointer;
}

.mode-opt input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.mode-opt span {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 0.92em;
    font-weight: 700;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}

.mode-opt:hover span {
    border-color: var(--brand-border);
    color: var(--brand-ink);
}

.mode-opt input:checked + span {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.mode-opt input:focus-visible + span {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.b64-out-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-line {
    margin: -6px 0 0;
    font-size: 0.84em;
    color: var(--faint);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.b64-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.opt-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.92em;
    color: var(--text);
}

.opt-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

/* ============================================================
   JWT Decoder (tool #4)
   ============================================================ */

.jwt-tool {
    text-align: left;
}

.jwt-tool textarea {
    width: 100%;
}

.jwt-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.88em;
    font-weight: 700;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
}

.badge-ok {
    background: var(--green-soft);
    border-color: var(--green-border);
    color: #14683a;
}

.badge-bad {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: #8f2d2d;
}

.badge-warn {
    background: var(--warn-soft);
    border-color: var(--warn-border);
    color: var(--warn);
}

.jwt-segment {
    margin-top: 18px;
}

.jwt-segment h4 {
    margin: 0 0 8px;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--faint);
}

.jwt-pre {
    margin: 0;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 220px;
    overflow-y: auto;
}

.jwt-sig {
    color: var(--faint);
}

/* ============================================================
   Hash Generator (tool #5)
   ============================================================ */

.hash-tool {
    text-align: left;
}

.hash-tool textarea {
    width: 100%;
}

.hash-mode-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.hash-digests {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.hash-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.hash-row .hash-name {
    font-weight: 700;
    font-size: 0.86em;
    width: 84px;
    flex-shrink: 0;
}

.hash-row .hash-value {
    flex: 1;
    font-family: var(--mono);
    font-size: 12.5px;
    word-break: break-all;
    color: #1d2438;
    min-width: 0;
}

.hash-row .hash-name .hash-legacy {
    display: block;
    font-size: 0.78em;
    font-weight: 400;
    color: var(--warn);
}

.hash-legacy-note {
    font-size: 0.88em;
    color: var(--muted);
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    margin-top: 12px;
}

.hash-verify {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.hash-verify input {
    flex: 1;
    min-width: 220px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
}

.hash-progress {
    margin-top: 8px;
    font-size: 0.86em;
    color: var(--faint);
}

/* ---------- toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(8px);
    background: var(--ink);
    color: #fff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 0.9em;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 50;
}

.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- responsive ---------- */
@media (max-width: 600px) {
    body {
        padding: 16px 12px 40px;
    }

    .hero,
    .tools-section,
    .home-note,
    .benefits,
    .instructions,
    .tool-section {
        padding: 22px 18px;
    }

    .rebuild-row {
        flex-direction: column;
    }

    .params-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-line {
        text-align: left;
    }
}

@media (min-width: 768px) {
    /* Two-pane row layout ONLY for the JSON Formatter container. A bare
       .tool-container rule here forced EVERY tool into a row at >=768px
       and broke the URL Inspector once its table appeared (product-2). */
    .tool-container.two-pane {
        flex-direction: row;
        align-items: flex-start;
    }

    #input-json, #output-json {
        width: calc(50% - 7.5px);
        height: 300px;
    }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}