:root {
    --primary: #0b63ce;
    --primary-dark: #084f9f;
    --success: #16813d;
    --danger: #b4232f;
    --warning-bg: #fff5f5;
    --text: #22304a;
    --muted: #61708a;
    --border: #d8e0ec;
    --surface: #ffffff;
    --page: #f4f7fb;
    --soft: #eef5ff;
    --radius: 14px;
    --shadow: 0 12px 34px rgba(34, 48, 74, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
}

button,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

a {
    color: inherit;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin-inline: auto;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 10000;
    transform: translateY(-150%);
    padding: 10px 14px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.navbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand img {
    display: block;
    width: auto;
    height: 46px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 26px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: #37445b;
    font-weight: 600;
    font-size: 0.96rem;
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: var(--primary);
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-size: 1.25rem;
}

.hero {
    padding: 24px 0 18px;
}

.hero .container {
    padding: 24px 28px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1177dc, #0753a7);
    color: #fff;
    text-align: center;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0 0 6px;
    font-size: clamp(1.7rem, 3.3vw, 2.35rem);
    line-height: 1.2;
}

.hero p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.93;
}

main {
    padding: 10px 0 48px;
}

.converter {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.converter > h2 {
    margin: 0 0 20px;
    font-size: 1.45rem;
}

.converter > h2 span {
    font-family: "Noto Nastaliq Urdu", serif;
    font-weight: 700;
}

.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f7f9fc;
}

.mode-tab {
    min-height: 72px;
    padding: 11px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    text-align: center;
}

.mode-tab strong,
.mode-tab span {
    display: block;
}

.mode-tab strong {
    font-size: 1rem;
}

.mode-tab span {
    margin-top: 2px;
    font-family: "Noto Nastaliq Urdu", serif;
    font-size: 0.94rem;
}

.mode-tab.is-active {
    border-color: #a8c9f2;
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(11, 99, 206, 0.1);
}

.language-control {
    display: grid;
    grid-template-columns: auto minmax(170px, 230px) 1fr;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid #bcd5f4;
    border-radius: 10px;
    background: var(--soft);
}

.language-control[hidden] {
    display: none;
}

.language-control label {
    font-weight: 700;
}

.language-control select {
    min-height: 42px;
    padding: 7px 10px;
    border: 1px solid #9dbce2;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.language-control small {
    color: var(--muted);
}

.field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.field-head label {
    font-weight: 700;
}

.field-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#counter {
    color: var(--muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

#counter.is-over {
    color: var(--danger);
    font-weight: 700;
}

.text-button {
    padding: 5px 11px;
    border: 1px solid #a9c4e8;
    border-radius: 7px;
    background: #fff;
    color: var(--primary-dark);
    font-weight: 700;
}

.text-area {
    display: block;
    width: 100%;
    min-height: 230px;
    resize: vertical;
    padding: 18px;
    border: 1px solid #bfcde0;
    border-radius: 12px;
    background: #fff;
    color: #101828;
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    font-family: "Noto Nastaliq Urdu", serif;
    font-size: 1.18rem;
    line-height: 2.15;
    overflow-wrap: anywhere;
}

.text-area:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(11, 99, 206, 0.13);
}

.text-area.is-invalid {
    border-color: var(--danger);
    outline-color: rgba(180, 35, 47, 0.1);
}

.message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 10px;
    padding: 11px 13px;
    border-radius: 9px;
    font-size: 0.94rem;
}

.message[hidden] {
    display: none;
}

.message-error {
    border: 1px solid #f0aeb5;
    background: var(--warning-bg);
    color: #8c1521;
}

.message-error button {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid #ca6670;
    border-radius: 7px;
    background: #fff;
    color: #8c1521;
    font-weight: 700;
}

.accuracy-note {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin: 10px 0 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.accuracy-note span {
    font-family: "Noto Nastaliq Urdu", serif;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
}

.captcha-wrap {
    min-width: 305px;
}

.captcha-wrap small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
}

.captcha-wrap small.is-ok {
    color: var(--success);
    font-weight: 700;
}

.buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.button {
    min-height: 46px;
    padding: 10px 20px;
    border-radius: 9px;
    font-weight: 750;
}

.button-primary {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
}

.button-primary:not(:disabled):hover {
    background: var(--primary-dark);
}

.button-secondary {
    border: 1px solid #aab7ca;
    background: #fff;
    color: #35445e;
}

.button-success {
    border: 1px solid var(--success);
    background: var(--success);
    color: #fff;
}

.result {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.result[hidden] {
    display: none;
}

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.result-head h2 {
    margin: 0;
    font-size: 1.3rem;
}

.result-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.result-area {
    min-height: 240px;
    background: #fcfdff;
}

.help-box,
.faq {
    margin-top: 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(34, 48, 74, 0.04);
}

.help-box summary {
    padding: 16px 18px;
    cursor: pointer;
    font-weight: 750;
}

.help-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
    padding: 0 22px 20px;
    color: #4c5b73;
}

.help-content ol {
    margin: 0;
    padding-inline-start: 22px;
}

.urdu-text {
    font-family: "Noto Nastaliq Urdu", serif;
    line-height: 2.1;
}

.faq {
    padding: 20px;
}

.faq h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.faq details {
    border-top: 1px solid var(--border);
}

.faq summary {
    padding: 13px 2px;
    cursor: pointer;
    font-weight: 700;
}

.faq p {
    margin: 0 0 15px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(420px, calc(100vw - 36px));
    padding: 13px 15px;
    border-radius: 10px;
    background: #1e293b;
    color: #fff;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
}

.toast[hidden] {
    display: none;
}

.toast.is-error {
    background: #a51e2b;
}

.toast.is-success {
    background: #147737;
}

.toast button {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.25rem;
}

.site-footer {
    border-top: 1px solid #1d4f89;
    background: #0b559e;
    color: #fff;
}

.footer-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.footer-inner p {
    margin: 0;
}

.footer-inner nav {
    display: flex;
    gap: 20px;
}

@media (max-width: 820px) {
    .nav-toggle {
        display: inline-grid;
        place-items: center;
    }

    .nav-links {
        position: absolute;
        top: 71px;
        right: 16px;
        left: 16px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
        box-shadow: var(--shadow);
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-links a {
        display: block;
        padding: 10px 12px;
    }

    .language-control {
        grid-template-columns: 1fr minmax(150px, 190px);
    }

    .language-control small {
        grid-column: 1 / -1;
    }

    .action-row {
        align-items: stretch;
        flex-direction: column;
    }

    .captcha-wrap {
        min-width: 0;
    }

    .buttons {
        justify-content: stretch;
    }

    .buttons .button {
        flex: 1;
    }

    .help-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .container {
        width: min(100% - 20px, 1180px);
    }

    .navbar {
        min-height: 64px;
    }

    .brand img {
        height: 40px;
    }

    .nav-links {
        top: 63px;
        right: 10px;
        left: 10px;
    }

    .hero {
        padding: 10px 0 12px;
    }

    .hero .container {
        padding: 17px 14px;
        border-radius: 13px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 0.9rem;
    }

    main {
        padding-top: 0;
    }

    .converter {
        padding: 17px 13px;
        border-radius: 14px;
    }

    .converter > h2 {
        margin-bottom: 14px;
        font-size: 1.25rem;
    }

    .mode-tabs {
        gap: 5px;
        padding: 4px;
    }

    .mode-tab {
        min-height: 64px;
        padding: 8px 6px;
    }

    .mode-tab strong {
        font-size: 0.88rem;
    }

    .mode-tab span {
        font-size: 0.82rem;
    }

    .language-control {
        grid-template-columns: 1fr;
        padding: 11px;
    }

    .field-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .field-actions {
        width: 100%;
        justify-content: space-between;
    }

    .text-area {
        min-height: 210px;
        padding: 14px;
        font-size: 1.05rem;
        line-height: 2;
    }

    .message {
        align-items: stretch;
        flex-direction: column;
    }

    .message-error button {
        width: 100%;
    }

    .g-recaptcha {
        transform: scale(0.91);
        transform-origin: left top;
        margin-bottom: -7px;
    }

    .buttons {
        flex-direction: column-reverse;
    }

    .buttons .button,
    .result-head .button {
        width: 100%;
    }

    .result-head {
        align-items: stretch;
        flex-direction: column;
    }

    .footer-inner {
        padding: 18px 0;
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .footer-inner nav {
        flex-wrap: wrap;
        gap: 10px 18px;
    }
}

/* Final compact conversion behavior */
#counter.is-over {
    color: #9a3412;
    font-weight: 700;
}

.accuracy-note {
    margin: 10px 0 18px;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: #f6f8fb;
    color: var(--muted);
    font-size: 0.9rem;
}

.accuracy-note span {
    display: inline;
    margin-inline-start: 6px;
}

.result-area {
    min-height: 210px;
}
