:root {
  --bg: #f5efe6;
  --panel: #fffaf2;
  --panel-soft: #fff4df;
  --ink: #2f2923;
  --muted: #6f6356;
  --line: #ddcdb7;
  --accent: #2e6f7a;
  --accent-strong: #1d4f58;
  --green: #55785a;
  --rose: #ad5f68;
  --shadow: rgba(47, 41, 35, .16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(46, 111, 122, .13), transparent 34%),
    linear-gradient(315deg, rgba(173, 95, 104, .12), transparent 32%),
    var(--bg);
}

a {
  color: inherit;
}

.study-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px);
}

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

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, .72);
  text-decoration: none;
  font-weight: 700;
}

.page-title {
  margin: 0;
  font-size: clamp(30px, 6vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  max-width: 680px;
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: clamp(16px, 2.5vw, 20px);
  line-height: 1.45;
}

.section-title {
  margin: 0 0 12px;
  font-size: clamp(22px, 3.5vw, 32px);
}

.study-section + .study-section {
  margin-top: 30px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.menu-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px var(--shadow);
  text-decoration: none;
}

.menu-card:hover {
  border-color: rgba(46, 111, 122, .5);
  transform: translateY(-1px);
}

.menu-card h2,
.menu-card h3 {
  margin: 0;
  font-size: 24px;
}

.menu-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.stub-card {
  position: relative;
  opacity: 1;
  background: #e1e3e0;
  color: #626861;
  border-color: #b9beb8;
  box-shadow: none;
}

.stub-card::after {
  content: "";
  position: absolute;
  top: 17px;
  right: 15px;
  width: 15px;
  height: 12px;
  border-radius: 2px;
  background: #4f554e;
}

.stub-card::before {
  content: "";
  position: absolute;
  top: 9px;
  right: 18px;
  width: 9px;
  height: 10px;
  border: 2px solid #4f554e;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: #4f554e;
}

.stub-card p,
.stub-card .tag {
  color: #6a7068;
}

.stub-card .tag {
  background: #d3d6d1;
}

.stub-card:hover {
  border-color: #b9beb8;
  transform: none;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-self: end;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.task-panel {
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px var(--shadow);
}

.task-panel h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 4vw, 38px);
}

.task-panel p,
.task-panel li {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.task-list {
  margin: 14px 0 0;
  padding-left: 22px;
}

.answer-box {
  width: 100%;
  min-height: 130px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  font: inherit;
  font-size: 17px;
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.action-link,
button.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.action-link.secondary {
  background: var(--green);
}

.action-link:hover,
button.action-link:hover {
  background: var(--accent-strong);
}

.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.rule-tile {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.rule-tile h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.rule-tile p {
  margin: 0;
  font-size: 15px;
}

.article-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}

.mode-toggle {
  display: inline-flex;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}

.mode-button {
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.mode-button + .mode-button {
  border-left: 1px solid var(--line);
}

.mode-button.is-active {
  background: var(--accent);
  color: #fff;
}

.article-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(173, 95, 104, .45);
  border-radius: 8px;
  background: #fff1f2;
  color: var(--ink);
}

.article-result.is-hidden {
  display: none;
}

.article-result.is-success {
  border-color: rgba(85, 120, 90, .65);
  background: #f1f8ef;
}

.article-result.is-stale {
  border-color: rgba(138, 107, 61, .45);
  background: #fff8e6;
}

.article-result strong {
  font-weight: 800;
}

.mini-link {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.fill-list {
  display: grid;
  gap: 10px;
}

.fill-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px;
  align-items: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.fill-card.round-enter {
  animation: article-card-in .34s ease both;
}

.fill-card.is-focus {
  box-shadow: 0 0 0 3px rgba(173, 95, 104, .2);
}

.fill-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.fill-body {
  min-width: 0;
}

.fill-card p {
  margin: 0;
  color: var(--ink);
}

.fill-sentence {
  font-size: clamp(18px, 3vw, 24px);
  line-height: 1.35;
  font-weight: 800;
}

.fill-card select {
  min-width: 86px;
  min-height: 36px;
  margin: 0 4px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.feedback-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 8px;
  border-radius: 50%;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  vertical-align: middle;
}

.feedback-mark.is-ok {
  background: var(--green);
}

.feedback-mark.is-bad {
  background: var(--rose);
}

.fill-card .hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.card-feedback {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  color: #5f383d;
  font-size: 14px;
  line-height: 1.35;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}

.sound-button:hover {
  border-color: rgba(46, 111, 122, .5);
}

.fill-card.is-correct {
  border-color: rgba(85, 120, 90, .75);
  background: #f1f8ef;
  animation: article-correct .24s ease both;
}

.fill-card.is-wrong {
  border-color: rgba(173, 95, 104, .75);
  background: #fff1f2;
  animation: article-wrong .24s ease both;
}

.compact-note {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .72);
}

.picture-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
  gap: 18px;
  align-items: start;
}

.picture-stage {
  display: grid;
  gap: 10px;
}

.picture-stage > img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.picture-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.picture-thumb {
  display: grid;
  gap: 5px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.picture-thumb.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(46, 111, 122, .16);
}

.picture-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.picture-work {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.picture-topic {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.picture-work h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 34px);
}

.picture-work p {
  margin: 0;
}

.picture-answer {
  min-height: 170px;
  margin-top: 14px;
}

.picture-model {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(85, 120, 90, .55);
  border-radius: 8px;
  background: #f1f8ef;
  animation: article-card-in .28s ease both;
}

.picture-model.is-hidden {
  display: none;
}

.picture-model h3 {
  margin: 0;
  font-size: 20px;
}

.model-fr {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.45;
}

.model-ru {
  color: var(--muted);
  line-height: 1.45;
}

.vocab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

@keyframes article-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes article-correct {
  50% {
    transform: scale(1.012);
  }
}

@keyframes article-wrong {
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .menu-card {
    min-height: 132px;
  }

  .fill-card {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .sound-button {
    grid-column: 2;
    justify-self: start;
  }

  .picture-layout {
    grid-template-columns: 1fr;
  }
}
