:root {
  color-scheme: light;
  --ice: #f3f7fc;
  --paper: #ffffff;
  --ink: #182c46;
  --muted: #5e6f84;
  --line: #cbd8e7;
  --line-strong: #9eb2c9;
  --blue: #235fa8;
  --blue-dark: #17477e;
  --blue-soft: #e4eef9;
  --apricot: #f5b77b;
  --mint: #daeee7;
  --mint-ink: #175b48;
  --danger: #a33a3a;
  --danger-soft: #fff0f0;
  --focus: #db7619;
  --shadow: 0 18px 45px rgba(24, 44, 70, 0.11);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ice);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ice);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ice);
}

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

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

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

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--paper);
  background: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  gap: 2rem;
  min-height: 72px;
  padding: 0.75rem clamp(1rem, 4vw, 4.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.93);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: max-content;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--ink);
  font-size: 0.82rem;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ice);
}

.top-nav a {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
}

.top-nav a[aria-current="page"] {
  color: var(--paper);
  background: var(--blue);
}

.prototype-label {
  justify-self: end;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

main {
  width: 100%;
}

.route-view {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.start-screen {
  display: grid;
  grid-template-columns: minmax(290px, 0.86fr) minmax(460px, 1.14fr);
  gap: clamp(3rem, 8vw, 8rem);
  align-items: start;
  padding: clamp(4rem, 9vw, 8rem) 0 5rem;
}

.intro-copy {
  position: sticky;
  top: 3rem;
}

.section-kicker,
.question-state,
.rail-label {
  margin: 0 0 0.55rem;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

h1,
h2,
p {
  max-width: 68ch;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 14ch;
  font-size: clamp(2.35rem, 6vw, 4.7rem);
  font-weight: 760;
}

h2 {
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  font-weight: 730;
}

.intro-copy > p:not(.section-kicker) {
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.privacy-note {
  display: flex;
  gap: 0.7rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem !important;
}

.privacy-note span {
  color: var(--apricot);
}

.start-form {
  padding: 0.25rem 0;
}

fieldset {
  min-width: 0;
  margin: 0 0 2.2rem;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.85rem;
  color: var(--ink);
  font-weight: 700;
}

fieldset:disabled {
  opacity: 0.5;
}

.choice-list {
  border-top: 1px solid var(--line-strong);
}

.choice-row {
  position: relative;
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
  padding: 1rem 0.4rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.choice-row:hover {
  background: rgba(255, 255, 255, 0.55);
}

.choice-row:has(input:checked) {
  border-bottom-color: var(--blue);
  background: var(--blue-soft);
}

.choice-row input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.25rem 0 0;
  accent-color: var(--blue);
}

.choice-row strong,
.choice-row small {
  display: block;
}

.choice-row strong {
  font-size: 0.98rem;
}

.choice-row small {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.start-action,
.question-actions,
.review-actions,
.success-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.start-action {
  justify-content: space-between;
  border-top: 1px solid var(--line-strong);
  padding-top: 1.15rem;
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: var(--paper);
  background: var(--blue);
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button-secondary {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--paper);
}

.button-quiet {
  color: var(--blue);
  background: transparent;
}

.button-danger {
  color: var(--paper);
  background: var(--danger);
}

.text-button,
.link-button {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: none;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2rem;
  cursor: pointer;
}

.message {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--blue);
  background: var(--paper);
}

.message p {
  margin: 0;
}

.message .button {
  margin-top: 0.75rem;
}

.message-error {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.survey-shell {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  width: min(1080px, 100%);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 5rem) 0;
}

.context-rail {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2.1rem 2rem 2rem 0;
  border-right: 1px solid var(--line-strong);
}

.rail-label {
  color: var(--muted);
}

.rail-value {
  margin: 0;
  font-weight: 700;
}

.rail-value-small {
  font-size: 0.86rem;
  font-weight: 600;
}

.rail-version {
  margin-top: auto;
}

.question-sheet {
  position: relative;
  align-self: start;
  min-height: 600px;
  padding: clamp(2rem, 6vw, 5rem);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.working-tab {
  position: absolute;
  top: 8.4rem;
  left: -7px;
  width: 14px;
  height: 88px;
  border-radius: 3px;
  background: var(--apricot);
}

.progress-block {
  margin-bottom: clamp(3rem, 7vw, 6rem);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 160ms ease-out;
}

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

#question-title {
  max-width: 18ch;
}

.question-help {
  margin: 1rem 0 0;
  color: var(--muted);
}

.question-control {
  margin-top: 2rem;
}

.answer-options {
  display: grid;
  gap: 0.55rem;
}

.answer-option {
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.answer-option input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.24rem;
  accent-color: var(--blue);
}

.answer-option:has(input:checked) {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
  font-weight: 650;
}

.text-input,
.textarea-input,
.select-input,
.task-filters select {
  width: 100%;
  min-height: 46px;
  padding: 0.8rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.35rem;
  color: var(--ink);
  background: var(--paper);
}

.textarea-input {
  min-height: 150px;
  resize: vertical;
}

.text-input:focus,
.textarea-input:focus,
.select-input:focus,
.task-filters select:focus {
  border-color: var(--blue);
}

.input-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.composite-fields {
  display: grid;
  gap: 1.2rem;
}

.field-block label,
.task-filters label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.field-required {
  color: var(--danger);
}

.field-error {
  margin: 0.8rem 0 0;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 650;
}

.question-actions {
  justify-content: flex-end;
  margin-top: 3rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--line);
}

#back-button {
  margin-right: auto;
}

.review-screen,
.success-screen {
  width: min(850px, 100%);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) 0;
}

.review-heading > p:last-child,
.success-screen > p:not(.section-kicker) {
  color: var(--muted);
}

.review-list {
  margin: 3rem 0;
  border-top: 1px solid var(--line-strong);
}

.review-item {
  display: grid;
  grid-template-columns: minmax(180px, 0.85fr) minmax(260px, 1.15fr) auto;
  gap: 1.5rem;
  align-items: start;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--line);
}

.review-item dt,
.review-item dd {
  margin: 0;
}

.review-item dt {
  color: var(--muted);
  font-size: 0.84rem;
}

.review-item dd {
  white-space: pre-wrap;
}

.review-actions,
.success-actions {
  justify-content: flex-end;
}

.success-screen {
  max-width: 680px;
  text-align: center;
}

.success-screen h2,
.success-screen p {
  margin-right: auto;
  margin-left: auto;
}

.success-confirmation {
  color: var(--ink) !important;
  font-size: 1.08rem;
  font-weight: 700;
}

.success-mark {
  display: grid;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.6rem;
  place-items: center;
  border-radius: 50%;
  color: var(--mint-ink);
  background: var(--mint);
  font-size: 1.8rem;
  font-weight: 800;
}

.receipt-list {
  margin: 1rem 0 0;
  border-top: 1px solid var(--line-strong);
  text-align: left;
}

.receipt-details {
  margin: 2.5rem 0;
  text-align: left;
}

.receipt-details summary {
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  color: var(--blue);
  font-weight: 650;
  cursor: pointer;
}

.receipt-list div {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.receipt-list dt {
  color: var(--muted);
  font-size: 0.84rem;
}

.receipt-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.team-view {
  padding: clamp(3rem, 7vw, 6rem) 0;
}

.team-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.team-heading h1 {
  max-width: none;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.team-heading > div > p:not(.section-kicker) {
  margin: 1rem 0 0;
  color: var(--muted);
}

.team-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1rem;
  align-items: center;
}

.inbox-badge,
.new-marker {
  width: max-content;
  border-radius: 999px;
  color: var(--ink);
  background: var(--apricot);
  font-weight: 750;
}

.inbox-badge {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.team-destination {
  font-size: 0.86rem;
}

.telegram-delivery-status {
  max-width: 760px;
  margin-top: 0.45rem !important;
  color: var(--muted);
  font-size: 0.8rem;
}

.telegram-delivery-status[data-status="configuration_error"] {
  color: var(--danger);
}

.team-refresh {
  display: grid;
  flex: 0 0 min(290px, 32vw);
  gap: 0.7rem;
  justify-items: end;
}

#team-connection-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

#team-connection-status[data-status="error"] {
  color: var(--danger);
}

.task-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 1rem;
  margin: 3rem 0 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.task-list {
  border-top: 1px solid var(--line-strong);
}

.task-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 180px 130px;
  gap: 1.5rem;
  align-items: center;
  width: 100%;
  padding: 1.25rem 0.25rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.task-row:hover {
  background: rgba(255, 255, 255, 0.55);
}

.task-row strong,
.task-row span {
  min-width: 0;
}

.task-origin {
  display: grid;
  gap: 0.4rem;
  align-items: start;
}

.new-marker {
  padding: 0.18rem 0.46rem;
  font-size: 0.68rem;
}

.delivery-marker {
  width: fit-content;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.delivery-accepted {
  color: var(--mint-ink);
}

.delivery-failed,
.delivery-unknown {
  color: var(--danger);
}

.task-summary {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  width: max-content;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.empty-state {
  padding: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(560px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0.65rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(24, 44, 70, 0.28);
}

.modal::backdrop {
  background: rgba(17, 35, 57, 0.56);
}

.modal > form,
.modal-head,
#task-detail-body,
#task-detail-message {
  padding: 1.5rem;
}

.modal h2 {
  font-size: 1.7rem;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.task-modal {
  width: min(820px, calc(100% - 2rem));
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-head > div,
.detail-toolbar > *,
#task-detail-body,
.detail-section,
.answer-list,
.answer-list div {
  min-width: 0;
  max-width: 100%;
}

.modal-head h2,
.detail-section p,
.detail-section li,
.answer-list dt,
.answer-list dd {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.icon-button {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.detail-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 2rem;
}

.detail-section {
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.detail-section ul {
  margin: 0;
  padding-left: 1.2rem;
}

.answer-list {
  margin: 0;
}

.answer-list div {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.answer-list dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.answer-list dd {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .site-header {
    grid-template-columns: 1fr auto;
    gap: 0.75rem 1rem;
  }

  .prototype-label {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .start-screen {
    grid-template-columns: 1fr;
    gap: 3rem;
    padding-top: 3rem;
  }

  .intro-copy {
    position: static;
  }

  .survey-shell {
    grid-template-columns: 1fr;
  }

  .context-rail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem 1.5rem;
    padding: 0 0 1.25rem;
    border-right: 0;
  }

  .rail-version {
    margin: 0;
  }

  .context-rail .text-button {
    align-self: end;
    justify-self: start;
  }

  .question-sheet {
    min-height: 560px;
  }

  .review-item {
    grid-template-columns: 1fr auto;
  }

  .review-item dd {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .task-row {
    grid-template-columns: 120px minmax(0, 1fr) auto;
  }

  .task-summary {
    display: none;
  }
}

@media (max-width: 600px) {
  :root {
    font-size: 16px;
  }

  body {
    background: var(--ice);
  }

  .site-header {
    display: flex;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
  }

  .brand {
    flex: 1 1 auto;
  }

  .brand > span:last-child {
    display: none;
  }

  .top-nav {
    margin-left: auto;
  }

  .top-nav a {
    padding: 0.42rem 0.62rem;
    font-size: 0.74rem;
  }

  .prototype-label {
    flex-basis: 100%;
  }

  .route-view {
    width: min(100% - 1.25rem, 1180px);
  }

  .start-screen {
    padding-top: 2.3rem;
  }

  h1 {
    font-size: clamp(2.25rem, 12vw, 3.25rem);
  }

  .start-action,
  .review-actions,
  .success-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .start-action .button,
  .review-actions .button,
  .success-actions .button {
    width: 100%;
  }

  .survey-shell {
    padding-top: 1.25rem;
  }

  .context-rail {
    grid-template-columns: 1fr 1fr;
    padding: 0.4rem 0.5rem 1rem;
  }

  .rail-version {
    display: none;
  }

  .question-sheet {
    min-height: 0;
    margin: 0 -0.625rem;
    padding: 1.5rem 1rem;
    box-shadow: none;
  }

  .working-tab {
    top: 7.8rem;
    left: 0;
    width: 7px;
    height: 68px;
  }

  .progress-block {
    margin-bottom: 3rem;
  }

  #question-title {
    font-size: clamp(1.75rem, 9vw, 2.5rem);
  }

  .question-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #back-button {
    margin: 0;
  }

  #next-button {
    grid-column: 2;
  }

  #skip-button:not([hidden]) + #next-button {
    grid-column: 1 / -1;
  }

  .review-screen,
  .success-screen,
  .team-view {
    padding: 2.5rem 0;
  }

  .receipt-list div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .team-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .team-refresh {
    width: 100%;
    justify-items: stretch;
  }

  #team-connection-status {
    text-align: left;
  }

  .task-filters {
    grid-template-columns: 1fr;
  }

  .task-row {
    grid-template-columns: 1fr auto;
    gap: 0.55rem 1rem;
  }

  .task-row > :first-child {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.8rem;
  }

  .detail-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
