:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #626a73;
  --line: #d7dce2;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --accent: #246b5f;
  --accent-strong: #184e46;
  --blue: #315f96;
  --red: #a94743;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ghost-link {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
}

.ghost-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 20px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.check-label {
  align-items: start;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
}

.check-label input {
  margin-top: 3px;
  width: auto;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin-bottom: 4px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
}

.topbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.auth-grid,
.app-grid {
  display: grid;
  gap: 18px;
}

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

.app-grid {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

.welcome-panel,
.panel,
.side-panel,
.lesson-panel,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.panel,
.lesson-form {
  display: grid;
  gap: 14px;
}

.welcome-panel {
  margin-bottom: 18px;
}

.welcome-panel p {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.62;
  margin-bottom: 14px;
  max-width: 74ch;
}

.welcome-panel p:last-child {
  margin-bottom: 0;
}

.lesson-panel {
  min-height: 460px;
}

.privacy-panel,
.topics-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 920px;
  padding: 26px;
}

.privacy-panel p,
.topics-panel p {
  font-size: 18px;
  line-height: 1.62;
  margin-bottom: 16px;
}

.privacy-panel p:last-child,
.topics-panel p:last-child {
  margin-bottom: 0;
}

.privacy-panel a {
  color: var(--accent);
}

.topics-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 22px;
  overflow: hidden;
}

.topics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 18px;
  padding: 13px 14px;
  border-top: 1px solid var(--line);
}

.topics-row:first-child {
  border-top: 0;
}

.topics-heading {
  background: #eef3f0;
  font-weight: 700;
}

.topics-row span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lesson-meta,
.feedback-row,
.lesson-actions,
.admin-header,
.admin-actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lesson-meta,
.admin-header {
  justify-content: space-between;
}

.lesson-meta span,
#accountText,
#message {
  color: var(--muted);
}

#lessonTitle {
  font-size: 34px;
  line-height: 1.12;
  margin: 22px 0 16px;
}

#lessonBody p {
  font-size: 19px;
  line-height: 1.7;
  margin-bottom: 18px;
  max-width: 70ch;
  white-space: pre-wrap;
}

#lessonBody p:last-child {
  margin-bottom: 0;
}

.lesson-actions {
  margin-top: 28px;
}

.feedback-row {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.side-panel h2,
.admin-panel h2 {
  font-size: 20px;
}

.side-link {
  border-top: 1px solid var(--line);
  color: var(--accent);
  display: block;
  margin-top: 18px;
  padding-top: 16px;
  text-decoration: none;
}

.side-link:hover {
  text-decoration: underline;
}

.reminder-setting {
  border-top: 1px solid var(--line);
  color: var(--ink);
  margin-top: 16px;
  padding-top: 16px;
}

.admin-panel {
  grid-column: 1 / -1;
}

.admin-test-form {
  max-width: 520px;
  margin-bottom: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

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

.stat strong {
  display: block;
  font-size: 26px;
}

.table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 1.4fr .7fr .7fr .7fr;
  gap: 12px;
  padding: 11px 12px;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
  background: #eef3f0;
  font-weight: 700;
}

.feedback-admin-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 70px 70px;
  gap: 12px;
  padding: 11px 12px;
  border-top: 1px solid var(--line);
}

.feedback-admin-row:first-child {
  border-top: 0;
}

.feedback-admin-heading {
  background: #eef3f0;
  font-weight: 700;
}

.feedback-admin-empty {
  color: var(--muted);
  padding: 14px 12px;
  border-top: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

#message {
  min-height: 24px;
  margin-top: 18px;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  margin-top: 30px;
  padding-top: 18px;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.selected-up {
  background: var(--blue);
}

.selected-down {
  background: var(--red);
}

@media (max-width: 780px) {
  .auth-grid,
  .app-grid,
  .stat-grid,
  .topics-row,
  .feedback-admin-row {
    grid-template-columns: 1fr;
  }

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

  #lessonTitle {
    font-size: 28px;
  }

  .row {
    grid-template-columns: 1fr;
  }
}
