:root {
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-border: #e2e2e2;
    --color-outline: #E5E7EB;
    --color-border-light: #efefef;

    --color-heading: #101828;
    --color-paragraph: #4A5565;
    --color-label: #6A7282;
    --color-placeholder: #A0A8B5;
    --color-mainGray: #f9fafB;

    --color-accent: #101828;
    --color-accent-hover: #1d2939;
    --color-danger: #fb2c36;
    --color-success: #00cf4f;
    --color-warning: #f59e0b;
    --color-blue: #4B90DE;

    --shadow-sm: 0px 1px 3px 0px #0000001A;
    --shadow-md: 0px 4px 16px 0px #0000001A;
    --shadow-lg: 0px 8px 32px 0px #00000014;

    --font-sans: 'Inter', 'Open Sans', sans-serif;
    --font-mono: 'Intel One Mono', 'Courier New', monospace;

    --container-max: 1280px;
    --tool-max: 920px;
    --tool-height: 408px;
}

*, *::before, *::after { box-sizing: border-box; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
    font-family: var(--font-sans) !important;
    background: var(--color-bg) !important;
    color: var(--color-heading);
    -webkit-font-smoothing: antialiased;
}

.c-container,
.c-container * {
    font-family: var(--font-sans);
}
.c-tool-tabs *,
.c-tool-tabs__word-count,
.c-hero__badge,
.c-processing__sub,
.c-sources__label {
    font-family: var(--font-mono) !important;
}

.hidden { display: none !important; }
.u-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Layout ── */
.c-container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: 24px;
}

.c-tool-wrap {
    width: 100%;
    max-width: var(--tool-max);
    margin-inline: auto;
    padding: 40px 0;
}
.c-result-wrap{
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    margin-bottom: 60px;
}

/* ── Hero ── */
.c-hero {
    text-align: center;
    padding: 0 24px 60px;
}

.c-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--color-label);
    margin-bottom: 12px;
    padding: 4px 8px;
    border: 1px solid var(--color-outline);
    background: var(--color-mainGray);
}

.c-hero__badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--color-heading);
    flex-shrink: 0;
}

.c-hero__title {
    font-size: clamp(32px, 5vw, 52px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: var(--color-heading);
    margin: 0 0 16px;
}

.c-hero__subtitle {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-paragraph);
    max-width: 760px;
    margin-inline: auto;
}

.c-tool-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-outline);
    position: relative;
    height: var(--tool-height);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.c-tool-panel__corner-tr,
.c-tool-panel__corner-bl {
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: var(--color-heading);
    border-style: solid;
    pointer-events: none;
    z-index: 2;
}
.c-tool-panel::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px;
    width: 12px; height: 12px;
    border-color: var(--color-heading);
    border-style: solid;
    border-width: 1px 0 0 1px;
    z-index: 2;
    pointer-events: none;
}
.c-tool-panel::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px;
    width: 12px; height: 12px;
    border-color: var(--color-heading);
    border-style: solid;
    border-width: 0 1px 1px 0;
    z-index: 2;
    pointer-events: none;
}
.c-tool-panel__corner-tr {
    top: -1px; right: -1px;
    border-width: 1px 1px 0 0;
}
.c-tool-panel__corner-bl {
    bottom: -1px; left: -1px;
    border-width: 0 0 1px 1px;
}

.c-tool-tabs {
    display: flex;
    align-items: stretch;
    padding: 8px 20px;
    border-bottom: 1px solid var(--color-outline);
    min-height: 32px;
    flex-shrink: 0;
    background-color: var(--color-mainGray);
}
.c-tool-tabs .left{
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.c-tool-tab {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0%;
    text-transform: uppercase;
    color: var(--color-label);
    border: none;
    background: none;
    cursor: default;
    white-space: nowrap;
    text-decoration: none;
    line-height: 16px;
}
.c-tool-tab-input{
    font-weight: 600;
}

/* clickable tab buttons (Add URL, Exclude URL) */
.c-tool-tab--btn {
    padding: 0;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: color .15s;
    color: var(--color-heading);
    font-weight: 400;
}
.c-tool-tab--btn:hover {
    color: var(--color-label);
}
.url-btns{
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--color-heading);
    padding-left: 16px;
    border-left: 1px solid var(--color-outline);
}
.c-tool-tabs__word-count {
    margin-left: auto;
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 16px;
    color: var(--color-label);
    white-space: nowrap;
}

/* ── Textarea body ── */
.c-tool-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.c-tool-textarea {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 28px;
    color: var(--color-heading);
    padding: 24px;
    background: var(--color-bg);
    display: block;
    overflow-y: auto;
}

.c-tool-textarea::placeholder { color: var(--color-placeholder); }

/* ── Tool footer ── */
.c-tool-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: var(--color-mainGray);
}

.c-tool-footer__left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.blur-filter {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.6);
    backdrop-filter: blur(3px);
    z-index: 5;
}

/* ── Buttons ── */
.c-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    text-decoration: none;
    line-height: 1;
}

.c-btn--primary {
    background: var(--color-accent);
    color: #fff;
    border: none;
}
.white-img{
    filter: brightness(0) invert(1);
}
.c-btn--primary:hover,
#checkPlag:hover:not(:disabled),
.c-container #checkPlag:hover:not(:disabled) { background: #1d2939 !important; border-color: #1d2939 !important; color: #fff !important; }
.c-btn--primary:disabled { opacity: .5; cursor: not-allowed; }
#checkPlag:disabled,
#checkPlag:disabled:hover { background: #101828 !important; border-color: #101828 !important; color: #fff !important; opacity: .65; cursor: not-allowed; }

.c-btn--ghost {
    background: var(--color-bg);
    color: var(--color-heading);
    border-color: var(--color-border);
}
.c-btn--ghost:hover { background: var(--color-surface); }

.c-btn--sm {
    font-size: 14px;
    padding: 8px 16px;
}

.c-btn__icon { flex-shrink: 0; }

/* ── Processing overlay ── */
.c-processing {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
}
.c-processing.is-active { display: flex; }

.c-processing__icon {
    width: 44px;
    height: 44px;
    color: var(--color-heading);
}

.c-processing__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-heading);
}

.c-processing__sub {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--color-label);
}

.c-processing__bar {
    width: 200px;
    height: 3px;
    background: var(--color-border);
    overflow: hidden;
}
.c-processing__bar-fill {
    height: 100%;
    width: 40%;
    background: var(--color-heading);
    animation: c-bar-slide 1.6s ease-in-out infinite;
}
@keyframes c-bar-slide {
    0%   { transform: translateX(-100%); }
    50%  { transform: translateX(150%); }
    100% { transform: translateX(400%); }
}

/* ── Native dialog (modals) ── */
dialog {
    border: none;
    box-shadow: var(--shadow-lg);
    padding: 0;
    max-width: 440px;
    width: calc(100% - 32px);
    background: var(--color-bg);
    /* centering — required for all browsers */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
dialog::backdrop {
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(2px);
}

.c-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.c-dialog__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-heading);
}
.c-dialog__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-placeholder);
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    transition: color .15s;
}
.c-dialog__close:hover { color: var(--color-heading); }

.c-dialog__body { padding: 12px 24px 24px; }

.c-dialog__desc {
    font-size: 13px;
    color: var(--color-paragraph);
    margin-bottom: 16px;
}

.c-dialog__footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--color-border-light);
}

.c-dialog__alert {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff8ed;
    border: 1px solid #f59e0b44;
    padding: 9px 12px;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 12px;
}
.c-dialog__alert-icon { flex-shrink: 0; color: #f59e0b; }
.c-dialog__alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: #92400e;
    font-size: 14px;
}

.c-dialog-url-list { display: flex; flex-direction: column; gap: 8px; }
.c-dialog-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.c-dialog-url-row input {
    flex: 1;
    border: 1px solid var(--color-heading);
    padding: 12px;
    font-size: 14px;
    height: 46px;
    outline: none;
    font-family: var(--font-sans);
    color: var(--color-heading);
    background: var(--color-bg);
    min-width: 220px;
}
.c-dialog-url-row input::placeholder { color: var(--color-placeholder); }
.c-dialog-url-row input:focus { border-color: var(--color-heading); }

.c-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
    color: var(--color-label);
    font-size: 16px;
}
.c-icon-btn:disabled { background: var(--color-bg); }
.c-icon-btn:hover, .c-icon-btn:disabled:hover { background: var(--color-surface); }
.c-icon-btn--remove {
    background: #ffffff;
    border: 1px solid var(--color-outline);
    box-shadow: var(--shadow-sm);
    color: var(--color-heading);
    width: 40px;
    height: 40px;
}
.c-icon-btn--remove:hover { background: #fef2f2; border-color: #fca5a5; }
.c-icon-btn--remove:hover .c-icon-btn__minus { background: var(--color-danger); }
.c-icon-btn__minus {
    display: block;
    width: 10px;
    height: 1.5px;
    background: var(--color-heading);
    border-radius: 1px;
}

/* plagiarized span highlight */
#output-content span.replace_sentemce {
    cursor: pointer;
}
#output-content span.highlighted {
    background: rgba(249,81,81,.08);
}
#word-count-display{
    line-height: 18px !important;
}

@media (max-width: 768px) {
    .c-tool-panel { height: 490px; }
    .c-hero { padding: 60px 16px 40px; }
    .c-hero__subtitle { font-size: 14px; }
}

@media (max-width: 540px) {
    .c-tool-footer {
        flex-direction: column;
        gap: 12px;
        padding: 16px 20px;
    }
    .c-tool-footer__left {
        width: 100%;
    }
    .c-tool-footer .c-btn--ghost,
    .c-tool-footer #btn_reset {
        display: flex !important;
        justify-content: center;
        width: 100%;
        font-size: 16px !important;
        font-weight: 400 !important;
        padding: 8px 12px !important;
        background: #fff !important;
        border: 1px solid #e5e7eb !important;
        box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.1) !important;
        line-height: 24px !important;
    }
    .c-tool-footer .c-btn--primary,
    .c-tool-footer #checkPlag {
        display: flex !important;
        justify-content: center;
        width: 100%;
        font-size: 16px !important;
        font-weight: 400 !important;
        padding: 10px 16px !important;
        line-height: 24px !important;
    }
    .c-btn--sm {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    .c-tool-tabs{
        align-items: flex-end;
        padding: 8px 12px;
    }
    .c-tool-tabs .left{
        flex-direction: column;
        align-items: flex-start;
        gap: 14px
    }
    .url-btns{
        border-left: 0;
        padding-left: 0;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .c-tool-tabs__word-count #word-count-display .wc-unit {
        display: none;
    }
}

@media (max-width: 480px) {
    .c-container { padding-inline: 16px; }
    .c-tool-footer { flex-wrap: wrap; }
}

.c-hero__title {
    color: var(--color-heading) !important;
}

/* button:disabled: style.css sets background:#8f8f91 globally */
.c-container button:disabled,
.c-btn:disabled {
    background: var(--color-mainGray) !important;
    opacity: .5 !important;
}
.c-btn--ghost:disabled {
    background: var(--color-bg) !important;
}

/* .blur-filter: style.css defines it with display:flex, no backdrop-filter.
   common.css defines it correctly but style.css loads first so we need specificity. */
.c-tool-body .blur-filter {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(255,255,255,.6) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    display: block !important;
    opacity: 1 !important;
    z-index: 5 !important;
    flex-direction: unset !important;
    justify-content: unset !important;
    align-items: unset !important;
}
/* when hidden class applied, hide wins */
.c-tool-body .blur-filter.hidden {
    display: none !important;
}

#tool-panel.is-processing #btn-add-url {
    color: var(--color-placeholder) !important;
    pointer-events: none !important;
    cursor: default !important;
    background: none !important;
}
#tool-panel.is-processing #btn-add-url img {
    opacity: 0.4 !important;
}
#tool-panel.is-processing #btn-new-scan {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.url-invalid-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-md);
    min-width: 220px;
    max-width: calc(100vw - 32px);
    pointer-events: all;
}
.url-invalid-toast.hidden { display: none !important; }
.url-invalid-toast__icon { flex-shrink: 0; }
.url-invalid-toast__text {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #101828;
    white-space: nowrap;
    padding: 0 12px;
    flex: 1;
}
.url-invalid-toast__close {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    border-radius: 6px;
    transition: opacity .15s;
}
.url-invalid-toast__close:hover { opacity: .6; }

#dialog-exclude-url {
    width: 380px;
    max-width: calc(100vw - 32px);
    padding: 0;
    border: 1px solid #e5e7eb;
    box-shadow: 0px 1px 1px 0px rgba(27,48,82,0.05), var(--shadow-lg);
    background: #fff;
}

.exc-dialog__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 16px 0;
}
.exc-dialog__typography {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.exc-dialog__title {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    line-height: 28px;
    color: #101828;
}
.exc-dialog__subtitle {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #4a5565;
    margin: 0;
}
.exc-dialog__close {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    border-radius: 6px;
    color: #101828;
    transition: opacity .15s;
}
.exc-dialog__close:hover { opacity: .6; }

/* Alert banner (max URLs) */
.exc-dialog__alert {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255,162,31,0.08);
    padding: 8px;
    margin: 16px 16px 0;
}
.exc-dialog__alert.hidden { display: none !important; }
.exc-dialog__alert-icon { flex-shrink: 0; }
.exc-dialog__alert-text {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #0f172a;
    flex: 1;
    padding: 0 12px;
}
.exc-dialog__alert-close {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    border-radius: 6px;
    transition: opacity .15s;
}
.exc-dialog__alert-close:hover { opacity: .6; }

/* Body: URL rows */
.exc-dialog__body {
    padding: 24px 16px;
}

/* Footer */
.exc-dialog__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 16px;
}
.exc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    padding: 8px 12px;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.exc-btn--ghost {
    background: #fafafa;
    border-color: #e5e7eb;
    color: #101828;
}
.exc-btn--ghost:hover { background: #f3f4f6; }
.exc-btn--primary {
    background: #101828;
    border-color: #101828;
    color: #fff;
}
.exc-btn--primary:hover { background: #1d2939; border-color: #1d2939; }

/* URL row: input + icon button */
.c-dialog-url-list { display: flex; flex-direction: column; gap: 12px; }
.c-dialog-url-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.c-dialog-url-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e5e7eb;
    padding: 12px;
    height: 46px;
    font-size: 14px;
    font-family: var(--font-sans);
    font-weight: 400;
    line-height: 20px;
    color: #101828;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}
.c-dialog-url-row input::placeholder { color: #a0a8b5; }
.c-dialog-url-row input:focus { border-color: #101828; }
.c-dialog-url-row input.is-invalid { border-color: #ef4444 !important; outline: none; }
.c-dialog-url-row input.is-invalid::placeholder { color: #ef4444; }
.c-dialog-url-row {
    flex-wrap: wrap;
}
.c-dialog-url-row input {
    flex-basis: calc(100% - 52px);
}
.c-url-error {
    flex-basis: 100%;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 400;
    color: #ef4444;
    margin: 2px 0 0 0;
    line-height: 1.4;
    order: 3;
}

/* Plus / Minus icon buttons */
.c-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.1);
    cursor: pointer;
    flex-shrink: 0;
    padding: 10px;
    transition: background .15s;
    color: #101828;
}
.c-icon-btn:hover { background: #f3f4f6; }
.c-icon-btn--remove:hover svg path { stroke: var(--color-danger); }
.c-icon-btn__minus {
    display: block;
    width: 10px;
    height: 1.5px;
    background: #101828;
    border-radius: 1px;
}
