:root {
  --bg: #f4f1ea;
  --bg-top: #ffffff;
  --surface: #ffffff;
  --ink: #1d2433;
  --accent: #0d6e6e;
  --accent-soft: #d9efef;
  --danger: #9c2f2f;
  --line: #d5dce5;
  --subtle: #4e5768;
  --link: #1a4b80;
  --topbar-bg: #ffffff;
  --hero-start: #ffffff;
  --hero-end: #eef8f8;
}

html[data-theme='light'] {
  color-scheme: light;
}

html[data-theme='dark'] {
  --bg: #0f1520;
  --bg-top: #141d2a;
  --surface: #1a2433;
  --ink: #e8eef8;
  --accent: #1c8d8d;
  --accent-soft: #24384b;
  --danger: #ff7d7d;
  --line: #2d3a4d;
  --subtle: #9fb0c8;
  --link: #8fb8ff;
  --topbar-bg: #121a26;
  --hero-start: #182332;
  --hero-end: #1a2f3b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, var(--bg-top), var(--bg));
  color: var(--ink);
}

.container {
  width: min(1080px, 92%);
  margin: 0 auto;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
}

.nav-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-links a { color: var(--ink); text-decoration: none; }

.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.main-content {
  padding: 24px 0 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}

.narrow { max-width: 520px; margin-inline: auto; }

.hero { background: linear-gradient(140deg, var(--hero-start), var(--hero-end)); }

.grid {
  display: grid;
  gap: 12px;
}

.grid.five { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.tile {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
}

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

.profile-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
}

.media-card img {
  aspect-ratio: auto;
  max-height: 280px;
}

.profile-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #eef2f8;
}

.profile-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.profile-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  background: #eef2f8;
}

.stack-form {
  display: grid;
  gap: 8px;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

.search-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 8px;
}

.search-row input,
.search-row select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.alt { background: #35597a; }
.btn.small { padding: 7px 10px; font-size: 14px; }

.inline-form { display: inline; }
.link-button {
  border: none;
  background: transparent;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.link-button.danger { color: var(--danger); }

.flash {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid;
}

.flash.success,
.notice.success {
  border-color: #97d6a7;
  background: #e9f8ed;
  color: #1b5f2f;
}

.flash.error {
  border-color: #e8aaaa;
  background: #fdeeee;
  color: #7a1e1e;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.message-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.message-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.message-author-photo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #eef2f8;
}

.message-card-content {
  display: grid;
  gap: 4px;
}

.class-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--ink);
}

.chip.active { background: var(--accent-soft); border-color: #94c8c8; }

.class-tree {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.class-tree li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th,
table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.subtle { color: var(--subtle); }
.compact-top { margin-top: 12px; }
.status { font-weight: 600; color: var(--subtle); }
.checkbox-line { display: flex; align-items: center; gap: 8px; }

@media (max-width: 700px) {
  .profile-head { flex-direction: column; }
  .profile-photo { width: 120px; height: 120px; }
  .topbar-inner { flex-direction: column; padding: 10px 0; gap: 8px; }
  .topbar-actions { flex-direction: column; width: 100%; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .search-row { grid-template-columns: 1fr; }
}
