/* Application layout and screens. Tokens come from theme.css (brand #A0197D). */
:root {
  --app-bg: #f7f4f6;
  --surface: #ffffff;
  --text: #1f1a1d;
  --text-muted: #5c5459;
  --line: #ddd5da;
  --danger: #b3261e;
  --success: #1e7b34;
  --warning-bg: #fff4d6;
  --warning-line: #e8c46a;
  --focus-ring: 0 0 0 3px rgb(160 25 125 / 35%);
  --topbar-h: 3.75rem;
  --nav-w: 15rem;
  --banner-h: 3.75rem;
  --r: 0.625rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--app-bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
}

a {
  color: var(--brand);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Programmatic focus targets: <FocusOnNavigate> moves focus to the page's h1 (and the skip link to <main>) so screen readers
   start at the new content. Those elements are not controls, and browsers match :focus-visible for script-driven focus on a
   fresh page load, which drew a ring round the heading ("Giriş yap", "Formlarım") before anyone touched the keyboard. Only
   these tabindex="-1" containers lose the ring; every control keeps the :focus-visible ring above. */
h1[tabindex="-1"]:focus,
h1[tabindex="-1"]:focus-visible,
main[tabindex="-1"]:focus,
main[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 100;
  background: var(--surface);
  padding: 0.5rem 1rem;
  border-radius: var(--r);
}

.skip-link:focus {
  left: 0.5rem;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Buttons and inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-outline {
  border-color: var(--line);
  background: var(--surface);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-text {
  color: var(--danger);
}

.btn-link {
  color: var(--brand);
  padding: 0 0.25rem;
  min-height: 2rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-sm {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.btn-on-brand {
  color: #fff;
  border-color: rgb(255 255 255 / 45%);
  min-height: 2.25rem;
}

.btn-on-brand:hover {
  background: rgb(255 255 255 / 15%);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-foreground);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn-sm {
  width: 2.25rem;
  height: 2.25rem;
}

.icon-btn.danger:hover:not(:disabled) {
  background: #fde8e7;
  color: var(--danger);
}

.input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 2px);
  background: var(--surface);
  font: inherit;
  color: inherit;
}

textarea.input {
  resize: vertical;
}

/* Number fields keep the browser's own up/down steppers; Chrome only paints them while the pointer is over the field, so
   they are made permanently visible (nothing here resets `appearance`). */
input.input[type="number"]::-webkit-inner-spin-button,
input.input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  height: auto;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
  outline: none;
}

.input:disabled {
  background: #faf8f9;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0 0 0.9rem;
  border: 0;
  padding: 0;
}

.field label,
.field legend,
.field-label {
  font-weight: 500;
  font-size: 0.9rem;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.switch-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  cursor: pointer;
}

.switch-row input[type="checkbox"] {
  appearance: none;
  width: 2.5rem;
  height: 1.4rem;
  border-radius: 999px;
  background: #cfc5cb;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.switch-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch-row input[type="checkbox"]:checked {
  background: var(--brand);
}

.switch-row input[type="checkbox"]:checked::after {
  transform: translateX(1.1rem);
}

.radio-row input {
  accent-color: var(--brand);
  width: 1.1rem;
  height: 1.1rem;
}

.alert {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  margin: 0 0 1rem;
}

.alert-info {
  background: #f7e8f3;
  border-color: #e7c3dc;
  color: #5c0e48;
}

.alert-error {
  background: #fde8e7;
  border-color: #f2b8b5;
  color: #8c1d18;
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-line);
}

.field-error,
.field-errors {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

/* The Tailwind reset of BlazorBlueprint makes every svg display:block, so an icon in front of the message used to sit on
   a line of its own; the message is a flex row (icon + text) instead. */
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.field-error > svg {
  flex: none;
  margin-top: 0.15rem;
}

.field-errors {
  padding-left: 1.1rem;
}

/* ---------- Brand ---------- */
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--brand);
  font-weight: 800;
  font-size: 1.2rem;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.2rem;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text small {
  opacity: 0.85;
  font-size: 0.78rem;
}

/* ---------- App shell ---------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: var(--brand);
  color: #fff;
}

.topbar-spacer {
  flex: 1;
}

.menu-toggle {
  display: none;
  color: #fff;
}

.menu-toggle:hover {
  background: rgb(255 255 255 / 15%) !important;
  color: #fff !important;
}

.user-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.logout-form {
  margin: 0;
}

/* The language switch: two links on the brand-coloured bars (app top bar, sign-in header, respondent header). */
.app-topbar,
.auth-header,
.public-header {
  --bar-bg: var(--brand);
  --bar-fg: #fff;
}

.public-shell.themed .public-header {
  --bar-bg: var(--color-header-bg, var(--brand));
  --bar-fg: var(--color-header-text, #fff);
}

.lang-menu {
  position: relative;
  flex: none;
  color: var(--bar-fg);
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0 0.6rem;
  border: 1px solid color-mix(in srgb, var(--bar-fg) 45%, transparent);
  border-radius: var(--r);
  color: var(--bar-fg);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.lang-trigger::-webkit-details-marker {
  display: none;
}

.lang-trigger svg {
  flex: none;
}

.lang-trigger:hover,
.lang-menu[open] > .lang-trigger {
  background: color-mix(in srgb, var(--bar-fg) 15%, transparent);
}

.lang-trigger:focus-visible {
  outline: 2px solid var(--bar-fg);
  outline-offset: 2px;
}

.lang-list {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 70;
  min-width: 9.5rem;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: 0 0.7rem;
  border-radius: calc(var(--r) - 2px);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.lang-option:hover {
  background: var(--accent);
}

.lang-option[aria-current="true"] {
  font-weight: 700;
  color: var(--brand);
}

.lang-option:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Phones: the bar is crowded, so only the globe and the chevron stay; the menu still names both languages. */
@media (max-width: 639px) {
  .lang-current {
    display: none;
  }

  .lang-trigger {
    min-height: 2.75rem;
    min-width: 2.75rem;
    justify-content: center;
    padding: 0 0.5rem;
    gap: 0.25rem;
  }
}

.app-body {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.app-nav {
  flex: none;
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

/* A session banner above the top bar is in the flow at scroll 0: the nav gives that room back, so its foot stays on screen. */
.app-shell:has(.impersonation-banner) .app-nav {
  height: calc(100dvh - var(--topbar-h) - var(--banner-h));
}

/* The items scroll above the pinned foot (the sign-out), which is therefore never hidden under a long admin list. */
.app-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem 0.5rem;
}

.app-nav-foot {
  flex: none;
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.nav-logout {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.app-nav-head {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  border-radius: var(--r);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.nav-item.active {
  background: var(--brand);
  color: #fff;
}

/* "Yönetim" disclosure: a button that looks like a nav item, with the admin pages indented under it. */
.nav-parent {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.nav-parent .nav-parent-label {
  flex: 1;
}

.nav-parent.section-active {
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-sub {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.nav-sub[hidden] {
  display: none;
}

.nav-sub-item {
  min-height: 2.25rem;
  padding: 0 0.65rem;
  gap: 0.55rem;
  font-size: 0.9rem;
}

.nav-backdrop,
.builder-backdrop,
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(20 10 18 / 45%);
  z-index: 40;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
}

.app-main:focus {
  outline: none;
}

@media (max-width: 767px) {
  .menu-toggle {
    display: inline-flex;
  }

  /* Menu button, brand, language switch and user menu share 360 px: tighter gaps, and the brand may shrink. */
  .app-topbar {
    padding: 0 0.5rem;
    gap: 0.35rem;
  }

  .app-topbar .app-brand {
    min-width: 0;
    gap: 0.4rem;
  }

  .brand-text strong {
    font-size: 0.9rem;
  }

  .app-topbar .user-menu-button {
    padding: 0.35rem 0.25rem;
  }

  .user-name-text,
  .brand-text small {
    display: none;
  }

  .app-nav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    /* Above the sticky session banner (55), so the drawer's first items and its close button are not hidden behind it. */
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 30px rgb(0 0 0 / 25%);
  }

  .app-shell:has(.impersonation-banner) .app-nav {
    height: 100dvh;
  }

  .app-nav.open {
    transform: none;
  }

  .app-nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    padding: 0 0 0.5rem 0.85rem;
  }

  .app-main {
    padding: 1rem;
  }
}

/* ---------- Auth ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: var(--brand);
  color: #fff;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) * 1.5);
  padding: 2rem;
  box-shadow: 0 10px 30px rgb(160 25 125 / 8%);
}

.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.auth-site-title {
  margin: 0;
  color: var(--brand);
  font-weight: 600;
}

.auth-description {
  color: var(--text-muted);
  margin: 0.5rem 0 1.25rem;
}

.auth-dev-notice {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-error,
.auth-main .app-error {
  max-width: 40rem;
}

.app-error h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

.app-error-trace code {
  user-select: all;
}

/* AD-31: a blocked operation during Impersonation keeps the page and shows this notice. */
.inline-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.625rem 0.5rem 0.625rem 0.875rem;
  background: var(--warning-bg);
  border: 1px solid var(--warning-line);
  border-radius: var(--r);
  color: var(--text);
  box-shadow: 0 6px 20px rgb(0 0 0 / 12%);
}

.inline-toast span {
  flex: 1;
}

/* ---------- Pages ---------- */
.page {
  max-width: 72rem;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
  padding: 3rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  color: var(--text-muted);
}

.empty-state p {
  margin: 0.25rem 0;
  max-width: 34rem;
}

/* ---------- Dashboard ---------- */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.25rem;
  overflow-x: auto;
  max-width: 100%;
}

.tab {
  min-height: 2.5rem;
  padding: 0 1rem;
  border: 0;
  border-radius: calc(var(--r) - 3px);
  background: transparent;
  font: inherit;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--brand);
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.search {
  position: relative;
  flex: 1;
  max-width: 22rem;
  min-width: 12rem;
}

.search > svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search .input {
  padding-left: 2.1rem;
}

.form-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.form-table th,
.form-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.form-table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: #fbf9fa;
}

.form-table tbody tr:last-child td {
  border-bottom: 0;
}

.form-table tbody tr:hover {
  background: #fcf7fa;
}

.form-title-cell {
  min-width: 12rem;
}

.form-title-cell a {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.form-title-cell a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.row-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .form-table thead {
    display: none;
  }

  .form-table,
  .form-table tbody,
  .form-table tr,
  .form-table td {
    display: block;
    width: 100%;
  }

  .form-table tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
  }

  .form-table td {
    border: 0;
    padding: 0.25rem 1rem;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .search {
    max-width: none;
  }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-draft {
  background: #f1eef0;
  color: #4a4247;
  border-color: #ddd5da;
}

.status-published {
  background: #e3f4e7;
  color: var(--success);
  border-color: #b9e0c3;
}

.status-closed {
  background: #fde8e7;
  color: #8c1d18;
  border-color: #f2b8b5;
}

.status-archived {
  background: #eef0f5;
  color: #3d4659;
  border-color: #cfd4df;
}

/* ---------- Dialog ---------- */
.dialog {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(28rem, calc(100vw - 2rem));
  background: var(--surface);
  border-radius: calc(var(--r) * 1.5);
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgb(0 0 0 / 25%);
}

.dialog-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.dialog-message {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---------- Builder ---------- */
.app-main:has(.builder) {
  padding: 0;
}

.builder-topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.builder-heading {
  margin: 0;
  font-size: 1.1rem;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-state {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.save-saved {
  color: var(--success);
}

.save-failed,
.save-invalid {
  color: var(--danger);
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spin {
    animation: none;
  }

  .app-nav,
  .builder-palette,
  .builder-panel {
    transition: none !important;
  }
}

.builder-alert {
  margin: 0.75rem 1rem 0;
}

.builder-body {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 21rem;
  gap: 1.25rem;
  padding: 1.25rem;
  align-items: start;
}

.builder-palette,
.builder-panel {
  position: sticky;
  top: calc(var(--topbar-h) + 4rem);
  max-height: calc(100vh - var(--topbar-h) - 5rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1rem;
}

.palette-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-head h2,
.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.palette-close,
.panel-close {
  display: none;
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.palette-category {
  margin: 0.9rem 0 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 2px);
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: grab;
}

.palette-item:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
  background: #fcf7fa;
}

.palette-item svg {
  color: var(--brand);
  flex: none;
}

.builder-canvas {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  max-width: 48rem;
  width: 100%;
  margin: 0 auto;
}

.form-header-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--brand);
  border-radius: var(--r);
  padding: 1.25rem;
}

.form-title-input,
.form-description-input,
.question-title-input,
.question-help-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0.3rem 0.1rem;
}

.form-title-input {
  font-size: 1.6rem;
  font-weight: 700;
}

.form-description-input {
  resize: vertical;
  color: var(--text-muted);
}

.form-title-input:hover,
.form-description-input:hover,
.question-title-input:hover,
.question-help-input:hover {
  border-bottom-color: var(--line);
}

.form-title-input:focus,
.form-description-input:focus,
.question-title-input:focus,
.question-help-input:focus {
  outline: none;
  box-shadow: none;
  border-bottom: 2px solid var(--brand);
}

.add-question-mobile {
  display: none;
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 8rem;
}

.canvas-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1rem;
  border: 2px dashed #e1c3d8;
  border-radius: var(--r);
  color: var(--text-muted);
  background: #fdfafc;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: var(--r);
  padding: 0.75rem 1rem 0.5rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.question-card:hover {
  box-shadow: 0 4px 14px rgb(0 0 0 / 6%);
}

.question-card.selected {
  border-left-color: var(--brand);
  box-shadow: 0 6px 20px rgb(160 25 125 / 12%);
}

.question-card.sortable-ghost,
.palette-item.sortable-ghost {
  opacity: 0.45;
  border: 2px dashed var(--brand);
}

.question-card-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.spacer {
  flex: 1;
}

.drag-handle {
  display: inline-flex;
  cursor: grab;
  padding: 0.3rem 0.1rem;
  color: #a8999f;
}

.drag-handle:active {
  cursor: grabbing;
}

.question-number {
  font-weight: 700;
  color: var(--text);
}

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #f7e8f3;
  color: #5c0e48;
  font-size: 0.78rem;
  font-weight: 600;
  width: fit-content;
}

.question-title-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.question-title-input {
  font-size: 1.05rem;
  font-weight: 600;
}

.question-help-input {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.required-mark {
  color: var(--danger);
  font-weight: 700;
  font-size: 1.2rem;
}

.question-preview {
  padding: 0.6rem 0 0.4rem;
}

.preview-field {
  max-width: 28rem;
}

.preview-narrow {
  max-width: 16rem;
}

.preview-consent {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.question-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f0eaee;
  margin-top: 0.4rem;
}

.option-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.input-inline {
  border-color: transparent;
  background: transparent;
  min-height: 2.25rem;
}

.input-inline:hover {
  border-color: var(--line);
}

.option-marker {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid #b8aab2;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.marker-radio {
  border-radius: 50%;
}

.marker-checkbox {
  border-radius: 0.2rem;
}

.marker-number,
.marker-none {
  border: 0;
  width: 1.5rem;
}

.grid-editor {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1rem;
}

.grid-editor-title {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question-card {
  container-type: inline-size;
  container-name: question-card;
}

/* Narrow cards (the builder canvas at 1280px is ~24rem): rows and columns editors stack, so labels stay readable. */
@container question-card (max-width: 40rem) {
  .grid-editor {
    grid-template-columns: minmax(0, 1fr);
  }
}

.builder-panel .settings-panel-body {
  margin-top: 0.75rem;
}

.panel-subtitle {
  margin: 1.25rem 0 0.6rem;
  font-size: 0.9rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.advanced {
  margin-top: 0.5rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 2px);
  padding: 0.5rem 0.75rem;
}

.advanced summary {
  cursor: pointer;
  font-weight: 500;
  min-height: 2rem;
  display: flex;
  align-items: center;
}

.advanced[open] summary {
  margin-bottom: 0.6rem;
}

.pattern-result {
  margin: 0.3rem 0 0;
  font-weight: 600;
  font-size: 0.875rem;
}

.pattern-result.ok {
  color: var(--success);
}

.pattern-result.fail {
  color: var(--danger);
}

.settings-link {
  display: none;
}

@media (max-width: 1279px) {
  .builder-body {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .builder-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    max-height: none;
    width: min(24rem, 100vw);
    z-index: 50;
    border-radius: 0;
    transform: translateX(105%);
    transition: transform 0.2s ease;
  }

  .panel-open .builder-panel {
    transform: none;
  }

  .panel-close,
  .settings-link {
    display: inline-flex;
  }
}

@media (max-width: 899px) {
  .builder-body {
    grid-template-columns: minmax(0, 1fr);
    padding: 1rem;
  }

  .builder-palette {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    max-height: none;
    width: min(18rem, 85vw);
    z-index: 50;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .palette-open .builder-palette {
    transform: none;
  }

  .palette-close,
  .add-question-mobile {
    display: inline-flex;
  }

  .drag-handle {
    display: none;
  }

  .grid-editor {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1280px) {
  .builder-backdrop {
    display: none;
  }
}

#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: #fff4c5;
  box-shadow: 0 -1px 2px rgb(0 0 0 / 20%);
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  cursor: pointer;
}

/* ---- Slice A2: publish, share, fill page, responses ---- */

.builder-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.count-pill {
  display: inline-flex;
  min-width: 1.5rem;
  justify-content: center;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 0.8rem;
}

.btn-lg {
  min-height: 3rem;
  padding: 0 1.75rem;
  font-size: 1.05rem;
}

.publish-issues {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  max-height: 50vh;
  overflow-y: auto;
}

.publish-issues li {
  margin-bottom: 0.35rem;
}

.publish-issues .btn-link {
  padding: 0;
  min-height: 0;
  white-space: normal;
  text-align: left;
}

/* Share dialog */
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.share-dialog {
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.share-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.35rem 0 0.25rem;
}

.share-row .input {
  min-width: 0;
  font-size: 0.85rem;
}

.share-toggle {
  margin: 1rem 0 0.5rem;
}

.share-regenerate {
  border-top: 1px solid var(--line);
  margin-top: 1rem;
  padding-top: 0.75rem;
}

/* Respondent layout (mobile first, 360 px and up) */
.public-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--topbar-h);
  padding: 0 1rem;
  background: var(--brand);
  color: #fff;
}

.public-header .app-brand {
  color: #fff;
}

.public-main {
  flex: 1;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 0.75rem 2rem;
}

.public-main:focus {
  outline: none;
}

.public-footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.preview-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--r);
  border: 1px dashed var(--brand);
  background: var(--accent);
  color: var(--accent-foreground);
}

.preview-banner .btn {
  margin-left: auto;
}

.fill-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) * 1.4);
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
}

.fill-header {
  border-top: 6px solid var(--brand);
}

.fill-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

.fill-description {
  margin: 0 0 0.5rem;
  white-space: pre-line;
}

.fill-required-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fill-status {
  text-align: center;
  padding: 2rem 0;
}

.fill-questions {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.fill-field {
  scroll-margin-top: 1rem;
}

.fill-label {
  display: block;
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.fill-help {
  margin: -0.15rem 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: pre-line;
}

.fill-info-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.info-text {
  margin: 0;
  white-space: pre-line;
}

.fill-input {
  min-height: 2.9rem;
  font-size: 1rem;
}

.fill-narrow {
  max-width: 16rem;
}

.fill-field.has-error .fill-input {
  border-color: var(--danger);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.9rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.choice-item input {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  accent-color: var(--brand);
  margin: 0;
}

.choice-item.checked {
  border-color: var(--brand);
  background: var(--accent);
}

.choice-item:focus-within {
  box-shadow: var(--focus-ring);
}

.checkbox-answer {
  font-weight: 500;
}

/* Rating question (FillRenderer + builder preview): five stars in a row, or a ten-point scale as one connected row of
   segments that shrinks to fit a 360px screen. */
.rating-answer {
  display: flex;
  gap: 0.15rem;
}

.rating-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
  font-weight: 600;
}

.rating-star {
  font-size: 2rem;
  line-height: 1;
  color: #7a6f76;
}

.rating-choice.on .rating-star {
  color: #b07d00;
}

.rating-ten {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0;
  max-width: 32rem;
  border-radius: var(--r);
}

.rating-ten .rating-choice {
  min-width: 0;
  border: 1px solid var(--line);
  margin-left: -1px;
  border-radius: 0;
  background: var(--surface);
}

.rating-ten .rating-choice:first-child {
  margin-left: 0;
  border-radius: var(--r) 0 0 var(--r);
}

.rating-ten .rating-choice:last-child {
  border-radius: 0 var(--r) var(--r) 0;
}

.rating-ten .rating-choice:hover:not(.on) {
  background: var(--accent);
}

.rating-ten .rating-choice.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  position: relative;
}

.rating-choice:focus-within {
  box-shadow: var(--focus-ring);
  position: relative;
  z-index: 1;
}

/* The builder shows the same scale, not clickable. */
.rating-preview .rating-choice {
  cursor: default;
  pointer-events: none;
}

.rating-preview .rating-choice:not(.on) .rating-star {
  color: #9a9096;
}

.rating-preview.rating-ten .rating-choice {
  color: var(--text-muted);
}

/* Likert and matrix: a scale table on wide screens, stacked groups at 640px and below (GridAnswer.razor). */
.grid-answer {
  /* Horizontal scroll is the last resort: only when even the narrowest columns do not fit. */
  overflow-x: auto;
}

.grid-table {
  min-width: calc(8rem + var(--grid-cols, 5) * 3.25rem);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.grid-head,
.grid-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1.6fr) repeat(var(--grid-cols, 5), minmax(3.25rem, 1fr));
  align-items: stretch;
}

.grid-head {
  border-bottom: 1px solid var(--line);
  background: #faf6f9;
  border-radius: var(--r) var(--r) 0 0;
}

.grid-col-label {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.55rem 0.3rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  overflow-wrap: break-word;
  hyphens: auto;
  min-width: 0;
}

.grid-row {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.grid-row + .grid-row {
  border-top: 1px solid #efe8ec;
}

.grid-row:nth-of-type(even) {
  background: #fcfafb;
}

.grid-row-label {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.75rem;
  font-weight: 500;
  overflow-wrap: anywhere;
  min-width: 0;
}

.grid-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  cursor: pointer;
}

.grid-cell input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
  cursor: pointer;
}

.grid-cell.checked {
  background: var(--accent);
}

.grid-cell:focus-within {
  box-shadow: inset var(--focus-ring);
}

/* In the table the column header names each radio, so the text is for assistive technology only. */
.grid-cell-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .grid-answer {
    overflow: visible;
  }

  .grid-table {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
    border: 0;
    background: transparent;
  }

  .grid-head {
    display: none;
  }

  .grid-row,
  .grid-row:nth-of-type(even) {
    display: block;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
  }

  .grid-row + .grid-row {
    border-top: 1px solid var(--line);
  }

  .grid-row-label {
    display: block;
    padding: 0 0.25rem;
  }

  .grid-cell {
    justify-content: flex-start;
    gap: 0.75rem;
    min-height: 2.9rem;
    margin-top: 0.4rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow-wrap: anywhere;
  }

  .grid-cell.checked {
    border-color: var(--brand);
  }

  .grid-cell:focus-within {
    box-shadow: var(--focus-ring);
  }

  .grid-cell-text {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}

.error-summary {
  border-color: var(--danger);
  border-left-width: 6px;
}

.error-summary:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

.error-summary h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--danger);
}

.error-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

.error-summary a {
  color: var(--danger);
}

.fill-actions {
  display: flex;
  justify-content: flex-end;
}

.fill-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text);
}

.fill-state h1 {
  font-size: 1.4rem;
  margin: 0.75rem 0 0.5rem;
}

.fill-thanks {
  border-top: 6px solid var(--success);
}

.fill-thanks:focus {
  outline: none;
}

@media (max-width: 479px) {
  .fill-actions .btn {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .public-main {
    padding-top: 1.5rem;
  }

  .fill-card {
    padding: 1.5rem 1.75rem;
  }

}

/* Responses */
.header-actions {
  display: flex;
  gap: 0.5rem;
}

.stat-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 10rem;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--brand);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.responses-filters {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.responses-filters .search {
  flex: 1 1 16rem;
}

.date-filter {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.date-filter .input {
  min-width: 10rem;
}

.table-scroll {
  position: relative; /* keeps visually hidden (absolute) header text inside the scroll box */
  overflow-x: auto;
  border-radius: var(--r);
}

.responses-table td.cell-clip {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.responses-table tr.selected {
  background: var(--accent);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgb(0 0 0 / 30%);
}

.drawer {
  position: fixed;
  z-index: 56;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(32rem, 100vw);
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -10px 0 40px rgb(0 0 0 / 20%);
  padding: 1rem 1.25rem 2rem;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin: 0 -1.25rem 1rem;
  padding: 0 1.25rem 0.75rem;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1.25rem;
}

.detail-meta dt {
  color: var(--text-muted);
}

.detail-meta dd {
  margin: 0;
}

.detail-answers {
  margin: 0;
  padding-left: 1.25rem;
}

.detail-answers li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-question {
  margin: 0 0 0.2rem;
  font-weight: 600;
}

.detail-answer {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  .builder-actions .btn-text {
    /* Visually hidden, still the button's accessible name (icon-only below 768 px). */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ---------- Slice B1: derived status, Sections, Conditions, settings, steps ---------- */
.status-scheduled {
  background: #e8f0fb;
  color: #1d4f91;
  border-color: #bcd2f0;
}

.status-active {
  background: #e3f4e7;
  color: var(--success);
  border-color: #b9e0c3;
}

.status-full {
  background: var(--warning-bg);
  color: #6b4b00;
  border-color: var(--warning-line);
}

.quota-badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
}

.quota-primary {
  background: #e3f4e7;
  color: var(--success);
  border-color: #b9e0c3;
}

.quota-reserve {
  background: var(--warning-bg);
  color: #6b4b00;
  border-color: var(--warning-line);
}

.section-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r);
  background: #fcf8fb;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.section-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brand);
}

.section-title-input,
.section-description-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0.2rem 0.1rem;
}

.section-title-input {
  font-size: 1.1rem;
  font-weight: 600;
}

.section-description-input {
  resize: vertical;
  color: var(--text-muted);
}

.section-title-input:hover,
.section-description-input:hover {
  border-bottom-color: var(--line);
}

.section-title-input:focus,
.section-description-input:focus {
  outline: none;
  box-shadow: none;
  border-bottom: 2px solid var(--brand);
}

.section-condition {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.75rem;
}

.icon-btn.active {
  background: var(--accent);
  color: var(--accent-foreground);
}

.add-section {
  align-self: center;
}

.condition-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1d4f91;
  background: #e8f0fb;
  border: 1px solid #bcd2f0;
  min-width: 0;
  max-width: 100%;
}

.condition-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 22rem;
}

.condition-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.condition-explain {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.condition-explain p {
  margin: 0 0 0.25rem;
}

.condition-example {
  padding-left: 0.6rem;
  border-left: 3px solid #bcd2f0;
}

.condition-empty,
.condition-sentence {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r);
  font-size: 0.875rem;
}

.condition-empty {
  background: var(--warning-bg);
  border: 1px solid var(--warning-line);
}

.condition-empty p,
.condition-sentence p {
  margin: 0;
}

.condition-empty p + p {
  margin-top: 0.25rem;
}

.condition-sentence {
  color: #1d4f91;
  background: #e8f0fb;
  border: 1px solid #bcd2f0;
  font-weight: 500;
}

.condition-sentence.pending {
  color: var(--text-muted);
  background: transparent;
  border-style: dashed;
  border-color: var(--line);
  font-weight: 400;
}

.condition-empty svg,
.condition-sentence svg {
  flex: none;
  margin-top: 0.15rem;
}

.condition-combinator-label {
  color: var(--text-muted);
}

.condition-rules {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.condition-rule {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  position: relative;
}

.condition-rule .icon-btn {
  justify-self: end;
}

.condition-values {
  border: 0;
  margin: 0;
  padding: 0;
}

.move-to-section {
  width: auto;
  max-width: 14rem;
}

.input-sm {
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.dialog-actions-wrap {
  flex-wrap: wrap;
}

.settings-group {
  padding: 0 0 1rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}

.settings-group:last-child {
  border-bottom: 0;
}

.settings-group fieldset {
  border: 0;
  padding: 0;
}

/* One section is saving: only it dims. Its controls stay enabled so the one in use keeps keyboard focus. */
.settings-group[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
  cursor: progress;
}

.settings-feedback {
  margin: 0.5rem 0 0;
  color: var(--text-muted, inherit);
}

.settings-feedback:empty {
  margin: 0;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fill-progress {
  margin-top: 0.75rem;
}

.fill-progress-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.fill-progress-track {
  height: 0.5rem;
  border-radius: 999px;
  background: #efe7ec;
  overflow: hidden;
}

.fill-progress-bar {
  height: 100%;
  background: var(--brand);
  transition: width 0.2s;
}

.fill-section-head {
  margin-bottom: -0.5rem;
}

.fill-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.fill-actions .spacer {
  flex: 1;
}

.fill-actions {
  gap: 0.75rem;
}

.fill-edit-banner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #1d4f91;
}

.fill-application {
  font-size: 1.15rem;
  font-weight: 700;
}

.edit-link-box {
  margin-top: 1.25rem;
  text-align: left;
}

/* ---- Slice B2: notices, consent, files, media ---- */
.dialog-wide {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.read-box {
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.75rem 1rem;
  background: var(--app-bg);
}

.read-box:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.read-box-title {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.read-end {
  height: 1px;
}

.read-hint {
  margin: 0.375rem 0 0.75rem;
}

.consent-card .consent-check.disabled {
  opacity: 0.6;
}

.consent-card.has-error .read-box {
  border-color: var(--danger);
}

.rich-text p {
  margin: 0 0 0.5rem;
}

.rich-text ul,
.rich-text ol {
  margin: 0 0 0.5rem;
  padding-left: 1.25rem;
}

.rich-text a {
  color: var(--brand);
  text-decoration: underline;
}

/* File upload: a dashed drop zone. The native input is stretched over .dropzone-target (transparent) so click, drop, keyboard
   and screen readers all use the real control; chosen files are chips below it, inside the same box. */
.dropzone {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 2px dashed #8f858b;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone-target {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 7rem;
  padding: 1rem;
  text-align: center;
  border-radius: calc(var(--r) - 2px);
}

.dropzone-title {
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dropzone-hint {
  overflow-wrap: anywhere;
}

.dropzone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-input:disabled {
  cursor: not-allowed;
}

.dropzone-input:focus-visible {
  box-shadow: none;
}

.dropzone:has(.dropzone-input:hover),
.dropzone.dragging {
  border-color: var(--brand);
  background: #faf6f9;
}

.dropzone.dragging {
  border-style: solid;
}

.dropzone:has(.dropzone-input:focus-visible) {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.dropzone.disabled {
  opacity: 0.7;
}

.dropzone .file-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
}

/* A chosen file is a chip: icon, name, size and a remove button in one box. */
.dropzone .file-item {
  flex-wrap: nowrap;
  max-width: 100%;
  padding: 0.25rem 0.25rem 0.25rem 0.65rem;
  border-color: var(--brand);
  border-radius: 999px;
  background: #faf6f9;
  color: var(--text);
}

.dropzone .file-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.dropzone .file-item .small {
  flex: none;
  white-space: nowrap;
}

.dropzone .file-item .btn {
  flex: none;
  border-radius: 999px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 2px);
}

.file-name {
  overflow-wrap: anywhere;
  flex: 1 1 10rem;
}

.file-preview {
  align-items: center;
  text-align: center;
  padding: 1.25rem 1rem;
  gap: 0.25rem;
}

.media-figure {
  margin: 0;
}

.media-figure img,
.media-thumb {
  max-width: 100%;
  height: auto;
  border-radius: var(--r);
}

.media-thumb {
  max-height: 12rem;
}

.media-pdf {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.media-pdf iframe {
  width: 100%;
  height: 28rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.media-video {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
}

.media-video iframe,
.video-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--r);
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #1f1f23;
  color: #fff;
  cursor: pointer;
  padding: 1rem;
  text-align: center;
}

.video-placeholder:focus-visible {
  box-shadow: var(--focus-ring);
}

.media-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  text-decoration: none;
}

.media-link > span {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-wrap: anywhere;
}

.media-link:hover {
  border-color: var(--brand);
}

.media-editor {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  align-items: flex-start;
}

.media-editor .input {
  width: 100%;
}

.media-file {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.25rem;
}

.responsibility {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

/* Slice C1: Summary tab, export menu and export list (FR-37–FR-40). */
.responses-tabs {
  margin-bottom: 1rem;
  width: fit-content;
}

.responses-tabs .tab {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.menu-anchor {
  position: relative;
}

.menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 30;
  min-width: 15rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgb(31 26 29 / 14%);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: calc(var(--r) - 3px);
  background: transparent;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--accent, #f7e8f3);
  color: var(--brand);
}

.menu-note {
  margin: 0.35rem 0.75rem 0.25rem;
}

.export-list {
  margin-bottom: 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.export-list summary {
  cursor: pointer;
  font-weight: 600;
}

.export-list ul {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.export-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

.export-format {
  font-weight: 600;
  min-width: 5.5rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eeeaec;
  color: var(--text-muted);
}

.badge-info {
  background: #f7e8f3;
  color: #5c0e48;
}

.badge-error {
  background: #fde8e7;
  color: var(--danger);
}

.summary-tab .stat-cards {
  flex-wrap: wrap;
}

.stat-value-sm {
  font-size: 1.05rem;
  padding: 0.45rem 0;
}

.stat-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.stat-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.stat-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.chart-box {
  position: relative;
  width: 100%;
  max-width: 48rem;
  margin: 0.5rem 0;
}

.stat-table {
  max-width: 48rem;
  margin-top: 0.5rem;
}

/* Label left, count right with a clear gap between them (a bare table has none). */
.stat-status-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 22rem;
}

.stat-status-table th,
.stat-status-table td {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.stat-status-table th {
  padding-right: 2rem;
  text-align: left;
  font-weight: 500;
}

.stat-status-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.stat-status-table tr:last-child th,
.stat-status-table tr:last-child td {
  border-bottom: 0;
}

.stat-table .num {
  text-align: right;
  white-space: nowrap;
}

.stat-table-toggle summary {
  cursor: pointer;
  color: var(--brand);
  margin-top: 0.25rem;
}

.stat-facts {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.stat-facts dt {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stat-facts dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand);
}

.recent-answers {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.recent-answers li {
  margin-bottom: 0.25rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  .menu-popover {
    left: 0;
    right: auto;
  }
}

/* ---- Form Themes on the fill page (FR-46): the layout root carries the allow-listed tokens ---- */
.public-shell.themed {
  --brand: var(--color-primary, #a0197d);
  --brand-hover: var(--color-primary, #86146a);
  --primary: var(--color-primary, #a0197d);
  --primary-foreground: var(--color-primary-contrast, #ffffff);
  --ring: var(--color-primary, #a0197d);
  --app-bg: var(--color-bg, #f7f4f6);
  --surface: var(--color-surface, #ffffff);
  --text: var(--color-text, #1f1a1d);
  --text-muted: var(--color-text-muted, #5c5459);
  --line: var(--color-border, #ddd5da);
  --r: var(--radius, 0.625rem);
  color: var(--text);
}

.public-shell.themed .public-header {
  background: var(--color-header-bg, var(--brand));
  color: var(--color-header-text, #fff);
  border-bottom: 1px solid var(--line);
}

.public-shell.themed .public-header .app-brand {
  color: var(--color-header-text, #fff);
}

/* ---- Theme picker with live preview (Form ayarları) ---- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 2px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.theme-option.selected {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.theme-option:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.theme-swatch {
  display: block;
  border-radius: calc(var(--radius, 8px) * 0.75);
  overflow: hidden;
  border: 1px solid var(--color-border, #ddd);
  background: var(--color-bg, #f5f5f5);
}

.theme-swatch-header {
  display: block;
  height: 0.9rem;
  background: var(--color-header-bg, #a0197d);
}

.theme-swatch-body {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem;
}

.theme-swatch-card {
  flex: 1;
  height: 1.4rem;
  border-radius: var(--radius, 6px);
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-top: 3px solid var(--color-primary, #a0197d);
}

.theme-swatch-button {
  width: 1.6rem;
  height: 0.8rem;
  border-radius: var(--radius, 6px);
  background: var(--color-primary, #a0197d);
}

.theme-preview {
  margin-top: 0.75rem;
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius, var(--r));
  overflow: hidden;
  background: var(--color-bg, var(--app-bg));
  color: var(--color-text, var(--text));
}

.theme-preview-header {
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--color-header-bg, var(--brand));
  color: var(--color-header-text, #fff);
}

.theme-preview-body {
  padding: 0.75rem;
}

.theme-preview-card {
  padding: 0.75rem;
  border-radius: var(--radius, var(--r));
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, var(--line));
  border-top: 4px solid var(--color-primary, var(--brand));
}

.theme-preview-card p {
  margin: 0 0 0.5rem;
}

.theme-preview-card .muted-text {
  color: var(--color-text-muted, var(--text-muted));
  font-size: 0.85rem;
}

.theme-preview-button {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius, var(--r));
  background: var(--color-primary, var(--brand));
  color: var(--color-primary-contrast, #fff);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---- Share dialog: QR and e-mail ---- */
.share-section {
  border-top: 1px solid var(--line);
  margin-top: 1rem;
  padding-top: 0.75rem;
}

.share-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.qr-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.qr-box {
  width: 9.5rem;
  height: 9.5rem;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.qr-box svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.share-dialog textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
}

/* ---- Collaborators dialog ---- */
.collab-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.collab-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.collab-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  flex-wrap: wrap;
}

.collab-who {
  flex: 1;
  min-width: 10rem;
}

.collab-who strong {
  display: block;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.25rem 0.75rem;
  margin: 0.5rem 0;
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.perm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.perm-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 0.75rem;
}

/* ---- Template picker and gallery ---- */
.template-dialog {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) * 1.2);
  background: var(--surface);
  text-align: left;
  font: inherit;
  color: inherit;
}

button.template-card {
  cursor: pointer;
}

button.template-card:hover:not(:disabled),
button.template-card:focus-visible {
  border-color: var(--brand);
}

.template-card h3 {
  margin: 0;
  font-size: 1rem;
}

.template-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.template-card .template-icon {
  color: var(--brand);
}

.template-card.blank {
  border-style: dashed;
}

.template-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
  flex-wrap: wrap;
}

.section-heading {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
}

/* ---------- Admin panel (slice D1) ---------- */
.admin-content {
  min-width: 0;
}

.admin-content .page {
  max-width: none;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 0.35rem;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.page-description {
  margin: 0.25rem 0 0;
  max-width: 48rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1rem;
}

.admin-grid > .stat-panel {
  margin-bottom: 0;
}

.admin-grid + .admin-grid,
.admin-grid + .stat-panel {
  margin-top: 1rem;
}

.admin-stat-cards {
  flex-wrap: wrap;
}

.admin-stat-cards .stat-card {
  flex: 1 1 10rem;
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
}

.admin-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.admin-card:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0 1rem;
}

.admin-filters .input-inline {
  width: auto;
  min-width: 10rem;
}

.admin-form-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-form-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.admin-form-list li:last-child {
  border-bottom: 0;
}

.admin-form-list-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.admin-facts {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) 1fr;
  gap: 0.4rem 1rem;
  margin: 0.5rem 0 1rem;
}

.admin-facts dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-facts dd {
  margin: 0;
}

.admin-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-inline-field {
  margin-top: 1rem;
}

.admin-role-list {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem;
  min-height: 2.75rem;
  border-radius: calc(var(--r) - 3px);
  cursor: pointer;
}

.admin-check:hover {
  background: var(--app-bg);
}

.admin-check input {
  margin-top: 0.25rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--brand);
}

.admin-check span {
  display: flex;
  flex-direction: column;
}

.admin-check.locked,
.admin-perm-grid label.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.admin-perm-grid {
  border: 0;
  padding: 0;
}

.admin-perm-grid input {
  accent-color: var(--brand);
  width: 1rem;
  height: 1rem;
}

.admin-perm-list {
  columns: 2 18rem;
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.admin-perm-list code {
  margin-left: 0.25rem;
}

.admin-role h2 {
  font-size: 1.05rem;
}

.admin-markdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.admin-markdown textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.admin-editor-dialog {
  width: min(64rem, calc(100vw - 2rem));
}

.admin-picker {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.admin-picker li.muted {
  padding: 0.6rem 0.8rem;
}

.admin-picker-search {
  max-width: none;
}

.admin-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.45rem 0.8rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-picker-item:hover {
  background: var(--app-bg);
}

.admin-picker-item.selected {
  background: var(--accent);
  color: var(--accent-foreground);
}

.admin-template-grid .template-card.archived {
  opacity: 0.75;
  border-style: dashed;
}

.admin-template-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--brand);
}

.admin-template-head h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.admin-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.admin-icon-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 3px);
  cursor: pointer;
}

.admin-icon-option.selected {
  border-color: var(--brand);
  background: var(--accent);
  color: var(--accent-foreground);
}

.admin-icon-option:focus-within {
  box-shadow: var(--focus-ring);
}

.admin-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.admin-theme-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0;
}

.admin-theme-card h2 {
  margin: 0.25rem 0;
  font-size: 1rem;
}

.admin-theme-card .theme-swatch-header {
  height: 1.25rem;
}

.admin-theme-card .theme-swatch-card {
  height: 2.75rem;
}

.admin-theme-card.inactive {
  opacity: 0.7;
}

.admin-theme-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
}

.admin-token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.6rem 1rem;
  border: 0;
  margin: 0;
  padding: 0;
}

.admin-token label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.admin-token input[type="color"] {
  width: 2.75rem;
  height: 2.5rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) - 3px);
  background: var(--surface);
  flex: none;
}

.admin-contrast {
  list-style: none;
  margin: 0.25rem 0;
  padding: 0;
  font-size: 0.88rem;
}

.admin-contrast li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
}

.admin-contrast li strong {
  margin-left: auto;
}

.admin-contrast li.ok {
  color: var(--success);
}

.admin-contrast li.fail {
  color: var(--danger);
}

.admin-settings .field-pair {
  align-items: start;
}

@media (max-width: 767px) {
  .admin-markdown,
  .admin-theme-layout,
  .admin-settings .field-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-filters .input-inline {
    flex: 1 1 100%;
  }

  .admin-facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-facts dd {
    margin-bottom: 0.4rem;
  }
}

/* ---------- Slice D2: audit viewer ---------- */
.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: end;
  margin: 0.75rem 0 1rem;
}

.audit-filters .field {
  margin: 0;
}

.audit-filter-actions {
  display: flex;
  gap: 0.5rem;
}

.audit-table .nowrap {
  white-space: nowrap;
}

.audit-row.selected {
  background: rgb(160 25 125 / 6%);
}

.audit-open {
  padding: 0;
  text-align: left;
}

.audit-drawer {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(32rem, 100vw);
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -12px 0 40px rgb(0 0 0 / 20%);
  padding: 1.25rem 1.25rem 2rem;
}

.audit-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.audit-drawer-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.audit-details-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.audit-value {
  overflow-wrap: anywhere;
}

/* ---------- Slice D2: Impersonation banner and user menu ---------- */
.impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 55;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  background: #7a1d00;
  color: #fff;
  font-weight: 600;
  border-bottom: 3px solid #ffb199;
}

.impersonation-banner form {
  margin: 0;
}

.impersonation-banner .btn {
  background: #fff;
  color: #7a1d00;
  border-color: #fff;
  min-height: 2.25rem;
}

.impersonation-banner .remaining {
  font-weight: 400;
  opacity: 0.9;
}

/* A system-account session (Super Admin mode, emergency sign-in): the same bar in a stronger red. */
.impersonation-banner.system-session {
  background: #9b0000;
}

/* "Süper Yönetici moduna geç" and the emergency form. */
.page.narrow {
  max-width: 40rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-form .form-actions {
  display: flex;
  gap: 0.75rem;
}

.procedure-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  line-height: 1.6;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--r);
  min-height: 2.75rem;
}

.user-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 70;
  min-width: 14rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 12px 30px rgb(0 0 0 / 18%);
}

.user-menu-list button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  padding: 0.6rem 0.75rem;
  border-radius: calc(var(--r) * 0.7);
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  min-height: 2.75rem;
}

.user-menu-list button:hover,
.user-menu-list button:focus-visible {
  background: rgb(160 25 125 / 8%);
}

.impersonate-panel textarea {
  width: 100%;
}

/* ---------- Slice D2: guided tour (driver.js) in the brand colours ---------- */
.driver-popover.maltepe-tour {
  border-radius: calc(var(--r) * 1.2);
  max-width: min(22rem, calc(100vw - 2rem));
  color: var(--text);
}

.driver-popover.maltepe-tour .driver-popover-title {
  font-size: 1.05rem;
}

.driver-popover.maltepe-tour .driver-popover-description {
  font-size: 0.95rem;
  line-height: 1.5;
}

.driver-popover.maltepe-tour .driver-popover-footer button {
  min-height: 2.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: calc(var(--r) * 0.8);
  text-shadow: none;
  font-size: 0.9rem;
}

.driver-popover.maltepe-tour .driver-popover-next-btn {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.driver-popover.maltepe-tour .driver-popover-close-btn {
  color: var(--text-muted);
}

/* driver.js lets the navigation buttons grow, so the skip button's auto margin gets no free space and the progress text
   ("4/7") used to touch it: a gap keeps them apart on the popover and on the phone sheet. */
.driver-popover.maltepe-tour .driver-popover-footer {
  gap: 0.75rem;
}

.driver-popover.maltepe-tour .driver-popover-progress-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.driver-popover.maltepe-tour .tour-skip-btn {
  margin-right: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.driver-popover.maltepe-tour button:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Phones: a bottom sheet instead of a popover next to the target. driver.js positions the popover with inline styles,
   hence !important; the arrow is dropped because the sheet does not point at anything. */
@media (max-width: 640px) {
  .driver-popover.maltepe-tour {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    max-width: none;
    width: auto;
    max-height: 55vh;
    overflow-y: auto;
    margin: 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    border-radius: calc(var(--r) * 1.5) calc(var(--r) * 1.5) 0 0;
    box-shadow: 0 -8px 30px rgb(0 0 0 / 28%);
  }

  .driver-popover.maltepe-tour .driver-popover-arrow {
    display: none;
  }

  .driver-popover.maltepe-tour .driver-popover-footer {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
  }

  .driver-popover.maltepe-tour .driver-popover-footer button {
    min-height: 2.75rem;
    min-width: 2.75rem;
  }

  .driver-popover.maltepe-tour .driver-popover-close-btn {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .driver-popover.maltepe-tour,
  .driver-overlay {
    transition: none !important;
    animation: none !important;
  }
}

/* Super Admin mode orientation: an ordinary card at the top of the page, nothing modal. */
.elevation-orientation {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid #9b0000;
  border-radius: var(--r);
}

.elevation-orientation h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.elevation-orientation ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.audit-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.audit-table td {
  overflow-wrap: anywhere;
}

/* ---------- User typeahead (AD-5) ---------- */
.typeahead {
  position: relative;
}

.typeahead-hint {
  margin: 0.25rem 0 0;
}

.typeahead-list {
  position: absolute;
  z-index: 50;
  top: 2.75rem;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
  max-height: 18rem;
  overflow-y: auto;
}

.typeahead-option {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: baseline;
  min-height: 44px;
  padding: 0.5rem 0.625rem;
  border-radius: calc(var(--r) - 0.25rem);
  cursor: pointer;
}

.typeahead-option.active,
.typeahead-option:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* Feedback round 1: "Doldurduğum formlar", the own Answers view, the admin storage page and upload formats. */
.my-responses-note {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  margin: 0 0 0.75rem;
}

.my-responses-note svg {
  flex: none;
  margin-top: 0.2rem;
}

.open-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.open-badge.open {
  color: #1e5e2e;
  background: #e6f4ea;
  border-color: #b7dfc2;
}

.open-badge.closed {
  color: #5c5459;
  background: #f1edf0;
  border-color: var(--line);
}

.my-response .breadcrumbs {
  margin-bottom: 0.5rem;
}

.my-response-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  margin: 0 0 1rem;
}

.my-response-facts dt {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.my-response-facts dd {
  margin: 0.15rem 0 0;
  font-weight: 500;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.answer-list {
  margin: 0;
}

.answer-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid #efe8ec;
}

.answer-item:last-child {
  border-bottom: 0;
}

.answer-item dt {
  font-weight: 600;
}

.answer-item dd {
  margin: 0.25rem 0 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.answer-item .file-list {
  margin: 0;
}

.my-response-back {
  margin: 0 0 0.75rem;
}

.my-response-back a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.admin-section {
  margin-top: 1.5rem;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  min-height: 2.75rem;
}

.sort-button:hover {
  color: var(--brand);
}

.admin-subheading {
  margin: 1.25rem 0 0.25rem;
  font-size: 1rem;
}

.format-table td {
  vertical-align: middle;
}

.format-table .format-actions {
  text-align: right;
}

.format-table .switch-row {
  min-height: 2.75rem;
}

.format-add {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--r);
}

.format-add legend {
  padding: 0 0.25rem;
  font-weight: 600;
}

.format-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.storage-cell {
  white-space: nowrap;
}

.storage-cell span {
  display: block;
}

.storage-size {
  color: var(--text);
  font-weight: 500;
}

/* Unit and user permissions (admin panel): the permission list with its source and the user's own setting. */
.perm-source-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.perm-source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.perm-source-row:last-child {
  border-bottom: 0;
}

.perm-source-name {
  display: flex;
  flex-direction: column;
  flex: 1 1 16rem;
  min-width: 0;
}

.perm-source-state {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1 1 12rem;
}

.perm-source-setting {
  flex: 0 1 15rem;
}

.perm-source-setting .input {
  width: 100%;
}

.perm-chip.on {
  background: #e7f4ea;
  color: #1e5b2a;
  border-color: #b9dcc1;
}

.perm-chip.off {
  background: #f1eef0;
  color: #4a4247;
}

/* Form settings: unit restriction (Erişimi birimlerle sınırla). */
.restriction-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0;
  padding: 0;
}

.restriction-chips li {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.25rem 0.1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
}

.restriction-chips .icon-btn {
  min-width: 1.75rem;
  min-height: 1.75rem;
}

.restriction-sentence {
  margin: 0.5rem 0;
}

/* ---- Admin: browsing users by category, people lists, read-only form content ---- */
.browse {
  display: grid;
  grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.browse-tree {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 0.75rem;
}

.browse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.browse-units {
  margin: 0.25rem 0 0.5rem 0.75rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--line);
}

.browse-node {
  display: flex;
  width: 100%;
  min-height: 2.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border: 0;
  border-radius: calc(var(--r) - 3px);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.browse-node:hover {
  background: var(--accent);
}

.browse-node.selected {
  background: var(--brand);
  color: #fff;
}

.browse-node.selected .count-pill {
  background: #fff;
  color: var(--brand);
}

.browse-directory {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.browse-panel {
  margin-bottom: 0;
  min-width: 0;
}

.never-signed-in {
  white-space: nowrap;
}

.people-table {
  width: 100%;
}

.form-content .content-questions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.form-content .content-question {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.75rem 1rem;
  background: var(--surface);
}

.form-content .content-question-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.form-content .content-lines,
.form-content .content-options ul {
  margin: 0.25rem 0 0.25rem 1.25rem;
  padding: 0;
}

.form-content .condition-note {
  margin: 0.5rem 0 0;
}

.form-content .consent-content {
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

@media (max-width: 767px) {
  .browse {
    grid-template-columns: minmax(0, 1fr);
  }
}
