:root {
  color-scheme: dark;
  --blue: #b4c5ff;
  --blue-dark: #9db3ff;
  --blue-soft: #1f2a4d;
  --on-accent: #0a1b57;
  --ink: #e8e9ee;
  --muted: #a3a6b3;
  --line: #2b2e39;
  --bg: #0b0d12;
  --card: #14161d;
  --green: #6ee7a0;
  --green-soft: #12301f;
  --orange: #fbbf5c;
  --orange-soft: #3a2a0c;
  --red: #ff9b9b;
  --red-soft: #3b1616;
  --grey-soft: #232632;
  --input-bg: #1a1c24;
  --input-border: #3a3d4a;
  --chip-bg: #232632;
  --chip-ink: #c9ccd8;
  --row-bg: #181a22;
  --btn-light-hover: #2a3866;
  --warn-star: #fbbf5c;
}
:root[data-theme="light"] {
  color-scheme: light;
  --blue: #1a56db;
  --blue-dark: #1344b0;
  --blue-soft: #e8efff;
  --on-accent: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f8fc;
  --card: #ffffff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --orange: #b45309;
  --orange-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --grey-soft: #f3f4f6;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --chip-bg: #eef2f7;
  --chip-ink: #475569;
  --row-bg: #fafbfd;
  --btn-light-hover: #d7e3ff;
  --warn-star: #d97706;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--blue); }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }

/* Top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { width: 100%; padding: 6px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--blue); color: var(--on-accent); font-size: .95rem; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .link-button { color: var(--ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: .95rem; }
.nav a:hover, .link-button:hover { background: var(--grey-soft); }
.nav a.active { color: var(--blue); background: var(--blue-soft); font-weight: 600; }
.link-button { background: none; border: 0; cursor: pointer; font-family: inherit; }
.inline-form { display: inline; margin: 0; }

/* Buttons */
.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none;
  background: var(--blue); color: var(--on-accent); font-weight: 600; font-family: inherit;
  padding: 10px 18px; border-radius: 10px; font-size: 1rem;
}
.btn:hover { background: var(--blue-dark); }
.btn-small { padding: 7px 14px; font-size: .92rem; }
.btn-light { background: var(--blue-soft); color: var(--blue); }
.btn-light:hover { background: var(--btn-light-hover); }
.btn-danger-light { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Cards and forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 12px; }
.card-narrow { max-width: 440px; margin: 24px auto; }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--input-bg);
  border: 1px solid var(--input-border); border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 14px; }
.field-hint { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.errors { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.errors ul { margin: 0; padding-left: 18px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: var(--blue-soft); color: var(--blue-dark); }

/* Landing */
.hero { text-align: center; padding: 48px 8px 24px; }
.hero h1 { font-size: 2.1rem; line-height: 1.2; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 20px; font-size: 1.05rem; }
.hero .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }

/* Filters */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; }

/* Opportunity cards */
.opp-card { display: block; text-decoration: none; color: inherit; }
.opp-card:hover { border-color: var(--blue); }
.opp-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.opp-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.opp-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; font-size: .88rem; color: var(--muted); }
.chip { display: inline-block; background: var(--chip-bg); color: var(--chip-ink); border-radius: 6px; padding: 2px 8px; font-size: .8rem; }
.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.match-high { background: var(--green-soft); color: var(--green); }
.match-mid { background: var(--orange-soft); color: var(--orange); }
.match-low { background: var(--grey-soft); color: var(--chip-ink); }
.status-pending { background: var(--orange-soft); color: var(--orange); }
.status-accepted { background: var(--green-soft); color: var(--green); }
.status-rejected { background: var(--red-soft); color: var(--red); }
.status-closed { background: var(--grey-soft); color: var(--chip-ink); }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* Detail page */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.pre { white-space: pre-wrap; word-wrap: break-word; }
.skill-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 8px; list-style: none; }
.skill-have { background: var(--green-soft); color: var(--green); border-radius: 6px; padding: 2px 8px; font-size: .85rem; }
.skill-miss { background: var(--red-soft); color: var(--red); border-radius: 6px; padding: 2px 8px; font-size: .85rem; }
.meter { width: 100%; height: 10px; accent-color: var(--blue); }
progress.meter { appearance: none; -webkit-appearance: none; border: 0; border-radius: 6px; background: var(--line); }
progress.meter::-webkit-progress-bar { background: var(--line); border-radius: 6px; }
progress.meter::-webkit-progress-value { background: var(--blue); border-radius: 6px; }
progress.meter::-moz-progress-bar { background: var(--blue); border-radius: 6px; }

/* Table-like list */
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Repeating rows (profile) */
.row-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--row-bg); }
.row-item .grid-2 { align-items: start; }
.row-actions { text-align: right; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.footer { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .85rem; padding: 14px 0; text-align: center; }

@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field-wide { grid-column: 1 / -1; }
  .grid-2, .detail-grid, .features { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.7rem; }
}

.mt { margin-top: 14px; }

pre { padding: 1rem; white-space: pre-wrap; }

/* Chat */
.chat-box { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; }
.msg-mine { align-self: flex-end; background: var(--blue-soft); }
.msg-theirs { align-self: flex-start; background: var(--grey-soft); }
.msg-meta { font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
.stars { color: var(--warn-star); letter-spacing: 1px; }

.btn-block { display: block; width: 100%; text-align: center; }

.theme-toggle { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .8rem; margin-left: 8px; }
.theme-toggle:hover { color: var(--ink); }

.nav a.btn, .nav a.btn:hover { color: var(--on-accent); }
.nav a.btn:hover { background: var(--blue-dark); }
.card > h2:first-child, .card h2:first-of-type { margin-top: 0; }

/* Public pages */
.section { margin: 44px 0; }
.section h2 { font-size: 1.5rem; margin: 0 0 .8rem; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 720px; }
.hero { text-align: left; padding: 56px 0 24px; }
.hero h1 { font-size: 2.3rem; }
.hero p { margin: 0 0 22px; max-width: 640px; }
.hero .actions { justify-content: flex-start; }
.timeline { border-left: 3px solid var(--blue-soft); margin: 0; padding: 0 0 0 18px; }
.timeline li { list-style: none; margin-bottom: 18px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--blue); }
.obj-list { padding-left: 20px; }
.obj-list li { margin-bottom: 8px; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 720px) { .hero h1 { font-size: 1.8rem; } .topbar-inner { padding: 6px 16px; } }
