:root {
  --bg: #0e1116;
  --surface: #151a21;
  --surface-2: #1b212a;
  --border: #262d38;
  --text: #d7dde6;
  --text-strong: #f2f5f9;
  --muted: #8b95a5;
  --accent: #c9d1dc;
  --accent-text: #0e1116;
  --danger: #d98080;
  --ok: #7fb89a;
  --radius: 6px;
  --font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Forge: repository browser and contributor workspace */
.forge-shell { max-width: 1160px; }
.forge-shell h1 { margin-top: 18px; }
.forge-toolbar { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 14px; align-items: end; padding: 24px 0; margin-top: 24px; border-top: 1px solid var(--border); }
.forge-toolbar .field { margin: 0; }
.forge-grid { margin-top: 20px; grid-template-columns: repeat(auto-fill,minmax(290px,1fr)); }
.project-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.project-card .eyebrow { margin: 0 !important; }
.project-card p { overflow-wrap: anywhere; }
.project-title { font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.forge-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }
.project-card .forge-meta { margin-top: auto; }
.forge-empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px; color: var(--muted); margin: 20px 0; grid-column: 1 / -1; }
.forge-prose, .forge-readme { white-space: pre-wrap; overflow-wrap: anywhere; }
.forge-readme { font: inherit; line-height: 1.8; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.forge-code { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .87rem; padding: 20px; margin: 0; background: var(--bg); }
.forge-shell details { border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.forge-shell summary { padding: 14px 20px; cursor: pointer; background: var(--surface-2); overflow-wrap: anywhere; }
.forge-status { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); margin: 12px 0; }
.forge-status p { width: 100%; }
.issue-card { margin: 18px 0; }
.issue-card h3 { margin-top: 14px; }
.issue-card .btn + .btn { margin-left: 8px; }
.forge-file-editor { padding: 20px; margin: 16px 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.forge-file-editor textarea { font-family: Consolas, monospace; }
.forge-shell .check { margin: 24px 0 12px; }
.forge-shell form > .btn[type=submit] { margin-top: 20px; display: block; }
.forge-toolbar > .btn[type=submit] { margin: 0 !important; }
.forge-account-banner { margin-bottom: 24px; }
.forge-account-banner h2 { margin-top: 0; }
.subnav button.active { color: var(--text-strong); border-bottom: 2px solid var(--accent); }
.forge-shell .subnav { gap: 28px; margin-top: 32px; }
@media(max-width: 760px) {
  .forge-toolbar { grid-template-columns: 1fr 1fr; }
  .forge-toolbar .field:first-child { grid-column: 1 / -1; }
  .forge-toolbar > .btn { grid-column: 1 / -1; }
  .forge-readme { padding: 18px; }
  .site-header .container { height: auto; min-height: 64px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; }
  .nav { gap: 14px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
a:hover { text-decoration-color: var(--accent); }
h1, h2, h3 { color: var(--text-strong); font-weight: 600; line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 2.1rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; margin-top: 2em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Layout */
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 720px; }
main { flex: 1; padding: 56px 0 72px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 700; letter-spacing: .14em; text-decoration: none; font-size: .95rem; }
.brand-logo { width: 32px; height: 32px; display: block; }
.hero-logo { width: 160px; height: 160px; display: block; margin-bottom: 24px; }
.nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: .93rem; }
.nav a:hover, .nav a.active { color: var(--text-strong); }
.nav button { font-size: .93rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 56px 0 28px; font-size: .93rem; color: var(--muted); }
.footer-cols { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; }
.footer-about p { margin: 14px 0 0; max-width: 380px; line-height: 1.6; }
.footer-about .brand { font-size: 1.05rem; }
.footer-about .brand-logo { width: 40px; height: 40px; }
.footer-about .footer-tagline { color: var(--text-strong); font-weight: 600; }
.footer-col { display: flex; flex-direction: column; gap: 10px; }
.footer-col h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-strong); margin: 0 0 6px; }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border); font-size: .85rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text-strong); }
@media (max-width: 860px) { .footer-cols { grid-template-columns: 1fr 1fr; } .footer-about { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer-cols { grid-template-columns: 1fr; } }

/* Hero */
.hero { padding: 40px 0 24px; max-width: 720px; }
.hero h1 { font-size: 2.6rem; }
.hero p { font-size: 1.1rem; color: var(--muted); }
main.home { padding-top: 0; }
.hero-band {
  background-color: var(--bg);
  background-image: linear-gradient(90deg, rgba(14, 17, 22, .92) 0%, rgba(14, 17, 22, .6) 45%, rgba(14, 17, 22, .1) 100%), url("/assets/images/hero.jpg");
  background-size: cover;
  background-position: center right;
  border-bottom: 1px solid var(--border);
  padding: 150px 0 140px;
  min-height: 70vh;
  display: flex;
  align-items: center;
}
.hero-band > .container { width: 100%; }
.hero-band .hero { padding: 0; max-width: 640px; }
.hero-band .hero h1 { font-size: 3.2rem; }
.hero-band .hero p { color: var(--text); }
.hero-band .hero .lead { font-size: 1.2rem; }
.eyebrow { font-size: .8rem !important; text-transform: uppercase; letter-spacing: .14em; color: var(--muted) !important; margin-bottom: 18px !important; }
.home .band { padding: 72px 0 0; }
.home .band:first-child { padding-top: 80px; }
.section-title { font-size: 1.8rem; margin: 0 0 .3em; }
.section-lead { color: var(--muted); margin: 0 0 8px; font-size: 1.05rem; }
.home .grid { margin-top: 28px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.principles { list-style: none; margin: 28px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.principles li { padding: 18px 24px; border-bottom: 1px solid var(--border); color: var(--muted); }
.principles li:last-child { border-bottom: 0; }
.principles strong { color: var(--text-strong); margin-right: 6px; }
.cta { margin: 96px 0 24px; padding: 64px 24px; text-align: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cta h2 { margin: 0 0 .4em; font-size: 1.9rem; }
.cta p { color: var(--muted); }
.actions.center { justify-content: center; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }
a.card { display: block; text-decoration: none; color: var(--text); }
a.card:hover { border-color: #3a4352; }

/* Forms */
.form-card { max-width: 440px; margin: 0 auto; }
.form-card.wide { max-width: 720px; }
label { display: block; font-size: .87rem; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  background: var(--bg);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: .97rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 18px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.check { display: flex; gap: 10px; align-items: center; font-size: .93rem; color: var(--text); }
.check input { width: auto; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 20px;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #dfe5ed; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--muted); background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: #4a2f33; }
.btn.small { padding: 5px 11px; font-size: .84rem; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-family: inherit; }
.link-btn:hover { color: var(--text-strong); }

.alert { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 20px; font-size: .93rem; background: var(--surface); }
.alert.error { border-left-color: var(--danger); }
.alert.success { border-left-color: var(--ok); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; border: 1px solid var(--border); border-radius: 3px; padding: 1px 8px; font-size: .78rem; color: var(--muted); }

/* Sub navigation */
.subnav { display: flex; gap: 8px; margin-bottom: 32px; border-bottom: 1px solid var(--border); }
.subnav a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-size: .93rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text-strong); }
.subnav a.active { color: var(--text-strong); border-bottom-color: var(--accent); }

dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 20px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; color: var(--text-strong); word-break: break-word; }

.legal h2 { font-size: 1.15rem; }
.legal ul { padding-left: 1.2em; }
.legal li { margin-bottom: .4em; }

/* Webmail */
.webmail-page main.wm-main { padding: 24px 0; }
.wm-container { width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 24px; }
.webmail { display: grid; grid-template-columns: 200px minmax(300px, 400px) 1fr; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); height: calc(100vh - 190px); min-height: 520px; overflow: hidden; }
.wm-side { border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; background: var(--bg); }
.wm-folders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.wm-folders button { width: 100%; display: flex; justify-content: space-between; background: none; border: 0; color: var(--muted); font: inherit; font-size: .93rem; padding: 8px 10px; border-radius: 4px; cursor: pointer; text-align: left; }
.wm-folders button:hover { background: var(--surface); color: var(--text-strong); }
.wm-folders button.active { background: var(--surface-2); color: var(--text-strong); }
.wm-folders .count { color: var(--accent); font-weight: 600; }
.wm-settings { margin-top: auto; text-align: left; font-size: .85rem; }
.wm-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.wm-toolbar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.wm-toolbar input { grid-column: 1 / -1; }
.wm-toolbar select, .wm-toolbar input { padding: 7px 10px; font-size: .88rem; }
.wm-toolbar select:first-of-type { grid-column: span 2; }
.wm-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.wm-bulk .check input { width: auto; }
.wm-messages { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.wm-row { display: grid; grid-template-columns: 20px 22px 1fr; gap: 8px; align-items: start; padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.wm-row:hover { background: var(--surface-2); }
.wm-row.current { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.wm-row input { width: auto; margin-top: 4px; }
.wm-row-body { min-width: 0; }
.wm-row-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.wm-from { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-date { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.wm-subject, .wm-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.wm-snippet { color: var(--muted); font-size: .82rem; }
.wm-row.unread .wm-from, .wm-row.unread .wm-subject { color: var(--text-strong); font-weight: 700; }
.wm-star { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1.2; }
.wm-star.on { color: #d6b36a; }
.wm-none { padding: 24px 16px; }
.wm-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: .82rem; }
.wm-reader { padding: 20px 24px; overflow-y: auto; min-width: 0; }
.wm-empty { margin-top: 24px; text-align: center; }
.wm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.wm-title { margin: 0 0 14px; font-size: 1.3rem; }
.wm-meta { display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.wm-meta dt { color: var(--muted); }
.wm-meta dd { margin: 0; color: var(--text); word-break: break-word; }
.wm-body { white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: .95rem; margin: 0; color: var(--text); }
.wm-frame { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.wm-note { font-size: .85rem; }
dialog.wm-dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 24px; }
dialog.wm-dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog.wm-dialog h2 { margin-top: 0; }

@media (max-width: 1000px) {
  .webmail { grid-template-columns: 1fr; height: auto; }
  .wm-side { border-right: 0; border-bottom: 1px solid var(--border); }
  .wm-folders { flex-direction: row; flex-wrap: wrap; }
  .wm-folders button { width: auto; gap: 8px; }
  .wm-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 60vh; }
  .wm-reader { min-height: 300px; }
}

@media (max-width: 640px) {
  .hero-band { padding: 72px 0; min-height: 0; background-image: linear-gradient(rgba(14, 17, 22, .85), rgba(14, 17, 22, .85)), url("/assets/images/hero.jpg"); }
  .hero-band .hero h1 { font-size: 2.1rem; }
  .home .band { padding-top: 48px; }
  h1, .hero h1 { font-size: 1.9rem; }
  .site-header .container { height: auto; padding-top: 14px; padding-bottom: 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 10px; }
}
