:root {
  color-scheme: dark;
  --background: #081117;
  --surface: #091a24;
  --card: #0a1720;
  --surface-hover: #102631;
  --text: #f4f0e7;
  --muted: #c5d4dd;
  --border: #244454;
  --accent: #e5bd52;
  --accent-ink: #20180f;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

a { color: inherit; }
.site-shell { display: flex; flex-direction: column; width: min(100% - 40px, 1160px); min-height: 100vh; margin: 0 auto; }
.site-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 29px 0 0; }
.brand { grid-column: 2; color: var(--accent); font-size: .82rem; font-weight: 850; letter-spacing: .1em; text-decoration: none; }
.header-controls { grid-column: 3; display: flex; align-items: center; justify-self: end; gap: 9px; }
.language-switch { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font: .68rem/1 monospace; letter-spacing: .08em; }
.language-switch a, .language-switch span { display: block; padding: 2px 9px; border-radius: 999px; text-decoration: none; }
.language-switch a { color: var(--text); }
.language-switch a:hover { background: var(--surface-hover); color: var(--accent); }
.language-switch [aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.theme-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme-switch button { display: grid; place-items: center; width: 25px; padding: 0; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
.theme-switch button::before { width: 11px; height: 11px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; content: ""; }
.theme-switch button:hover, .theme-switch button[aria-pressed="true"] { background: var(--surface-hover); }
.theme-switch button[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--text); }
.theme-switch [data-theme="blue"]::before { background: #e5bd52; }
.theme-switch [data-theme="green"]::before { background: #d9ff51; }
.theme-switch [data-theme="brown"]::before { background: #c8895a; }
html[data-theme="green"] { --background: #0b1514; --surface: #12211f; --card: #0e1c1b; --surface-hover: #18312d; --muted: #c5d2ce; --border: #25413d; --accent: #d9ff51; --accent-ink: #0b1514; }
html[data-theme="brown"] { --background: #17110c; --surface: #241a12; --card: #1e160f; --surface-hover: #2c2017; --text: #efe4d7; --muted: #b7a48f; --border: #362619; --accent: #c8895a; --accent-ink: #1c130d; }
main { padding: 0 0 88px; }
.intro { display: grid; place-content: center; width: 100%; min-height: min(56svh, 560px); margin: 0 auto; padding: 70px 0 26px; text-align: center; }
h1, h2, p { margin-top: 0; }
h1, .app-card h2, .legal-page h1, .legal-page h2 {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-weight: 850;
  letter-spacing: -.065em;
  line-height: .98;
}
h1 { margin-bottom: 18px; font-size: clamp(3.4rem, 8vw, 6.5rem); }
.intro h1 { margin-inline: auto; text-align: center; white-space: nowrap; }
.intro p { max-width: 560px; margin-inline: auto; color: var(--accent); font-size: clamp(.92rem, 1.5vw, 1rem); }

.project-filters { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 0 0 34px; }
.project-filters { display: none; }
.project-filters button { padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); cursor: pointer; font: 700 .7rem/1 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.project-filters button:hover { color: var(--text); border-color: var(--accent); }
.project-filters button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.app-card {
  display: flex;
  flex-direction: column;
  min-height: 210px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}
.app-card:hover { border-color: #56606b; background: var(--surface-hover); transform: translateY(-3px); }
.app-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.app-type { color: var(--accent); font-size: .75rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.app-card h2 { margin: 22px 0 8px; font-size: 1.38rem; }
.app-card p { margin-bottom: 20px; color: var(--muted); font-size: .93rem; }
.card-link { margin-top: auto; font-weight: 700; }

.site-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: auto; padding: 26px 0 34px; border-top: 1px solid var(--border); color: #849591; font-size: .78rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 20px; }
.site-footer a:hover { color: var(--accent); }

.legal-page main { max-width: 760px; padding-top: 82px; }
.legal-page .site-header { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.legal-page .language-switch { grid-column: 3; width: max-content; justify-self: end; align-self: center; }
.legal-page h1 { font-size: clamp(3rem, 7vw, 5.4rem); margin-bottom: 42px; }
.legal-page h2 { margin: 48px 0 12px; font-size: clamp(1.65rem, 3vw, 2.2rem); }
.legal-page p, .legal-page li { color: var(--muted); }
.legal-page ul { padding-left: 20px; }
.notice { padding: 18px 20px; border-left: 3px solid var(--accent); border-radius: 0; background: var(--surface); color: var(--text) !important; }

@media (max-width: 620px) {
  .site-shell { width: min(100% - 32px, 1160px); }
  .site-header { padding-top: 24px; }
  main { padding-bottom: 62px; }
  .intro { min-height: min(53svh, 440px); padding: 54px 0 28px; }
  .intro h1 { white-space: normal; }
  .project-filters { margin-bottom: 28px; }
  .app-grid { grid-template-columns: 1fr; gap: 18px; }
  .app-card { min-height: 220px; padding: 25px; }
  .site-footer { align-items: flex-start; flex-direction: column; padding-bottom: 26px; }
}

@media (prefers-reduced-motion: reduce) { .app-card { transition: none; } }
