/*
 * Дизайн-система «Зошит із дудлами» — див. docs/design/DESIGN.md.
 * Propshaft підключає всі файли з цієї папки за абеткою.
 */

:root {
  --ink: #1F1D1A;
  --paper: #F3F1EC;
  --white: #FFFFFF;
  --ginger: #F29A4A;
  --lavender: #B9B4F5;
  --teal: #3FB6A8;
  --yellow: #FFD45C;
  --pink: #F7A8C4;
  --mint: #BFEBDF;
  --coral: #FBC9C3;
  --muted: #4A4640;
  --violet: #5B4FD0;
  --error: #C0392B;

  /* Світлі плями для карток */
  --tint-peach: #FCE3CC;
  --tint-lavender: #E3E0FB;
  --tint-mint: #CFEDE8;
  --tint-yellow: #FFF0B8;

  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;

  --radius-sketch: 18px 28px 16px 26px / 26px 16px 28px 18px;
  --radius-btn: 14px 22px 14px 20px / 20px 14px 22px 14px;
  --shadow: 4px 5px 0 var(--ink);
  --shadow-sm: 3px 4px 0 var(--ink);
  --line: 2.5px solid var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--ink); }
a:hover { color: var(--violet); }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

[hidden] { display: none !important; }

.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* Контур «від руки» */
.sk {
  border: var(--line);
  border-radius: var(--radius-sketch);
  box-shadow: var(--shadow);
}

.ink {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.m-ink { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.m-ink--2 { stroke-width: 2; }
.m-ink--3 { stroke-width: 3; }
.mascot { display: block; flex-shrink: 0; }

.scribble {
  margin: 0;
  font-family: var(--font-hand);
  font-weight: 700;
  color: var(--violet);
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 24px;
  font: 800 17px/1 var(--font-body);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  background: var(--white);
  border: var(--line);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { color: var(--ink); transform: translate(-1px, -2px); box-shadow: 4px 6px 0 var(--ink); }
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { cursor: default; opacity: .5; transform: none; box-shadow: var(--shadow-sm); }
.btn--primary { background: var(--ginger); }
.btn--white { background: var(--white); }
.btn--teal { background: var(--teal); }
.btn--danger { background: var(--coral); }
.btn--sm { min-height: 44px; padding: 0 22px; }
.btn--xs { min-height: 38px; padding: 0 14px; font-size: 14px; box-shadow: 2px 3px 0 var(--ink); }
.btn--block { display: flex; width: 100%; min-height: 58px; font-size: 18px; }
form.button_to { display: inline; margin: 0; }

.pill {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 18px;
  font: 700 16px var(--font-body);
  color: var(--ink);
  cursor: pointer;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.pill[aria-pressed="true"] { background: var(--yellow); }

.badge {
  display: inline-block;
  padding: 2px 12px;
  font-weight: 800;
  font-size: 14px;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}

/* Мітка типу питання */
.kind {
  flex-shrink: 0;
  padding: 1px 10px;
  font-size: 13px;
  font-weight: 800;
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.kind--choice { background: var(--mint); }
.kind--drag { background: var(--tint-lavender); }
.kind--input { background: var(--tint-peach); }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 800;
}
.progress__bar {
  flex-grow: 1;
  height: 12px;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.progress__bar span { display: block; height: 100%; background: var(--teal); }

/* Форми */
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-weight: 800; font-size: 15px; }
.field__hint { margin: 0; font-size: 15px; color: var(--muted); }
.input {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  font: 600 18px var(--font-body);
  color: var(--ink);
  background: var(--white);
  border: var(--line);
  border-radius: 14px;
  outline: none;
  transition: box-shadow .12s, border-color .12s;
}
.input--area { padding: 14px 18px; line-height: 1.4; resize: vertical; }
/* Випадний список: своя стрілка замість браузерної */
select.input {
  padding-right: 48px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath d='M6 9 L12 15 L18 9' fill='none' stroke='%231F1D1A' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 18px center;
}
.input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px var(--lavender); }
.input[aria-invalid="true"] { border-color: var(--error); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--coral); }
/* Випадне меню в стилі сайту: фільтр-кнопка (.pill) або поле форми (.dropdown--field, див. select_controller). */
.dropdown { position: relative; }
.dropdown__toggle { display: inline-flex; align-items: center; gap: 10px; list-style: none; }
.dropdown__toggle::-webkit-details-marker { display: none; }
.dropdown__toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border: solid var(--ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  transition: transform .15s;
}
.dropdown[open] .dropdown__toggle::after { margin-top: 4px; transform: rotate(-135deg); }
.pill.dropdown__toggle--chosen { background: var(--yellow); }
.dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--white);
}
.dropdown__item { display: block; width: 100%; font: inherit; text-align: left; cursor: pointer; background: none; border: 0; padding: 9px 12px; font-weight: 700; color: var(--ink); text-decoration: none; border-radius: 10px; }
.dropdown__item:hover { color: var(--ink); background: var(--tint-yellow); }
.dropdown__item[aria-current="page"],
.dropdown__item[aria-selected="true"] { background: var(--yellow); }
.dropdown--field .dropdown__menu { right: 0; left: 0; }
.dropdown__field { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.dropdown__field::-webkit-details-marker { display: none; }
.dropdown__field::after {
  content: "";
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin: -5px 4px 0 16px;
  border: solid var(--ink);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.dropdown--field[open] .dropdown__field { border-color: var(--violet); box-shadow: 0 0 0 4px var(--lavender); }

.field__error { margin: 0; font-weight: 700; font-size: 15px; color: var(--error); }

.check { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 700; cursor: pointer; }
.check input {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  cursor: pointer;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 6px;
}
.check input:checked { background: var(--teal); }
.check input:checked::after {
  content: "";
  width: 7px;
  height: 13px;
  margin-top: -3px;
  border: solid var(--ink);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 12px; height: 12px; margin: 0; background: var(--ink); border: 0; border-radius: 50%; transform: none; }
.check input[aria-invalid="true"] { border-color: var(--error); }
.check:has(input:disabled) { cursor: default; opacity: .4; }
.check input:disabled { cursor: default; }
.check a { color: var(--violet); }

/* Вікно підтвердження (layouts/_confirm) */
.confirm-dialog { width: min(440px, calc(100vw - 32px)); margin: auto; padding: 0; color: var(--ink); background: var(--white); }
.confirm-dialog::backdrop { background: rgb(31 29 26 / .45); }
.confirm-dialog__body { display: flex; flex-direction: column; gap: 20px; padding: 24px; }
.confirm-dialog__message { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.45; }
.confirm-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.flash-area { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.flash { margin: 0; padding: 14px 20px; font-weight: 700; background: var(--mint); }
.flash--alert { background: var(--coral); }

/* Шапка */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px 32px;
  padding-block: 22px;
}

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo:hover { color: var(--ink); }
.logo__word { font: 800 24px var(--font-display); letter-spacing: -0.02em; }
.logo__tag {
  padding: 0 10px;
  font: 700 24px/1.2 var(--font-hand);
  background: var(--yellow);
  border: var(--line);
  border-radius: var(--radius-sketch);
  box-shadow: 2px 3px 0 var(--ink);
  transform: rotate(-5deg);
}

.site-header__user { display: flex; align-items: center; gap: 14px; }
.site-header__name { font-weight: 800; }
.site-header__admin { font-weight: 800; color: var(--violet); }
.mobile-menu__user { margin: 0; font-weight: 800; color: var(--muted); }

.site-nav { display: flex; flex-wrap: wrap; gap: 6px 24px; flex-grow: 1; font-weight: 700; }
.site-nav a { text-decoration: none; }

.locale-switch {
  display: flex;
  padding: 3px;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.locale-switch a {
  min-width: 44px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  border-radius: 999px;
}
.locale-switch a[aria-current="true"] { background: var(--yellow); }

.mobile-menu { display: none; position: relative; margin-left: auto; }
.mobile-menu summary {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  list-style: none;
  cursor: pointer;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 12px;
}
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 220px;
  padding: 16px 20px;
  background: var(--white);
}
.mobile-menu__panel nav { display: flex; flex-direction: column; gap: 4px; font-weight: 800; }
.mobile-menu__panel nav a { padding: 8px 0; text-decoration: none; }
.mobile-menu .locale-switch { align-self: flex-start; }

/* Підвал */
.site-footer { background: var(--ink); color: var(--paper); }
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 28px;
  font-size: 15px;
}
.site-footer__brand { font-family: var(--font-display); font-weight: 800; }
.site-footer a { color: var(--yellow); }

/* Нижня панель (лише мобільна) */
.tabbar { display: none; }

@media (max-width: 720px) {
  body { font-size: 16px; padding-bottom: 96px; }
  .container { padding-inline: 16px; }

  .site-header { padding-block: 14px; }
  .logo__word { font-size: 19px; }
  .logo__tag { font-size: 19px; padding: 0 7px; box-shadow: 2px 2px 0 var(--ink); }
  .site-header > .site-nav,
  .site-header > .locale-switch,
  .site-header__login,
  .site-header__user { display: none; }
  .mobile-menu { display: block; }

  .tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 16px;
    z-index: 10;
    display: flex;
    padding: 4px;
    background: var(--white);
    border: var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
  }
  .tabbar a {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    font: 800 12px var(--font-body);
    text-decoration: none;
    border-radius: 14px;
  }
  .tabbar a[aria-current="page"] { background: var(--yellow); }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
