:root {
  --profile-bg: #f8f9fc;
  --profile-surface: #ffffff;
  --profile-surface-soft: #f3f5fb;
  --profile-border: #d7dfec;
  --profile-border-strong: #b8c6e3;
  --profile-text: #1b2536;
  --profile-muted: #5e6a80;
  --profile-accent: #1f4b9a;
  --profile-accent-soft: rgba(31, 75, 154, 0.12);
  --profile-shadow: 0 12px 28px -18px rgba(31, 75, 154, 0.32);

  --history-bg: var(--profile-bg);
  --history-surface: var(--profile-surface);
  --history-surface-soft: var(--profile-surface-soft);
  --history-border: var(--profile-border);
  --history-border-strong: var(--profile-border-strong);
  --history-text: var(--profile-text);
  --history-muted: var(--profile-muted);
  --history-accent: var(--profile-accent);
  --history-accent-soft: var(--profile-accent-soft);
  --history-shadow: var(--profile-shadow);

  --settings-bg: var(--profile-bg);
  --settings-surface: var(--profile-surface);
  --settings-surface-soft: var(--profile-surface-soft);
  --settings-border: var(--profile-border);
  --settings-border-strong: var(--profile-border-strong);
  --settings-text: var(--profile-text);
  --settings-muted: var(--profile-muted);
  --settings-accent: var(--profile-accent);
  --settings-accent-soft: var(--profile-accent-soft);
  --settings-shadow: var(--profile-shadow);

  --archive-bg: var(--profile-bg);
  --archive-surface: var(--profile-surface);
  --archive-surface-soft: var(--profile-surface-soft);
  --archive-border: var(--profile-border);
  --archive-border-strong: var(--profile-border-strong);
  --archive-text: var(--profile-text);
  --archive-muted: var(--profile-muted);
  --archive-accent: var(--profile-accent);
  --archive-accent-soft: var(--profile-accent-soft);
  --archive-shadow: var(--profile-shadow);
}

[data-theme="dark"] {
  --profile-bg: #0f172a;
  --profile-surface: #1e293b;
  --profile-surface-soft: #334155;
  --profile-border: #334155;
  --profile-border-strong: #475569;
  --profile-text: #f1f5f9;
  --profile-muted: #94a3b8;
  --profile-accent: #60a5fa;
  --profile-accent-soft: rgba(96, 165, 250, 0.15);
  --profile-shadow: none;

  --history-bg: var(--profile-bg);
  --history-surface: var(--profile-surface);
  --history-surface-soft: var(--profile-surface-soft);
  --history-border: var(--profile-border);
  --history-border-strong: var(--profile-border-strong);
  --history-text: var(--profile-text);
  --history-muted: var(--profile-muted);
  --history-accent: var(--profile-accent);
  --history-accent-soft: var(--profile-accent-soft);
  --history-shadow: var(--profile-shadow);

  --settings-bg: var(--profile-bg);
  --settings-surface: var(--profile-surface);
  --settings-surface-soft: var(--profile-surface-soft);
  --settings-border: var(--profile-border);
  --settings-border-strong: var(--profile-border-strong);
  --settings-text: var(--profile-text);
  --settings-muted: var(--profile-muted);
  --settings-accent: var(--profile-accent);
  --settings-accent-soft: var(--profile-accent-soft);
  --settings-shadow: var(--profile-shadow);

  --archive-bg: var(--profile-bg);
  --archive-surface: var(--profile-surface);
  --archive-surface-soft: var(--profile-surface-soft);
  --archive-border: var(--profile-border);
  --archive-border-strong: var(--profile-border-strong);
  --archive-text: var(--profile-text);
  --archive-muted: var(--profile-muted);
  --archive-accent: var(--profile-accent);
  --archive-accent-soft: var(--profile-accent-soft);
  --archive-shadow: var(--profile-shadow);
}

.profile-page {
  min-height: 100vh;
  background: var(--profile-bg);
  padding: 1.5rem;
  overflow-x: hidden;
}

.profile-shell {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 clamp(1.5rem, 2vw, 2.75rem);
  display: grid;
  gap: 1.5rem;
}

.profile-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem 2rem;
  background: var(--profile-surface);
  border: 1px solid var(--profile-border);
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  box-shadow: var(--profile-shadow);
}

.profile-hero__intro {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--profile-accent);
}

.profile-hero__intro h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0;
  font-weight: 600;
  color: var(--profile-text);
}

.profile-hero__intro p {
  margin: 0;
  max-width: 48ch;
  font-size: 0.9rem;
  color: var(--profile-muted);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.profile-link,
.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.profile-link {
  background: transparent;
  border-color: var(--profile-border);
  color: var(--profile-accent);
}

.profile-link:hover {
  background: var(--profile-surface-soft);
}

.profile-button {
  background: var(--profile-accent);
  color: #fff;
}

.profile-button:hover {
  background: #173b7a;
}

.profile-button--ghost {
  background: var(--profile-surface);
  border-color: var(--profile-border);
  color: var(--profile-text);
}

.profile-button--ghost:hover {
  background: var(--profile-surface-soft);
}

.profile-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.profile-card {
  background: var(--profile-surface);
  border: 1px solid var(--profile-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--profile-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.profile-card__title h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--profile-text);
}

.profile-card__meta {
  font-size: 0.85rem;
  color: var(--profile-muted);
}

.profile-card__list {
  display: grid;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--profile-muted);
}

.profile-card__list strong {
  color: var(--profile-text);
}

.profile-table-section {
  display: grid;
  gap: 1rem;
}

.profile-table-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.profile-table-wrapper {
  background: var(--profile-surface);
  border: 1px solid var(--profile-border);
  border-radius: 1rem;
  box-shadow: var(--profile-shadow);
  overflow-x: auto;
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: 0.9rem;
}

.profile-table thead {
  background: var(--profile-surface-soft);
  color: var(--profile-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.profile-table th,
.profile-table td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--profile-border);
  text-align: left;
}

.profile-table tbody tr:last-child td {
  border-bottom: none;
}

.profile-table td strong {
  color: var(--profile-text);
}

.profile-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--profile-border);
  border-radius: 0.75rem;
  background: var(--profile-surface);
}

.profile-search input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--profile-text);
  font-size: 0.85rem;
  min-width: 200px;
}

.profile-search button {
  border: none;
  background: var(--profile-accent);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.profile-search button:hover {
  background: #173b7a;
}

.profile-empty {
  border: 1px dashed var(--profile-border);
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--profile-muted);
  background: var(--profile-surface);
}

.profile-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--profile-border);
  background: var(--profile-surface);
  box-shadow: var(--profile-shadow);
}

.profile-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--profile-border);
  color: var(--profile-text);
  background: var(--profile-surface-soft);
  transition: all 0.2s ease;
}

.profile-nav__link:hover {
  color: var(--profile-accent);
  border-color: var(--profile-border-strong);
}

.profile-nav__link.is-active {
  background: var(--profile-accent);
  border-color: var(--profile-accent);
  color: #fff;
}

@media (max-width: 900px) {
  .profile-hero {
    padding: 1.25rem;
  }

  .profile-actions {
    width: 100%;
  }

  .profile-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .profile-table {
    min-width: 0;
  }

  .profile-table thead {
    display: none;
  }

  .profile-table tr {
    display: block;
    border-bottom: 1px solid var(--profile-border);
  }

  .profile-table td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 1rem;
  }

  .profile-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--profile-muted);
  }
}
