*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  background: var(--bg);
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #cbd5e1;
  --text:       #1e293b;
  --muted:      #52637a;
  --brand:      #0369a1;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:         #0f172a;
  --surface:    #1e293b;
  --border:     #334155;
  --text:       #e2e8f0;
  --muted:      #94a3b8;
  --brand:      #38bdf8;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px clamp(16px, 4vw, 24px) 24px;
  transition: background 0.15s, color 0.15s;
}

header {
  display: flex;
  flex-direction: column;
  min-height: 15rem;
  width: 100%;
  max-width: 860px;
  text-align: center;
  margin-bottom: 32px;
  position: relative;
  overflow-wrap: anywhere;
}

.profile-avatar-slot { flex: 0 0 88px; }

.profile-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-avatar:not([hidden]) { display: block; }

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.profile-details { margin-top: 12px; }

.profile-details:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

header .role { color: var(--text); }

a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; text-decoration-skip-ink: none; }

.link-label {
  display: inline-block;
  max-width: 100%;
  padding: 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:is(:hover, :focus-visible),
a:is(:hover, :focus-visible) .link-label {
  text-decoration-thickness: 2px;
}

.external-link .link-label::after {
  content: "";
  display: inline-block;
  flex-shrink: 0;
  width: 0.875em;
  height: 0.875em;
  margin-inline-start: 0.25em;
  vertical-align: -0.1em;
  background-color: currentColor;
  mask: url("icons/external-link.svg") center / contain no-repeat;
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.profile-links a:focus-visible, .card a:focus-visible, footer a:focus-visible {
  outline: none;
}

.profile-links a:focus-visible .link-label,
.card a:focus-visible .link-label,
footer a:focus-visible .link-label {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
  margin-top: auto;
  padding-top: 12px;
  font-size: 14px;
}

.profile-links a, .card a, footer a, .loading a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

main { width: 100%; max-width: 860px; }

.projects-title {
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
}

.not-found-page { min-height: 100svh; }

.not-found-content {
  max-width: 520px;
  margin-block: auto;
  padding-block: 32px;
  text-align: left;
}

.not-found-code {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.not-found-content h1 {
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.not-found-message {
  margin: 16px 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.return-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  max-width: 100%;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.legal-navigation,
.legal-content {
  width: 100%;
  max-width: 720px;
}

.legal-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 720px);
  gap: 48px;
  width: 100%;
  max-width: 968px;
  align-items: start;
}

.legal-document { min-width: 0; }

.legal-contents {
  position: sticky;
  top: 24px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.5;
}

.legal-contents p {
  margin: 0 0 12px;
  min-height: 44px;
  padding-block: 10px;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 24px;
  color: var(--muted);
}

.legal-contents nav { display: grid; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px; }

.legal-contents a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

.legal-contents a:is(:hover, :focus-visible, [aria-current="location"]) {
  color: var(--brand);
}

.legal-contents a[aria-current="location"] {
  border-color: var(--brand);
}

.legal-mobile-contents { display: none; }
.legal-content h2 { scroll-margin-top: 24px; }

@media (max-width: 900px) {
  .legal-page .legal-navigation { margin-bottom: 16px; }
  .legal-layout { display: block; max-width: 720px; }
  .legal-contents { display: none; }
  .legal-mobile-contents {
    display: block;
    margin-block: 24px;
    border-block: 1px solid var(--border);
    padding-block: 4px;
    font-size: 14px;
  }
  .legal-mobile-contents summary { min-height: 44px; padding-block: 10px; cursor: pointer; }
  .legal-mobile-contents nav { display: grid; padding: 4px 3px; }
  .legal-mobile-contents a { display: flex; align-items: center; min-height: 44px; padding-block: 8px; }
}

@media print {
  .legal-layout { display: block; }
  .legal-contents, .legal-mobile-contents, .legal-navigation, .legal-page .theme-toggle { display: none; }
}

.legal-navigation {
  margin-bottom: 24px;
  font-size: 14px;
}

.legal-navigation a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  line-height: 24px;
  text-decoration: none;
}

.legal-content {
  font-size: 15px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.legal-content h1 {
  margin-bottom: 20px;
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.legal-content h2 {
  margin: 32px 0 12px;
  font-size: 20px;
  line-height: 1.4;
}

.legal-content p,
.legal-content ul {
  margin-bottom: 16px;
}

.legal-content ul {
  padding-left: 24px;
}

.legal-content li + li {
  margin-top: 12px;
}

.legal-content a[href^="http"]:not([href="https://github.myowin.dev"]):not([href="https://github.myowin.dev/"]):not([href^="https://github.myowin.dev/legal/"])::after {
  content: "";
  display: inline-block;
  width: 0.875em;
  height: 0.875em;
  margin-inline-start: 0.25em;
  vertical-align: -0.1em;
  background-color: currentColor;
  mask: url("icons/external-link.svg") center / contain no-repeat;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.theme-toggle {
  display: grid;
  place-items: center;
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-width: 44px;
  min-height: 44px;
}

.theme-icon-sun,
[data-theme="dark"] .theme-icon-moon { display: none; }

[data-theme="dark"] .theme-icon-sun { display: block; }

.theme-toggle:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.theme-toggle:focus-visible { outline-offset: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 860px;
}

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-heading {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
}

.card-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card-release { min-width: 0; font-size: 12px; }

.card-release a, .card-license a, footer a { color: var(--muted); }
.card-release a:hover, .card-license a:hover, footer a:hover { color: var(--brand); }
footer a[aria-current="page"] { color: var(--brand); }

.card-status {
  margin-inline-start: auto;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  margin-top: auto;
  padding-top: 4px;
}

.card-license { min-width: 0; font-size: 12px; }

.loading {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.project-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  text-align: center;
}

.project-controls p:empty { display: none; }

.load-more {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 10px 20px;
  min-height: 44px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.load-more:hover:not([aria-disabled="true"]) { border-color: var(--brand); }

.load-more:focus-visible {
  border-color: var(--brand);
  outline: 2px solid var(--brand);
  outline-offset: 0;
}

.load-more[aria-busy="true"][data-loading-visible="true"] { cursor: progress; color: transparent; }

.load-more[aria-busy="true"][data-loading-visible="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text);
  border-right-color: transparent;
  border-radius: 50%;
  animation: loading-spin 0.7s linear infinite;
}

@keyframes loading-spin { to { transform: rotate(360deg); } }

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 20px;
  width: 100%;
  max-width: 860px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.not-found-page footer { max-width: 520px; }
.legal-page footer { max-width: 720px; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 20px;
  margin-inline-start: auto;
}

@media (prefers-reduced-motion: reduce) {
  body, .theme-toggle { transition: none; }
  .load-more[aria-busy="true"][data-loading-visible="true"]::after { animation: none; }
}

@media (max-width: 600px) {
  header { min-height: 19rem; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  header h1 { font-size: 20px; }
}

@media (min-width: 601px) {
  body { padding-bottom: 32px; }
  header { margin-bottom: 48px; }
  footer { margin-top: 48px; }
}
