:root {
    --tp-bg: #f4f7fb;
    --tp-surface: #ffffff;
    --tp-surface-2: #f8fafc;
    --tp-text: #0f172a;
    --tp-muted: #64748b;
    --tp-line: #e2e8f0;
    --tp-primary: #2563eb;
    --tp-primary-dark: #1d4ed8;
    --tp-success: #15803d;
    --tp-success-soft: #dcfce7;
    --tp-danger: #dc2626;
    --tp-danger-soft: #fee2e2;
    --tp-amber: #b45309;
    --tp-shadow: 0 18px 60px rgba(15, 23, 42, .08);
    --tp-radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--tp-bg);
    color: var(--tp-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}
button, select, textarea { font: inherit; }
button, select { min-height: 44px; }
button { -webkit-tap-highlight-color: transparent; }
.tp-page { min-height: 100vh; }
.tp-container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.tp-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.tp-hero {
    padding: 54px 0 92px;
    color: #fff;
    background:
        radial-gradient(circle at 85% 20%, rgba(59,130,246,.38), transparent 30%),
        radial-gradient(circle at 15% 0%, rgba(14,165,233,.24), transparent 34%),
        linear-gradient(135deg, #0f172a 0%, #172554 55%, #0f172a 100%);
}
.tp-hero-grid { display: grid; grid-template-columns: 1.6fr .7fr; gap: 48px; align-items: center; }
.tp-kicker { display: inline-flex; padding: 7px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.08); font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.tp-hero h1 { max-width: 760px; margin: 18px 0 14px; font-size: clamp(2.35rem, 5vw, 4.6rem); line-height: 1.02; letter-spacing: -.045em; }
.tp-hero-text { max-width: 760px; margin: 0; color: #dbeafe; font-size: clamp(1rem, 2vw, 1.18rem); }
.tp-hero-points { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 24px; color: #e0f2fe; font-weight: 650; font-size: .94rem; }
.tp-hero-mini-card { padding: 24px; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: rgba(255,255,255,.09); backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.tp-mini-label { color: #bfdbfe; font-size: .85rem; font-weight: 700; }
.tp-mini-number { margin: 4px 0 16px; font-size: 3.6rem; font-weight: 900; line-height: 1; }
.tp-mini-number small { font-size: .9rem; color: #bfdbfe; }
.tp-mini-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: #dbeafe; }
.tp-mini-row strong { color: #fff; }

.tp-tool-section { margin-top: -54px; position: relative; z-index: 2; }
.tp-tool-card { padding: 26px; background: var(--tp-surface); border: 1px solid rgba(226,232,240,.9); border-radius: 28px; box-shadow: var(--tp-shadow); }
.tp-toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tp-control label, .tp-custom-panel label { display: block; margin-bottom: 6px; color: #475569; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.tp-control select { width: 100%; padding: 0 13px; border: 1px solid var(--tp-line); border-radius: 12px; background: #fff; color: var(--tp-text); outline: none; }
.tp-control select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(59,130,246,.12); }
.tp-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.tp-pill { padding: 8px 14px; border: 1px solid var(--tp-line); border-radius: 999px; background: #fff; color: #334155; cursor: pointer; font-weight: 750; }
.tp-pill:hover { border-color: #93c5fd; background: #eff6ff; }
.tp-pill.is-active { border-color: var(--tp-primary); background: var(--tp-primary); color: #fff; }
.tp-custom-panel { margin-top: 18px; padding: 16px; border: 1px solid #bae6fd; border-radius: 16px; background: #f0f9ff; }
.tp-custom-panel textarea { width: 100%; resize: vertical; padding: 12px 14px; border: 1px solid #bae6fd; border-radius: 12px; background: #fff; }
.tp-inline-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.tp-help { color: var(--tp-muted); font-size: .88rem; }

.tp-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 22px 0 12px; }
.tp-stat { min-width: 0; padding: 13px 15px; border: 1px solid var(--tp-line); border-radius: 16px; background: var(--tp-surface-2); }
.tp-stat-value { display: block; overflow: hidden; text-overflow: ellipsis; font-size: clamp(1.25rem, 3vw, 1.7rem); line-height: 1.15; font-weight: 900; letter-spacing: -.03em; }
.tp-stat-label { display: block; margin-top: 3px; color: var(--tp-muted); font-size: .78rem; font-weight: 700; }
.tp-stat-time { background: #eff6ff; border-color: #bfdbfe; }
.tp-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.tp-progress { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2563eb, #06b6d4); transition: width .2s linear; }

.tp-prompt-wrap { margin-top: 18px; border: 1px solid var(--tp-line); border-radius: 18px; background: #fff; overflow: hidden; }
.tp-prompt-topline { display: flex; justify-content: space-between; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--tp-line); background: #f8fafc; color: var(--tp-muted); font-size: .82rem; font-weight: 750; }
.tp-prompt {
    min-height: 170px;
    max-height: 300px;
    overflow: auto;
    padding: 22px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: clamp(1.16rem, 2.5vw, 1.45rem);
    line-height: 1.9;
    letter-spacing: .01em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
}
.tp-prompt.tp-urdu { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Sans Arabic", serif; font-size: clamp(1.25rem, 2.8vw, 1.65rem); line-height: 2.15; }
.tp-char { border-radius: 3px; }
.tp-char.correct { color: var(--tp-success); background: var(--tp-success-soft); }
.tp-char.wrong { color: var(--tp-danger); background: var(--tp-danger-soft); text-decoration: underline; text-decoration-thickness: 2px; }
.tp-char.current { background: #dbeafe; box-shadow: inset 2px 0 0 var(--tp-primary); }

.tp-input-wrap { margin-top: 14px; }
#typingInput { width: 100%; min-height: 130px; resize: vertical; padding: 16px; border: 1px solid var(--tp-line); border-radius: 16px; background: #fbfdff; color: var(--tp-text); outline: none; line-height: 1.7; }
#typingInput[dir="rtl"] { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Sans Arabic", serif; font-size: 1.15rem; line-height: 2; }
.tp-input-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--tp-muted); font-size: .82rem; }
kbd { padding: 2px 6px; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 5px; background: #f8fafc; font-family: inherit; font-size: .75rem; }
.tp-actions, .tp-result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tp-btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; font-weight: 800; text-decoration: none; }
.tp-btn-primary { background: var(--tp-primary); color: #fff; }
.tp-btn-primary:hover { background: var(--tp-primary-dark); }
.tp-btn-secondary { border-color: var(--tp-line); background: #fff; color: #334155; }
.tp-btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.tp-insights, .tp-content-section, .tp-faq-section { padding: 72px 0; }
.tp-insights { padding-bottom: 12px; }
.tp-section-heading { max-width: 720px; margin-bottom: 26px; }
.tp-section-heading > span { color: var(--tp-primary); font-size: .78rem; font-weight: 900; letter-spacing: .08em; }
.tp-section-heading h2, .tp-article-card h2, .tp-side-card h2 { margin: 7px 0 10px; line-height: 1.2; letter-spacing: -.025em; }
.tp-section-heading h2 { font-size: clamp(1.7rem, 4vw, 2.35rem); }
.tp-section-heading p { margin: 0; color: var(--tp-muted); }
.tp-info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.tp-info-card { padding: 20px; border: 1px solid var(--tp-line); border-radius: 18px; background: #fff; }
.tp-info-card h3 { margin: 0 0 5px; font-size: 1.15rem; }
.tp-info-card p { margin: 0; color: var(--tp-muted); font-size: .95rem; }

.tp-content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
.tp-article-card, .tp-side-card { padding: 28px; border: 1px solid var(--tp-line); border-radius: 22px; background: #fff; }
.tp-article-card h2 { margin-top: 32px; font-size: 1.45rem; }
.tp-article-card h2:first-child { margin-top: 0; }
.tp-article-card p, .tp-article-card li { color: #475569; }
.tp-article-card ol { padding-left: 22px; }
.tp-table-wrap { overflow-x: auto; border: 1px solid var(--tp-line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 580px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--tp-line); }
th { background: #f8fafc; color: #334155; font-size: .84rem; }
tbody tr:last-child td { border-bottom: 0; }
.tp-note { font-size: .88rem; }
.tp-side-card { position: sticky; top: 18px; }
.tp-side-card h2 { margin-top: 0; font-size: 1.2rem; }
.tp-side-link { width: 100%; display: block; padding: 13px 0; border: 0; border-bottom: 1px solid var(--tp-line); background: transparent; color: var(--tp-text); text-align: left; text-decoration: none; cursor: pointer; }
.tp-side-link:last-child { border-bottom: 0; }
.tp-side-link strong, .tp-side-link span { display: block; }
.tp-side-link span { margin-top: 2px; color: var(--tp-muted); font-size: .84rem; }
.tp-side-link:hover strong { color: var(--tp-primary); }

.tp-faq-section { padding-top: 12px; padding-bottom: 88px; }
.tp-faq-list { display: grid; gap: 10px; }
.tp-faq-list details { border: 1px solid var(--tp-line); border-radius: 16px; background: #fff; padding: 0 18px; }
.tp-faq-list summary { padding: 16px 0; cursor: pointer; font-weight: 800; }
.tp-faq-list p { margin: 0 0 16px; color: var(--tp-muted); }

.tp-modal { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 18px; }
.tp-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .66); backdrop-filter: blur(5px); }
.tp-modal-card { position: relative; width: min(560px, 100%); padding: 30px; border-radius: 24px; background: #fff; box-shadow: 0 30px 100px rgba(0,0,0,.25); text-align: center; }
.tp-modal-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; min-height: 38px; border: 0; border-radius: 50%; background: #f1f5f9; color: #475569; font-size: 1.5rem; cursor: pointer; }
.tp-result-badge { display: inline-block; padding: 6px 10px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: .72rem; font-weight: 900; letter-spacing: .07em; }
.tp-modal-card h2 { margin: 12px 0 6px; }
.tp-result-score { margin: 14px 0 20px; font-size: 5rem; font-weight: 950; line-height: .9; letter-spacing: -.06em; color: var(--tp-primary); }
.tp-result-score small { display: block; margin-top: 10px; font-size: .85rem; letter-spacing: .08em; }
.tp-result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tp-result-grid div { padding: 12px 8px; border-radius: 12px; background: #f8fafc; }
.tp-result-grid strong, .tp-result-grid span { display: block; }
.tp-result-grid strong { font-size: 1.15rem; }
.tp-result-grid span { color: var(--tp-muted); font-size: .75rem; }
.tp-result-message { margin: 18px 0 0; color: #475569; }
.tp-result-actions { justify-content: center; }
.tp-share-status { min-height: 22px; margin-top: 10px; color: var(--tp-success); font-size: .85rem; }

@media (max-width: 900px) {
    .tp-hero-grid, .tp-content-grid { grid-template-columns: 1fr; }
    .tp-hero-mini-card { max-width: 460px; }
    .tp-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tp-info-grid { grid-template-columns: repeat(2, 1fr); }
    .tp-side-card { position: static; }
}

@media (max-width: 640px) {
    .tp-container { width: min(100% - 20px, 1180px); }
    .tp-hero { padding: 38px 0 82px; }
    .tp-hero h1 { font-size: 2.45rem; }
    .tp-tool-card { padding: 16px; border-radius: 20px; }
    .tp-toolbar { grid-template-columns: 1fr; }
    .tp-stats { grid-template-columns: repeat(2, 1fr); }
    .tp-stat-time { grid-column: span 2; }
    .tp-prompt { min-height: 150px; padding: 16px; }
    .tp-input-footer { align-items: flex-start; flex-direction: column; }
    .tp-actions .tp-btn { flex: 1 1 130px; }
    .tp-info-grid { grid-template-columns: 1fr; }
    .tp-insights, .tp-content-section, .tp-faq-section { padding-top: 48px; }
    .tp-result-grid { grid-template-columns: repeat(2, 1fr); }
    .tp-result-score { font-size: 4.4rem; }
    .tp-modal-card { padding: 26px 18px 22px; }
}

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