:root {
  color-scheme: light dark;
  --gap: 0.75rem;
  --border: #ccc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.4;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: var(--gap) 1rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.site-nav .brand {
  font-weight: bold;
  text-decoration: none;
}

.logout-form { margin-left: auto; }

.content {
  padding: 1rem;
  max-width: 60rem;
  margin: 0 auto;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

.button, button {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: #f5f5f5;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 32rem;
}

.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stacked-form input,
.stacked-form textarea,
.stacked-form select {
  padding: 0.6rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin: var(--gap) 0;
}

.filter-form input,
.filter-form select {
  padding: 0.5rem;
  font-size: 1rem;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(0, 0, 0, 0.05);
}

.field-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
}

.field-list dt { font-weight: bold; }
.field-list dd { margin: 0; }

.error { color: #b00020; }

.progress-bar {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  height: 0.6rem;
  overflow: hidden;
  margin: 0.3rem 0;
}

.progress-fill {
  background: #2e7d32;
  height: 100%;
}

.progress-summary { margin-bottom: 1.5rem; }

.pattern-group { margin-bottom: 1.5rem; }

.pattern-group h2 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.pattern-group .count { font-weight: normal; color: #666; }

.problem-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.problem-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.status {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-not_started { background: rgba(0, 0, 0, 0.08); }
.status-in_progress { background: #fff3cd; }
.status-mastered { background: #d4edda; }

.pattern-label { color: #666; margin-top: -0.5rem; }

.solution {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.solution pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.solution-meta {
  color: #666;
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

@media (max-width: 40rem) {
  .field-list {
    grid-template-columns: 1fr;
  }
  .field-list dt { margin-top: 0.5rem; }
}
