/* ============================================================================
 * Text Tools — styles.css
 * ==========================================================================*/
:root {
    --brand: #059669;
    --brand-2: #34d399;
    --brand-dark: #047857;
    --tint: #d1fae5;
    --tint-2: #ecfdf5;
    --ink-1: #1b1d28;
    --ink-2: #5b6072;
    --line: #e7e9f0;
    --bg: #f6f7fb;
    --card: #ffffff;
    --ok: #18a058;
    --err: #e5484d;
    --radius: 14px;
    --shadow-sm: 0 1px 3px rgba(20, 22, 40, .08);
    --shadow-md: 0 10px 30px rgba(20, 22, 40, .10);
    --maxw: 1120px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink-1);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
body.no-translate { visibility: hidden; opacity: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: .7em 1.25em; border-radius: 10px; border: 1px solid transparent;
    background: #eef0f6; color: var(--ink-1); transition: .18s;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(5, 150, 105, .28); }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--small { padding: .45em .85em; font-size: .9rem; border-radius: 9px; }
.btn--block { width: 100%; }
.btn--lg { padding: .9em 1.8em; font-size: 1.05rem; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* --- Header --- */
.sticky-header { position: sticky; top: 0; z-index: 50; }
.topbar { background: rgba(255,255,255,.9); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line); }
.topbar__inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: center; gap: 9px; color: var(--brand); font-weight: 800; font-size: 1.2rem; }
.logo-text { color: var(--ink-1); }
.logo-text__accent { color: var(--brand); }
.nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
.nav-link { padding: .5em .7em; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: .95rem; }
.nav-link:hover { background: #f1f2f7; color: var(--ink-1); }
.topbar__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.premium-badge { background: linear-gradient(120deg, #ffd56a, #ffb020); color: #5a3b00; font-weight: 700; font-size: .8rem; padding: .3em .7em; border-radius: 20px; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--ink-1); }
.nav-drawer { display: none; flex-direction: column; gap: 6px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.nav-drawer.is-open { display: flex; }

/* --- Hero --- */
.hero { padding-top: 64px; padding-bottom: 40px; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 3rem); }
.hero .lead { color: var(--ink-2); font-size: 1.15rem; max-width: 640px; margin: 0 auto 8px; }
.hero__trust { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; color: var(--ink-2); font-size: .95rem; margin-top: 14px; }

/* --- Tool grid --- */
.section { padding-top: 40px; padding-bottom: 40px; }
.section__title { text-align: center; font-size: 1.8rem; }
.section__subtitle { text-align: center; color: var(--ink-2); max-width: 600px; margin: 0 auto 28px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tool-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow-sm); transition: .2s; display: flex; flex-direction: column; gap: 8px;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #a7f3d0; }
.tool-card__icon { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; color: var(--brand); background: var(--tint); }
.tool-card__title { font-weight: 700; font-size: 1.1rem; }
.tool-card__desc { color: var(--ink-2); font-size: .92rem; }

/* --- Tool page --- */
.tool-hero { padding-top: 48px; padding-bottom: 18px; text-align: center; }
.tool-hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
.tool-hero p { color: var(--ink-2); max-width: 560px; margin: 0 auto; }
.workspace { max-width: 760px; margin: 0 auto 50px; padding: 0 20px; }

.dropzone {
    background: var(--card); border: 2px dashed #d4d8e6; border-radius: var(--radius);
    padding: 48px 24px; text-align: center; cursor: pointer; transition: .18s; margin-top: 20px;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--brand); background: var(--tint-2); }
.dropzone__icon { font-size: 2.4rem; }
.dropzone__title { font-weight: 700; font-size: 1.15rem; margin-top: 8px; }
.dropzone__hint { color: var(--ink-2); font-size: .92rem; }
.dropzone input[type=file] { display: none; }

.filelist { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.fileitem {
    display: flex; align-items: center; gap: 12px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.fileitem__handle { cursor: grab; color: var(--ink-2); font-size: 1.1rem; }
.fileitem.dragging { opacity: .5; }
.fileitem__name { flex: 1; font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileitem__size { color: var(--ink-2); font-size: .85rem; }
.fileitem__remove { background: none; border: 0; cursor: pointer; color: var(--ink-2); font-size: 1.2rem; line-height: 1; }
.fileitem__remove:hover { color: var(--brand); }

.options { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 18px; box-shadow: var(--shadow-sm); }
.options h3 { font-size: 1.05rem; }
.field { margin-top: 12px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field input[type=text], .field input[type=number], .field select {
    width: 100%; padding: .65em .8em; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff;
}
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; padding: .5em .8em; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-weight: 500; }
.radio-row input { accent-color: var(--brand); }

.action-bar { display: flex; justify-content: center; margin-top: 22px; }
.warn { background: #fff7ec; border: 1px solid #ffd98a; color: #8a5a00; padding: 10px 14px; border-radius: 10px; font-size: .9rem; margin-top: 14px; }
.progress { height: 8px; background: #eef0f6; border-radius: 6px; overflow: hidden; margin-top: 16px; }
.progress__bar { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; text-align: center; margin-top: 22px; box-shadow: var(--shadow-sm); }
.result h3 { font-size: 1.3rem; }
.result .stat { color: var(--ink-2); margin: 6px 0 16px; }
.result .stat strong { color: var(--ok); }
.hidden { display: none !important; }

/* --- Modal / paywall --- */
.modal { position: fixed; inset: 0; background: rgba(20,22,40,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal.show { display: flex; }
.modal-content { background: #fff; border-radius: 18px; max-width: 440px; width: 100%; padding: 30px; position: relative; box-shadow: var(--shadow-md); }
.modal-content h2 { font-size: 1.5rem; }
.modal-desc { color: var(--ink-2); }
.close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--ink-2); }
.paywall-bullets { list-style: none; padding: 0; margin: 16px 0; }
.paywall-bullets li { padding: 7px 0 7px 28px; position: relative; }
.paywall-bullets li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.payment-link-button {
    display: flex; align-items: center; justify-content: center; gap: .5em; width: 100%;
    background: var(--brand); color: #fff; font-weight: 700; padding: .9em; border-radius: 12px; margin-top: 8px;
    box-shadow: 0 6px 16px rgba(5,150,105,.3); transition: .18s;
}
.payment-link-button:hover { background: var(--brand-dark); }
.lock-icon { width: 18px; height: 18px; }
.payment-secure-note { text-align: center; color: var(--ink-2); font-size: .82rem; margin-top: 10px; }

/* --- Lead form --- */
.lead-offer { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 30px auto 0; max-width: 560px; text-align: center; box-shadow: var(--shadow-sm); }
.lead-form__row { display: flex; gap: 8px; margin-top: 10px; }
.lead-form__row input { flex: 1; padding: .7em .9em; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.lead-form__help { color: var(--ink-2); font-size: .82rem; margin-top: 8px; }
.lead-form__error { color: var(--brand); font-size: .85rem; }
.lead-form__success { color: var(--ok); font-size: .85rem; }

/* --- FAQ --- */
.faq { max-width: 760px; margin: 0 auto; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { color: var(--ink-2); margin: 10px 0 0; }

/* --- Footer --- */
.footer { background: #fff; border-top: 1px solid var(--line); margin-top: 40px; padding: 40px 20px 24px; }
.footer__tools { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 28px; }
.footer__col h4 { font-size: .95rem; }
.footer__col a { display: block; color: var(--ink-2); font-size: .9rem; padding: 3px 0; }
.footer__col a:hover { color: var(--brand); }
.footer__col--about p { color: var(--ink-2); font-size: .9rem; }
.footer__note { text-align: center; color: var(--ink-2); font-size: .85rem; margin-top: 28px; }

/* --- Responsive --- */
@media (max-width: 860px) {
    .nav { display: none; }
    .nav-toggle { display: block; }
    .nav-drawer.is-open { display: flex; }
}

@media (max-width: 600px) {
    .container { padding: 0 20px; }

    /* Header: tighter, declutter (Premium lives in the drawer on mobile) */
    .topbar__inner { padding: 10px 16px; gap: 10px; }
    .logo { font-size: 1.1rem; }
    .logo-icon svg { width: 26px; height: 26px; }
    #openPaywallFromHeader { display: none; }

    /* Hero / sections */
    .hero { padding-top: 36px; padding-bottom: 22px; }
    .hero .lead { font-size: 1.02rem; }
    .hero__trust { gap: 6px 16px; font-size: .9rem; }
    .section { padding-top: 30px; padding-bottom: 30px; }
    .section__title { font-size: 1.45rem; }
    .section__subtitle { font-size: .95rem; }
    .tool-hero { padding-top: 32px; padding-bottom: 12px; }

    /* Cards a touch tighter */
    .tool-grid { gap: 14px; }
    .tool-card { padding: 18px; }

    /* Tool workspace */
    .workspace { padding: 0 20px; }
    .dropzone { padding: 34px 16px; }
    .dropzone__icon { font-size: 2rem; }
    .dropzone__title { font-size: 1.05rem; }
    .options, .result { padding: 18px; }

    /* Radio groups stack vertically so long labels read well */
    .radio-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .radio-row label { justify-content: flex-start; }

    /* Modal / paywall */
    .modal { padding: 12px; }
    .modal-content { padding: 24px 18px; border-radius: 14px; }
    .modal-content h2 { font-size: 1.3rem; }

    /* Lead form: stacked, full-width button */
    .lead-offer { padding: 18px; }
    .lead-form__row { flex-direction: column; }
    .lead-form__row .btn { width: 100%; }

    /* Footer */
    .footer { padding: 30px 20px 22px; }
    .footer__tools { gap: 22px; }
}

@media (max-width: 400px) {
    .hero h1 { font-size: 1.7rem; }
    .section__title { font-size: 1.3rem; }
    .btn--lg { padding: .85em 1.2em; font-size: 1rem; }
    .logo-text { font-size: 1.05rem; }
}

/* --- Dev tool editor (text in / text out) --- */
.editor { max-width: 1000px; margin: 18px auto 50px; padding: 0 20px; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; }
.panel__bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfbfe; }
.panel__title { font-weight: 700; font-size: .92rem; color: var(--ink-1); }
.panel__bar .spacer { flex: 1; }
.iconbtn { background: #eef0f6; border: 1px solid transparent; border-radius: 8px; padding: .35em .7em; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink-2); transition: .15s; }
.iconbtn:hover { background: #e4e6f0; color: var(--ink-1); }
.code, .code-out {
    font-family: var(--mono); font-size: .9rem; line-height: 1.5; tab-size: 2;
    width: 100%; border: 0; background: var(--card); color: var(--ink-1);
    padding: 14px; resize: vertical; min-height: 300px; box-sizing: border-box;
}
.code:focus { outline: none; }
.code::placeholder { color: #aab; }
.code-out { white-space: pre; overflow: auto; margin: 0; min-height: 300px; }
.code-out--wrap { white-space: pre-wrap; word-break: break-word; }

/* Options bar above the editor */
.optbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.optbar .opt { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.optbar select, .optbar input[type=text] { padding: .45em .6em; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.optbar label.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.optbar input[type=checkbox], .optbar input[type=radio] { accent-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg label { padding: .45em .9em; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--brand); color: #fff; }

.run-row { display: flex; justify-content: center; gap: 10px; margin: 18px 0 0; flex-wrap: wrap; }
.error-box { margin-top: 14px; background: #fdecec; border: 1px solid #f5b5b7; color: #a51d22; padding: 11px 14px; border-radius: 10px; font-size: .9rem; font-family: var(--mono); white-space: pre-wrap; }

/* Hash result rows */
.hash-grid { display: flex; flex-direction: column; gap: 0; }
.hash-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.hash-row:last-child { border-bottom: 0; }
.hash-row .algo { font-weight: 700; font-size: .85rem; color: var(--brand); }
.hash-row .val { font-family: var(--mono); font-size: .85rem; word-break: break-all; color: var(--ink-1); }

/* JWT panels */
.jwt-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.jwt-claims { margin-top: 16px; }
.jwt-claims .hash-row { grid-template-columns: 120px 1fr; }

@media (max-width: 760px) {
    .editor-grid, .jwt-cols { grid-template-columns: 1fr; }
    .code, .code-out { min-height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* --- Counter: live stats grid --- */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px;
    margin-top: 18px;
}
.stat-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 16px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-card__num { font-size: 1.9rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat-card__label { color: var(--ink-2); font-size: .85rem; margin-top: 4px; }
.editor--single .editor-grid { grid-template-columns: 1fr; }

/* --- Find & Replace fields --- */
.fr-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fr-fields .field { margin-top: 0; }
@media (max-width: 600px) { .fr-fields { grid-template-columns: 1fr; } }
.match-count { color: var(--ink-2); font-size: .88rem; margin-top: 10px; text-align: center; }
.match-count strong { color: var(--brand); }

/* --- Diff output --- */
.diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .diff-cols { grid-template-columns: 1fr; } }
.diff-out {
    font-family: var(--mono); font-size: .88rem; line-height: 1.55;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 0; margin-top: 18px; box-shadow: var(--shadow-sm); overflow: auto; max-height: 520px;
}
.diff-line { display: flex; gap: 10px; padding: 1px 14px; white-space: pre-wrap; word-break: break-word; }
.diff-sym { width: 1ch; flex: none; color: var(--ink-2); user-select: none; }
.diff-text { flex: 1; }
.diff-add { background: #e6f6ec; }
.diff-add .diff-sym { color: var(--ok); }
.diff-del { background: #fdecec; }
.diff-del .diff-sym { color: var(--err); }
.diff-summary { text-align: center; color: var(--ink-2); font-size: .9rem; margin-top: 12px; }
.diff-summary .add { color: var(--ok); font-weight: 700; }
.diff-summary .del { color: var(--err); font-weight: 700; }
