:root {
  color-scheme: light;
  --bg: #f4eee2;
  --paper: rgba(255, 252, 247, 0.94);
  --paper-strong: #fff9ef;
  --ink: #16212c;
  --muted: #67717b;
  --accent: #bf5b36;
  --accent-dark: #8f3818;
  --line: rgba(22, 33, 44, 0.11);
  --warning: #b45309;
  --shadow: 0 24px 50px rgba(80, 60, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(191, 91, 54, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(32, 112, 132, 0.1), transparent 26%),
    linear-gradient(140deg, #fcf7ef 0%, #f4efe3 46%, #e7e1d7 100%);
}

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

code {
  font-family: Consolas, "Courier New", monospace;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 28px auto 40px;
  display: grid;
  gap: 18px;
}

.hero,
.panel,
.notice {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.hero h1,
.panel h2,
.question-card h3,
.test-card h3,
.result-card h3 {
  margin: 0;
}

.result-card__summary {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.results-list-note {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.section-kicker {
  margin-bottom: 6px;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 720px;
  line-height: 1.65;
  color: var(--muted);
}

.hero-bases {
  margin: 14px 0 0;
  padding-left: 1.25rem;
  max-width: 720px;
  line-height: 1.65;
  color: var(--muted);
}

.hero-bases li {
  margin-top: 6px;
}

.hero-bases li:first-child {
  margin-top: 0;
}

.hero-badge {
  min-width: 240px;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(248, 239, 228, 0.86));
  border: 1px solid rgba(22, 33, 44, 0.08);
}

.hero-badge span,
.hero-badge strong,
.field span,
.hint-row,
.material-card small,
.test-card small,
.result-card small {
  display: block;
}

.hero-badge span,
.field span,
.hint-row,
.material-card small,
.test-card small,
.result-card small {
  color: var(--muted);
}

.hero-badge strong {
  margin-top: 6px;
  font-size: 20px;
}

.ghost-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

.notice {
  padding: 18px 22px;
  line-height: 1.6;
}

.notice--warning {
  color: #8a4d08;
}

.panel {
  padding: 24px;
}

.panel-header,
.panel-subheader,
.runner-header,
.card-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.button--danger-quiet {
  border: 1px solid rgba(185, 28, 28, 0.35);
  background: rgba(255, 255, 255, 0.9);
  color: #9f1239;
}

.button--danger-quiet:hover {
  border-color: rgba(185, 28, 28, 0.55);
  background: rgba(254, 242, 242, 0.95);
  color: #881337;
}

/* Readonly в модалках визуально как раньше (как обычные поля), без «серых плашек» */
.modal--work .question-card textarea[readonly] {
  background: var(--paper-strong);
  color: var(--ink);
  cursor: default;
  resize: none;
  border-color: rgba(22, 33, 44, 0.14);
}

.draft-edit-hint {
  margin: 0 0 8px;
  max-width: 52em;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.panel-header-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.tests-panel__title {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.test-settings-bar {
  margin-top: 18px;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(22, 33, 44, 0.08);
  background: rgba(255, 255, 255, 0.5);
}

.test-settings-bar__counts {
  margin: 0;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(22, 33, 44, 0.14);
  border-radius: 16px;
  background: var(--paper-strong);
  color: var(--ink);
  padding: 12px 14px;
}

textarea {
  resize: vertical;
}

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

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.material-card,
.question-card,
.test-card,
.result-card,
.runner-question,
.empty-state {
  border-radius: 20px;
  border: 1px solid rgba(22, 33, 44, 0.08);
  background: rgba(255, 255, 255, 0.74);
}

.materials-preview,
.question-editor,
.card-list,
.runner-questions {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.question-editor-scroll {
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 8px;
}

.draft-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.modal--work .draft-nav button {
  min-height: 44px;
  padding: 10px 20px;
}

.qa-layout {
  display: grid;
  grid-template-columns: minmax(0, 50%) minmax(0, 50%);
  gap: 16px;
  align-items: start;
}

.draft-entry-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.panel--tests .draft-entry-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
  align-items: stretch;
}

.draft-entry-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  padding: 22px 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  text-align: left;
  cursor: pointer;
  font: inherit;
  height: 100%;
  min-height: 7.5rem;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

/* Перебиваем глобальный button:hover (тёмный фон + белый текст), иначе у span остаётся тёмный цвет на тёмном фоне */
.draft-entry-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(80, 60, 40, 0.12);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
}

.draft-entry-btn--mood {
  border-color: rgba(191, 91, 54, 0.28);
  background: rgba(255, 250, 244, 0.92);
}

.draft-entry-btn--mood:hover {
  border-color: rgba(191, 91, 54, 0.45);
  background: rgba(255, 246, 236, 0.98);
}

.draft-entry-btn--graded {
  border-color: rgba(32, 112, 132, 0.26);
  background: rgba(245, 252, 252, 0.95);
}

.draft-entry-btn--graded:hover {
  border-color: rgba(32, 112, 132, 0.42);
  background: rgba(238, 250, 250, 0.98);
}

.draft-entry-btn__title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-dark);
}

.draft-entry-btn--graded .draft-entry-btn__title {
  color: #1d5a66;
}

.draft-entry-btn__note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 33, 44, 0.45);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 22px 22px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

/* Явная высота панели — иначе flex-ребёнок .modal__questions с flex-basis: 0 схлопывается */
.modal--work .modal__panel--work {
  width: min(960px, calc(100% - 24px));
  height: min(88vh, 920px);
  max-height: min(92vh, 960px);
  min-height: min(520px, 92vh);
}

.modal__field {
  margin-bottom: 12px;
}

.modal__field select {
  width: 100%;
}

.modal__questions {
  flex: 1;
  min-height: 160px;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(22, 33, 44, 0.08);
  background: rgba(255, 255, 255, 0.65);
}

/* В модалках «Поднять настроение» / «В зачёт» кнопки навигации не должны уезжать под обрезку: скролл только у карточки вопроса */
.modal--work .modal__questions {
  flex: 1 1 auto;
  min-height: min(48vh, 420px);
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal--work .modal__questions.question-editor-scroll {
  max-height: none;
  overflow-y: visible;
}

.modal--work .modal__questions > .question-card {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.modal--work .modal__questions > .draft-nav {
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(22, 33, 44, 0.1);
}

.modal__questions--graded {
  border-color: rgba(32, 112, 132, 0.15);
  background: rgba(248, 252, 252, 0.9);
}

.modal__title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.modal__lead {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid rgba(22, 33, 44, 0.08);
}

.modal__dismiss {
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.modal__dismiss:hover {
  color: var(--ink);
  border-color: rgba(22, 33, 44, 0.2);
}

.draft-bucket-toggle {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(22, 33, 44, 0.12);
}

.draft-bucket-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 6px;
}

.draft-bucket-option {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.draft-bucket-option input {
  margin-top: 3px;
}

.draft-graded-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  list-style: disc;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.draft-graded-list__item {
  margin-bottom: 10px;
}

.draft-graded-num {
  font-weight: 700;
  color: #1d5a66;
  margin-right: 4px;
}

.draft-session-result-inner--notice .draft-session-notice {
  margin: 0 0 16px;
  line-height: 1.5;
  color: var(--muted);
}

.draft-session-result {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
}

.draft-session-result-inner--line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  justify-content: space-between;
}

.draft-session-line {
  margin: 0;
  flex: 1 1 16rem;
  min-width: min(100%, 12rem);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

.draft-session-line--notice {
  color: var(--muted);
}

.draft-session-verdict.is-pass {
  color: #166534;
}

.draft-session-verdict.is-fail {
  color: #b91c1c;
}

.draft-session-retry {
  flex-shrink: 0;
  margin: 0;
}

.draft-session-result-inner h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.draft-session-score {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
}

.draft-session-passed {
  margin: 0 0 14px;
  font-weight: 600;
}

.draft-session-passed.is-pass {
  color: #166534;
}

.draft-session-passed.is-fail {
  color: #b91c1c;
}

.draft-session-details {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  font-size: 14px;
  line-height: 1.45;
}

.draft-session-details li {
  margin-bottom: 8px;
}

.draft-session-details .is-ok {
  color: #166534;
}

.draft-session-details .is-bad {
  color: var(--ink);
}

.draft-session-details .muted {
  color: var(--muted);
  font-size: 13px;
}

.qa-question,
.qa-answers {
  min-width: 0;
}

.compact-textarea {
  overflow: hidden;
  resize: none;
}

.qa-answers .option-editor {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  row-gap: 0;
  cursor: pointer;
}

.qa-answers .options-editor {
  gap: 10px;
}

.qa-answers .option-editor input[type="radio"] {
  margin: 0;
  width: 16px;
  height: 16px;
  justify-self: center;
}

.qa-answers .option-editor .option-text {
  margin: 0;
  min-height: 0;
  padding: 10px 12px;
  line-height: 1.3;
}

.check-item,
.option-editor,
.runner-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.check-item,
.material-card,
.question-card,
.test-card,
.result-card,
.runner-question,
.empty-state {
  padding: 16px;
}

.check-item {
  border: 1px solid rgba(22, 33, 44, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.65);
}

.check-item--radio {
  cursor: pointer;
}

.check-item--radio.is-selected {
  border-color: rgba(191, 91, 54, 0.42);
  background: rgba(191, 91, 54, 0.08);
}

.check-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.hint-row {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.options-editor {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.compact-textarea {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 12px;
  line-height: 1.35;
}

.question-card {
  padding: 12px;
}

.question-card .field {
  gap: 4px;
}

.option-editor {
  align-items: center;
}

.option-editor textarea {
  min-height: 42px;
}

.test-card,
.result-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.result-card__main {
  flex: 1 1 auto;
  min-width: 0;
}

.result-card__main h3 {
  margin: 0 0 6px;
}

button.result-card__delete {
  flex: 0 0 auto;
  align-self: flex-start;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(185, 28, 28, 0.32);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #9f1239;
  line-height: 0;
  cursor: pointer;
}

button.result-card__delete:hover {
  background: rgba(254, 242, 242, 0.98);
  color: #881337;
}

.result-card__delete-icon {
  display: block;
}

.test-card p,
.result-card p,
.runner-header p,
.material-card p {
  margin: 8px 0;
  color: var(--muted);
}

.test-runner {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.runner-question h4 {
  margin: 0 0 12px;
}

.runner-option {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(191, 91, 54, 0.06);
}

.empty-state {
  color: var(--muted);
}

@media (max-width: 940px) {
  .hero,
  .test-settings-bar,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .panel--tests .draft-entry-buttons {
    grid-template-columns: 1fr;
  }

  .hero,
  .panel-header,
  .panel-subheader,
  .runner-header,
  .test-card,
  .result-card {
    display: grid;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    margin: 20px auto 28px;
  }

  .panel,
  .hero,
  .notice {
    padding: 18px;
    border-radius: 20px;
  }
}
