:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --line: #d8ded8;
  --text: #1f2a27;
  --muted: #62706b;
  --primary: #126e5a;
  --primary-dark: #0a4b3e;
  --accent: #b65c32;
  --warn: #a73f3f;
  --blue: #315f9d;
  --shadow: 0 1px 2px rgba(22, 32, 28, 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

button.secondary {
  background: #fff;
  color: var(--primary-dark);
}

button.warn {
  border-color: var(--warn);
  background: var(--warn);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px;
}

.loading {
  padding: 32px;
  color: var(--muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
}

.brand span {
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wide {
  grid-column: 1 / -1;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.status {
  display: inline-block;
  min-width: 68px;
  border-radius: 999px;
  padding: 3px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 750;
}

.status-draft {
  background: #edf0f2;
  color: #4b5563;
}

.status-published {
  background: #e3f3ee;
  color: var(--primary-dark);
}

.status-archived {
  background: #f5e7e3;
  color: #87412e;
}

.notice {
  border-left: 4px solid var(--accent);
  background: #fff8f2;
  padding: 10px 12px;
  color: #5f3b25;
  font-size: 14px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login .panel {
  width: min(420px, 100%);
}

.player {
  display: grid;
  gap: 10px;
}

.sim-frame {
  width: 100%;
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.student-layout {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.review-list,
.sim-list,
.subject-tabs {
  display: grid;
  gap: 8px;
}

.login-tabs {
  margin: 12px 0;
}

.item-button,
.tab-button {
  width: 100%;
  min-height: 42px;
  text-align: left;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.item-button.active,
.tab-button.active {
  border-color: var(--primary);
  background: var(--surface-2);
}

.sim-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.sim-row .item-button {
  flex: 1;
}

.sim-row button.small {
  flex: 0 0 auto;
  align-self: center;
  padding: 6px 10px;
  font-size: 12px;
}

.sim-row button.small.assigned {
  opacity: 0.6;
  cursor: default;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(33, 33, 33, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 1000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.deck-list {
  display: grid;
  gap: 8px;
}

.deck-row,
.study-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.deck-row {
  background: var(--surface-2);
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.stats-strip span,
.card-type {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.study-card {
  display: grid;
  gap: 12px;
}

.card-front {
  font-size: 18px;
  line-height: 1.55;
  font-weight: 750;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  font-weight: 500;
}

.choice input {
  width: auto;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sim-frame.compact {
  min-height: 380px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 0;
}

.error {
  color: var(--warn);
  font-size: 14px;
  min-height: 20px;
}

@media (max-width: 860px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .student-layout,
  .split {
    grid-template-columns: 1fr;
  }

  .sim-frame {
    min-height: 430px;
  }

  .rating-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
