:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #6b7489;
    --border: #e2e7f0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef0ff;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warn: #d97706;
    --warn-soft: #fff4e0;
    --success: #059669;
    --success-soft: #e6f7f0;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.15rem; }
code { background: var(--primary-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 28px; padding-bottom: 40px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 9px; background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: .95rem; flex: none;
}
.brand-logo { height: 44px; width: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; letter-spacing: .02em; }
.brand-tagline { font-size: .72rem; font-weight: 500; color: var(--muted); }
.hero-logo { height: 96px; width: auto; margin-bottom: 14px; }
.hero-kicker { font-size: .8rem !important; font-weight: 700; letter-spacing: .08em; color: var(--primary) !important; margin: 0 auto 12px !important; }
.loader-logo { width: 40px; height: 40px; object-fit: contain; animation: pulse 1.2s ease-in-out infinite; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav > a:not(.btn) { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav > a:not(.btn):hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav > a.active { color: var(--primary); background: var(--primary-soft); }
.nav-user { color: var(--muted); padding: 0 8px; font-size: .9rem; }
.nav form.inline { display: inline-flex; }
.nav form.inline .btn { width: 100%; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--text); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--primary); color: #fff; border: 1px solid var(--primary);
    padding: 10px 18px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer;
    transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #f3c4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: .875rem; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::before {
    content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards & forms */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
label { display: block; font-weight: 500; margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 13px;
    border: 1px solid var(--border); border-radius: 9px; font: inherit; color: var(--text); background: var(--surface);
}
textarea { resize: vertical; min-height: 140px; line-height: 1.6; }
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: #065f46; border-color: #b7e6d3; }
.alert-error { background: var(--danger-soft); color: #991b1b; border-color: #f3c4c4; }
.alert-info { background: var(--primary-soft); color: #3730a3; border-color: #d6d9fb; }

/* Home */
.hero { text-align: center; padding: 48px 0 36px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 1.15rem; max-width: 620px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.feature { color: var(--text); transition: transform .15s, box-shadow .15s; }
a.feature:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .1); }
.feature p { color: var(--muted); margin: 0; }
.feature-icon { font-size: 1.8rem; margin-bottom: 10px; }

/* Tool pages */
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 0; }
.tool textarea { margin-top: 0; }
.tool-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.modes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.mode { margin: 0; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode span { display: inline-block; padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 500; color: var(--muted); }
.mode input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.mode input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.pane-head { font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
#rewrite-output { background: #fafbfe; }

/* Plagiarism results */
.result-grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.score-card { text-align: center; }
.score-ring {
    --pct: 0; --color: var(--success);
    width: 150px; height: 150px; margin: 4px auto 12px; border-radius: 50%;
    background: conic-gradient(var(--color) calc(var(--pct) * 1%), var(--border) 0);
    display: grid; place-items: center; position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 14px; background: var(--surface); border-radius: 50%; }
.score-ring span { position: relative; font-size: 2rem; font-weight: 800; }
.score-label { font-weight: 600; }
.score-unique { color: var(--muted); }
.stats-card { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-content: center; }
.stats-card p { grid-column: 1 / -1; margin: 6px 0 0; }
.stat, .stat-box { display: flex; flex-direction: column; color: var(--muted); font-size: .9rem; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--text); }

.highlighted { line-height: 1.9; font-size: 1.02rem; }
.highlighted p { margin: 0 0 1em; }
.hl { border-radius: 4px; padding: 1px 2px; cursor: help; }
.hl-web { background: var(--danger-soft); border-bottom: 2px solid var(--danger); }
.hl-local { background: var(--warn-soft); border-bottom: 2px solid var(--warn); }
.legend { display: flex; gap: 8px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.tag-web { background: var(--danger-soft); color: var(--danger); border-color: #f3c4c4; }
.tag-local { background: var(--warn-soft); color: var(--warn); border-color: #f7dcae; }
.tag-ok { background: var(--success-soft); color: var(--success); border-color: #b7e6d3; }

.sources { list-style: none; padding: 0; margin: 0; }
.sources li { padding: 12px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.sources li:first-child { border-top: 0; }
.sources a, .sources strong { word-break: break-word; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
summary { cursor: pointer; }
.full-text { margin-top: 10px; padding: 12px; background: var(--bg); border-radius: 8px; font-size: .9rem; }
.score-pill { font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.score-pill.low { background: var(--success-soft); color: var(--success); }
.score-pill.mid { background: var(--warn-soft); color: var(--warn); }
.score-pill.high { background: var(--danger-soft); color: var(--danger); }
.actions { white-space: nowrap; }
.actions form { margin-right: 4px; }

/* Auth */
.auth { max-width: 420px; margin: 20px auto; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Admin */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.tabs a { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tabs a.active { background: var(--primary-soft); color: var(--primary); }
.tabs a:hover { text-decoration: none; background: var(--bg); }
.tabs.small { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 4px; }
.api-status { list-style: none; padding: 0; margin: 0; }
.api-status li { padding: 6px 0; display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.on { background: var(--success); }
.dot.off { background: var(--danger); }

/* Admin settings */
.settings h3 { font-size: 1rem; margin: 22px 0 8px; }
.providers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.provider { margin: 0; }
.provider input { position: absolute; opacity: 0; pointer-events: none; }
.provider-box { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 400; }
.provider input:checked + .provider-box { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.provider input:focus-visible + .provider-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.provider-panel { border-top: 1px solid var(--border); margin-top: 18px; }
.guide { padding-left: 20px; margin: 0 0 16px; }
.guide li { margin-bottom: 6px; }
.secret { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: .9rem; color: var(--muted); margin-top: -6px; }
.secret input { margin-top: 0; font-family: ui-monospace, Consolas, monospace; }
input[type=number], input.narrow { display: block; margin-top: 6px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font: inherit; max-width: 280px; width: 100%; }

/* System check */
.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); }
.checklist li:first-child { border-top: 0; }
.check-icon { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: #fff; }
.check-icon.pass { background: var(--success); }
.check-icon.fail { background: var(--danger); }
.check-icon.warn { background: var(--warn); }
.fail-text { color: var(--danger); }
.test-group { font-size: .95rem; margin: 18px 0 4px; color: var(--muted); }

.footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: .88rem; text-align: center; background: var(--surface); }

.footer-credit { margin-top: 4px; }
.footer-credit strong { color: var(--text); }

/* Page loading effects */
.main { animation: page-in .35s ease-out both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none; }
.page-progress-bar {
    height: 100%; width: 0; opacity: 0;
    background: linear-gradient(90deg, #818cf8, var(--primary), #c084fc);
    box-shadow: 0 0 10px rgba(79, 70, 229, .6);
}
.page-progress.active .page-progress-bar { opacity: 1; animation: progress-grow 8s cubic-bezier(.1, .7, .2, 1) forwards; }
.page-progress.done .page-progress-bar { opacity: 0; transition: width .2s ease, opacity .3s ease .2s; }
@keyframes progress-grow { 0% { width: 0; } 10% { width: 35%; } 40% { width: 65%; } 100% { width: 92%; } }

.page-overlay {
    position: fixed; inset: 0; z-index: 999; display: grid; place-items: center;
    background: rgba(245, 247, 251, .55); backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
}
.page-overlay.active { opacity: 1; visibility: visible; }
.loader-box { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.loader-spinner {
    position: absolute; inset: 0; border-radius: 50%;
    border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-right-color: #a78bfa;
    animation: spin .8s linear infinite;
}
.loader-mark {
    width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 800; animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(.88); opacity: .8; } }

@media (prefers-reduced-motion: reduce) {
    .main, .loader-spinner, .loader-mark { animation: none; }
    .page-progress.active .page-progress-bar { animation: none; width: 70%; }
}

/* Collapse the menu early: the INFO-TECH name and the admin menu need room side by side. */
@media (max-width: 1000px) {
    .nav-toggle { display: block; }
    .nav {
        display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; align-items: stretch;
        background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px 16px;
    }
    .nav-open .nav { display: flex; }
}

/* Mobile */
@media (max-width: 820px) {
    .nav-toggle { display: block; }
    .brand-tagline { font-size: .62rem; max-width: 170px; }
    .brand-logo { height: 38px; }
    .nav {
        display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column; align-items: stretch;
        background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px 16px;
    }
    .nav-open .nav { display: flex; }
    .split, .result-grid { grid-template-columns: 1fr; }
    .stats-card { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: 1.6rem; }
}
