:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --ink: #172033;
    --muted: #667085;
    --line: #dce3ec;
    --primary: #175cd3;
    --primary-dark: #1849a9;
    --success: #067647;
    --danger: #b42318;
    --warning: #b54708;
    --shadow: 0 12px 32px rgba(16, 24, 40, .08);
    --radius: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
code { padding: .1rem .35rem; border-radius: 5px; background: #edf2f7; font-size: .9em; }
.container { width: min(1220px, calc(100% - 36px)); margin-inline: auto; }
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: var(--muted); font-size: .7rem; margin-top: 3px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(135deg,#175cd3,#7f56d9); font-weight: 800; box-shadow: 0 6px 15px rgba(23,92,211,.28); }
.brand-mark.large { width: 58px; height: 58px; border-radius: 16px; font-size: 1.6rem; margin-inline: auto; }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.inline-form { display: inline; margin: 0; }
.main-content { min-height: calc(100vh - 155px); padding-block: 34px 60px; }
.footer { color: var(--muted); border-top: 1px solid var(--line); background: #fff; font-size: .86rem; text-align: center; padding: 22px 0; }
h1,h2,h3,h4 { line-height: 1.22; margin-top: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 3rem); letter-spacing: -.035em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.05rem; }
p { margin-top: 0; }
.muted { color: var(--muted); }
.eyebrow { display: inline-block; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .13em; margin-bottom: 7px; }
.button { border: 1px solid transparent; border-radius: 10px; padding: .72rem 1rem; font: inherit; font-weight: 700; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 7px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--primary); color: #fff; box-shadow: 0 6px 14px rgba(23,92,211,.2); }
.button.primary:hover { background: var(--primary-dark); color: #fff; }
.button.secondary { background: #eaf2ff; color: var(--primary-dark); border-color: #c9dcff; }
.button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.button.danger { background: #fff0ee; color: var(--danger); border-color: #fecdca; }
.button.small { padding: .5rem .72rem; font-size: .86rem; border-radius: 8px; }
.button.full { width: 100%; }
.notice, .flash { border: 1px solid; border-radius: 11px; padding: 12px 15px; margin-bottom: 18px; }
.notice.warning { color: #7a2e0e; background: #fff7ed; border-color: #fed7aa; }
.flash.success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }
.flash.danger { color: #912018; background: #fef3f2; border-color: #fecdca; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 34px; color: #fff; border-radius: 22px; background: radial-gradient(circle at top right, rgba(255,255,255,.18), transparent 30%), linear-gradient(125deg,#0b4db7,#53389e); box-shadow: var(--shadow); }
.hero.compact h1 { max-width: 780px; margin-bottom: 10px; }
.hero p { color: #e7efff; max-width: 760px; margin-bottom: 0; }
.hero .eyebrow { color: #cfe0ff; }
.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin: 22px 0 34px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; box-shadow: 0 5px 18px rgba(16,24,40,.04); }
.stat-card span { color: var(--muted); font-size: .84rem; }
.stat-card strong { font-size: 1.65rem; }
.stat-card .small-value { font-size: 1rem; margin-top: 8px; }
.status-good { color: var(--success); }
.status-bad { color: var(--danger); }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 34px 0 14px; }
.section-heading h2, .section-heading p { margin-bottom: 2px; }
.project-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.project-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 6px 18px rgba(16,24,40,.045); display: flex; flex-direction: column; min-height: 310px; }
.project-card h3 { margin: 18px 0 8px; font-size: 1.12rem; }
.project-card p { color: var(--muted); flex: 1; }
.project-card-top { display: flex; align-items: center; justify-content: space-between; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 4px #d1fadf; }
.badge { display: inline-flex; border-radius: 999px; padding: .3rem .62rem; background: #eaf2ff; color: var(--primary-dark); font-size: .76rem; font-weight: 800; }
.badge.large { font-size: .82rem; white-space: nowrap; }
.meta-list { margin: 12px 0 18px; display: grid; gap: 7px; }
.meta-list div { display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; text-align: right; font-weight: 650; }
.card-actions { display: flex; gap: 8px; }
.empty-state { padding: 70px 25px; text-align: center; border: 1px dashed #b9c6d6; border-radius: 18px; background: rgba(255,255,255,.72); }
.empty-state.small { padding: 45px 22px; }
.empty-icon { width: 62px; height: 62px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 18px; color: var(--primary); background: #eaf2ff; font-weight: 900; font-size: 1.25rem; }
.auth-shell { min-height: 68vh; display: grid; place-items: center; }
.auth-card { width: min(440px,100%); padding: 30px; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.stack-form { display: grid; gap: 15px; text-align: left; margin-top: 22px; }
label { display: flex; flex-direction: column; gap: 7px; font-size: .88rem; font-weight: 700; color: #344054; }
label b { color: var(--danger); }
input, select, textarea { width: 100%; border: 1px solid #cfd8e3; border-radius: 9px; padding: .76rem .82rem; background: #fff; color: var(--ink); font: inherit; font-weight: 400; outline: none; transition: .15s ease; }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus,select:focus,textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px #e8f0ff; }
label small { color: var(--muted); font-weight: 400; }
.page-header, .project-header { display: flex; justify-content: space-between; gap: 25px; align-items: flex-start; margin-bottom: 24px; }
.page-header h1 { margin: 5px 0 8px; }
.page-header p { color: var(--muted); max-width: 760px; }
.back-link { color: var(--muted); font-size: .86rem; font-weight: 700; }
.project-form { display: grid; gap: 20px; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 6px 18px rgba(16,24,40,.035); }
.form-card-heading { display: flex; gap: 13px; border-bottom: 1px solid var(--line); padding-bottom: 17px; margin-bottom: 20px; }
.form-card-heading > span { flex: 0 0 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--primary); font-weight: 800; }
.form-card-heading h2 { margin-bottom: 2px; }
.form-card-heading p { color: var(--muted); margin-bottom: 0; }
.form-grid { display: grid; gap: 18px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid .full { grid-column: 1/-1; }
.profile-preview { grid-column: 1/-1; padding: 15px; border-radius: 11px; background: #f5f8fc; border: 1px solid var(--line); color: #344054; font-size: .88rem; }
.profile-preview ul { margin: 8px 0 0; padding-left: 19px; }
.source-present { color: var(--success); font-size: .8rem; }
.form-submit-bar { position: sticky; bottom: 12px; z-index: 20; display: flex; justify-content: flex-end; gap: 10px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.project-header h1 { font-size: clamp(1.7rem,3vw,2.5rem); margin: 6px 0 9px; }
.project-header > div:first-child { max-width: 850px; }
.title-row { display: flex; align-items: flex-start; gap: 12px; }
.header-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.header-meta span { background: #fff; border: 1px solid var(--line); padding: .32rem .58rem; border-radius: 8px; color: #475467; font-size: .78rem; }
.header-actions { display: flex; gap: 9px; }
.workflow-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.workflow-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.workflow-card p { color: var(--muted); font-size: .78rem; margin: 2px 0 0; }
.step-number { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: #eaf2ff; color: var(--primary); font-weight: 900; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { padding: 12px 15px; color: var(--muted); font-weight: 750; white-space: nowrap; border-bottom: 3px solid transparent; }
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab-panel { padding-top: 22px; }
.overview-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.content-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 19px; }
.content-card h3 { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.content-card ul, .content-card ol { padding-left: 20px; }
.preserve-text { white-space: pre-wrap; color: #475467; }
.danger-zone { margin-top: 28px; padding: 18px; border: 1px solid #fecdca; background: #fff7f6; border-radius: 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-zone h3, .danger-zone p { margin-bottom: 3px; }
.score-panel { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 22px; padding: 24px; border-radius: 18px; color: #fff; background: linear-gradient(125deg,#163d8d,#53389e); }
.score-panel p { color: #e6ecff; margin-bottom: 0; }
.score-panel .eyebrow { color: #cbd9ff; }
.score-ring { width: 112px; height: 112px; border-radius: 50%; border: 9px solid rgba(255,255,255,.22); display: flex; justify-content: center; align-items: baseline; flex-direction: column; text-align: center; }
.score-ring strong { font-size: 2.4rem; line-height: 1; margin-inline: auto; }
.score-ring span { font-size: .75rem; margin-inline: auto; opacity: .8; }
.analysis-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; margin-top: 16px; }
.analysis-columns.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.check-list li::marker { color: var(--success); }
.alert-list li::marker { color: var(--danger); }
.assessment-list { display: grid; gap: 13px; }
.assessment-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.assessment-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.assessment-head h3 { margin-bottom: 2px; }
.assessment-head span { color: var(--muted); font-size: .8rem; }
.assessment-head > strong { font-size: 1.5rem; color: var(--primary); }
.progress { height: 7px; border-radius: 99px; background: #e7edf4; overflow: hidden; margin: 12px 0; }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#175cd3,#7f56d9); }
.assessment-body { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; font-size: .88rem; }
.assessment-body h4 { margin-bottom: 4px; }
.assessment-body ul { margin: 0; padding-left: 18px; }
.editor-layout { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: 16px; align-items: start; }
.editor-card, .preview-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.editor-card { position: sticky; top: 88px; }
.editor-head { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.editor-head h2, .editor-head p { margin-bottom: 0; }
.editor-head p { color: var(--muted); font-size: .8rem; }
.markdown-editor { border: 0; border-radius: 0; min-height: 650px; padding: 18px; font-family: "SFMono-Regular",Consolas,monospace; font-size: .84rem; }
.article-render { padding: 25px; font-family: Georgia,"Times New Roman",serif; color: #1d2939; overflow-x: auto; }
.article-render h1 { font-size: 1.8rem; }
.article-render h2 { font-size: 1.35rem; border-bottom: 1px solid #e4e7ec; padding-bottom: 7px; margin-top: 28px; }
.article-render h3 { margin-top: 22px; }
.article-render table { width: 100%; border-collapse: collapse; margin: 15px 0; font-size: .88rem; }
.article-render th,.article-render td { border: 1px solid #d0d5dd; padding: 8px; text-align: left; vertical-align: top; }
.article-render th { background: #f2f4f7; }
.loading-overlay[hidden] { display: none; }
.loading-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(16,24,40,.68); backdrop-filter: blur(4px); }
.loading-card { width: min(390px,calc(100% - 32px)); padding: 28px; border-radius: 18px; background: #fff; text-align: center; box-shadow: var(--shadow); }
.loading-card p { color: var(--muted); margin-bottom: 0; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid #dbe7fb; border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 0 auto 15px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 980px) {
    .project-grid,.workflow-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .editor-layout { grid-template-columns: 1fr; }
    .editor-card { position: static; }
    .analysis-columns.three { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .container { width: min(100% - 24px,1220px); }
    .topbar-inner { min-height: 60px; }
    .brand small,.nav-actions > a:first-child { display: none; }
    .hero,.page-header,.project-header,.danger-zone { flex-direction: column; align-items: stretch; }
    .hero { padding: 25px; }
    .stats-grid,.project-grid,.workflow-grid,.overview-grid,.analysis-columns,.assessment-body,.form-grid.two { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .title-row { flex-direction: column; }
    .header-actions { flex-wrap: wrap; }
    .score-panel { grid-template-columns: 1fr; text-align: center; }
    .score-ring { margin-inline: auto; }
    .workflow-card { grid-template-columns: auto 1fr; }
    .workflow-card button { grid-column: 1/-1; width: 100%; }
    .form-card { padding: 18px; }
    .form-submit-bar { justify-content: stretch; }
    .form-submit-bar .button { flex: 1; }
}


button:disabled, .button:disabled { opacity: .5; cursor: not-allowed; }
.config-warning { margin-bottom: 18px; padding: 16px 18px; border: 1px solid #f7c56b; border-radius: 14px; background: #fffaeb; color: #7a4d00; }
.config-warning p { margin: 5px 0 0; }
.config-warning code { background: rgba(122,77,0,.08); padding: .12rem .3rem; border-radius: 5px; }
.scholar-search-form { display: grid; grid-template-columns: minmax(260px,2fr) repeat(3,minmax(120px,.55fr)) auto; gap: 14px; align-items: end; margin-bottom: 20px; }
.scholar-query-field { min-width: 0; }
.scholar-search-form .button { min-height: 45px; }
.scholar-help { grid-column: 1/-1; color: var(--muted); font-size: .8rem; margin: -2px 0 0; }
.scholar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 22px 0 14px; }
.scholar-toolbar h2, .scholar-toolbar p { margin-bottom: 3px; }
.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scholar-analysis-card { margin-bottom: 16px; }
.bibliography-card { margin-bottom: 16px; }
.bibliography-card ol { display: grid; gap: 12px; }
.bibliography-entry { white-space: pre-wrap; }
.verification-badge { display: inline-block; margin-top: 5px; padding: .2rem .45rem; border-radius: 999px; background: #fff1f0; color: #b42318; font-size: .72rem; font-weight: 800; }
.scholar-results { display: grid; gap: 14px; }
.scholar-result { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.scholar-result-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.scholar-result-head h3 { margin-bottom: 3px; }
.scholar-result-head h3 a { color: var(--primary); }
.reference-id { width: 42px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: #eaf2ff; color: var(--primary); font-weight: 900; font-size: .8rem; }
.scholar-meta { color: var(--muted); font-size: .82rem; margin-bottom: 0; }
.citation-count { white-space: nowrap; padding: .28rem .55rem; border-radius: 999px; background: #f2f4f7; color: #475467; font-size: .74rem; font-weight: 750; }
.citation-box { margin-top: 13px; padding: 13px 14px; border-radius: 11px; background: #f8fafc; border: 1px solid var(--line); }
.citation-box strong { display: block; margin-bottom: 4px; }
.citation-box small { display: block; margin-top: 6px; color: #b42318; }
.resource-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.resource-links a { padding: .3rem .55rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: .76rem; font-weight: 700; }
@media (max-width: 1100px) {
    .workflow-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .scholar-search-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .scholar-query-field, .scholar-help { grid-column: 1/-1; }
}
@media (max-width: 720px) {
    .scholar-search-form { grid-template-columns: 1fr; }
    .scholar-query-field, .scholar-help { grid-column: auto; }
    .scholar-toolbar { flex-direction: column; align-items: stretch; }
    .scholar-result-head { grid-template-columns: auto 1fr; }
    .citation-count { grid-column: 2; justify-self: start; }
}
