/* =====================================================================
   Public feedback forms. Requires tokens.css + components.css.
   ===================================================================== */
.form-page { padding-bottom: env(safe-area-inset-bottom); }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 600; padding: 8px 14px; border-radius: var(--r-pill); background: var(--accent); color: var(--ink-on-accent); }
.skip-link:focus { top: 12px; }

/* App bar (glass) */
.appbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 56px; padding: var(--s-2) max(var(--s-5), env(safe-area-inset-right)) var(--s-2) max(var(--s-5), env(safe-area-inset-left));
  background: var(--material); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 0.5px 0 var(--separator);
}
.appbar-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: var(--t-callout); letter-spacing: 0; }
.appbar-brand:hover { text-decoration: none; }
.appbar-brand img { width: 28px; height: 28px; border-radius: 7px; }
.appbar-nav { display: flex; gap: 2px; margin-inline-start: auto; padding: 3px; border-radius: var(--r-pill); background: var(--fill); }
.appbar-nav a { padding: 6px 14px; border-radius: var(--r-pill); color: var(--ink); font-size: var(--t-footnote); font-weight: 590; white-space: nowrap; }
.appbar-nav a:hover { text-decoration: none; background: var(--fill); }
.appbar-nav a[aria-current="page"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
:root[data-theme="dark"] .appbar-nav a[aria-current="page"] { background: #636366; }

/* Sheet */
.sheet { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 var(--s-5) var(--s-12); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-8); align-items: end; padding: var(--s-12) 0 var(--s-8); }
.kicker { font-size: var(--t-callout); font-weight: 590; color: var(--accent); margin-bottom: var(--s-2); }
.hero h1 { font-size: clamp(34px, 5.4vw, 52px); font-weight: 750; letter-spacing: -0.035em; line-height: 1.04; text-wrap: balance; }
.lede { margin-top: var(--s-4); max-width: 60ch; font-size: var(--t-headline); line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.dept-chip { display: inline-flex; align-items: center; gap: var(--s-2); margin-top: var(--s-5); padding: 6px 6px 6px 14px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-card); font-size: var(--t-footnote); color: var(--ink-2); }
[dir="rtl"] .dept-chip { padding: 6px 14px 6px 6px; }
.dept-chip strong { padding: 4px 12px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }

.brand-tile {
  position: relative; display: grid; place-items: center;
  width: 132px; height: 132px; border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden;
}
.brand-tile img { display: none; width: 100%; height: 100%; object-fit: contain; padding: 14px; background: #fff; }
.brand-tile.has-image img { display: block; }
.brand-upload {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px;
  color: var(--ink-2); font-size: var(--t-caption); font-weight: 590; text-align: center; cursor: pointer;
  border-radius: inherit; box-shadow: inset 0 0 0 1.5px var(--separator-strong); transition: background-color var(--dur-fast);
}
.brand-upload:hover { background: var(--fill); }
.brand-tile.has-image .brand-upload { opacity: 0; box-shadow: none; }
.brand-tile.has-image .brand-upload:hover { opacity: 1; background: rgba(0,0,0,.45); color: #fff; }
.brand-upload .ico { width: 22px; height: 22px; }
.brand-tile:focus-within { box-shadow: var(--focus-ring); }

/* Progress */
.progress-bar {
  position: sticky; top: 56px; z-index: 40;
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin: 0 calc(var(--s-5) * -1) var(--s-6); padding: var(--s-3) var(--s-5);
  background: var(--material); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font-size: var(--t-footnote); color: var(--ink-2);
}
.progress-track { flex: 1 1 160px; height: 6px; border-radius: var(--r-pill); background: var(--fill); overflow: hidden; }
.progress-fill { inline-size: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: inline-size var(--dur) var(--ease); }
#progressLabel { font-weight: 590; color: var(--ink); font-variant-numeric: tabular-nums; }
.draft-state { color: var(--ink-3); }

/* Sections — grouped, inset lists */
.form-section { margin-bottom: var(--s-8); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin: 0 var(--s-1) var(--s-3); }
.section-head h2 { display: flex; align-items: baseline; gap: 10px; font-size: var(--t-title3); letter-spacing: -0.02em; }
.section-head p { margin-top: 4px; font-size: var(--t-footnote); color: var(--ink-2); }
.section-num { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-footnote); font-weight: 700; font-variant-numeric: tabular-nums; }
.section-count { flex: none; padding: 3px 10px; border-radius: var(--r-pill); background: var(--fill); font-size: var(--t-caption); font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.section-count.is-complete { background: var(--green-soft); color: var(--green); }
.group { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.group-pad { padding: var(--s-5) var(--s-5) var(--s-1); }
.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-4); }

/* Criterion row with a 1–5 segmented rating */
.criterion { border: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-4) var(--s-5); }
.criterion + .criterion { border-top: 1px solid var(--separator); }
.criterion-title { float: none; padding: 0; font-size: var(--t-body); font-weight: 590; }
.criterion-value { justify-self: end; font-size: var(--t-footnote); color: var(--ink-3); }
.criterion.is-rated .criterion-value { color: var(--accent-ink); font-weight: 590; }
.rate-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: 30px; background: var(--fill); }
.rate { position: relative; display: block; cursor: pointer; }
.rate input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rate span { display: grid; place-items: center; gap: 1px; min-height: 52px; padding: 6px 4px; border-radius: 27px; text-align: center; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast) var(--ease); }
.rate b { font-size: var(--t-headline); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rate small { font-size: 11px; color: var(--ink-2); line-height: 1.2; }
.rate:hover span { background: var(--fill); }
.rate input:focus-visible + span { box-shadow: var(--focus-ring); }
.rate input:checked + span { background: var(--accent); color: var(--ink-on-accent); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.rate input:checked + span small { color: inherit; opacity: 0.9; }
.rate:active span { transform: scale(0.97); }

/* Legend */
.scale-legend { margin: calc(var(--s-4) * -1) var(--s-1) var(--s-6); font-size: var(--t-footnote); color: var(--ink-2); }
.scale-legend summary { cursor: pointer; color: var(--accent); font-weight: 590; width: fit-content; }
.scale-legend ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-top: var(--s-3); }
.scale-legend li { display: inline-flex; align-items: center; gap: 6px; }
.scale-legend b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--fill); color: var(--ink); font-size: var(--t-caption); }

/* Summary */
.score-strip { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.score-strip > div { padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-sunken); }
.score-strip dt { font-size: var(--t-caption); color: var(--ink-2); font-weight: 510; }
.score-strip dd { margin-top: 4px; font-family: var(--font-display); font-size: var(--t-title2); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.score-strip .score-main { background: var(--accent-soft); }
.score-strip .score-main dd { font-size: 40px; line-height: 1; color: var(--accent-ink); }
fieldset.form-group { border: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-4); border-radius: var(--r-pill); background: var(--fill); font-size: var(--t-footnote); font-weight: 590; transition: background-color var(--dur-fast), color var(--dur-fast); }
.chip:hover span { background: var(--fill-strong); }
.chip input:checked + span { background: var(--accent); color: var(--ink-on-accent); }
.chip input:focus-visible + span { box-shadow: var(--focus-ring); }

/* Actions */
.form-actions { padding-top: var(--s-2); }
.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.actions-row .btn .ico { width: 16px; height: 16px; }
.btn[data-busy="true"] { position: relative; color: transparent; }
.btn[data-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink-on-accent); border-inline-end-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.submit-status:not(:empty) { margin-bottom: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--fill); font-size: var(--t-footnote); }
.submit-status[data-tone="error"] { background: var(--red-soft); color: var(--red); font-weight: 510; }
.footer-note { margin-top: var(--s-4); font-size: var(--t-footnote); color: var(--ink-2); line-height: 1.55; }

/* Confirmation */
.done-dialog { margin: auto; width: min(420px, calc(100vw - 32px)); padding: var(--s-8) var(--s-6) var(--s-6); border: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); text-align: center; }
.done-dialog[open] { animation: pop 420ms var(--ease-out); }
.done-dialog::backdrop { background: rgba(0,0,0,.32); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.done-mark { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto var(--s-4); border-radius: 50%; background: var(--green-soft); color: var(--green); }
.done-mark .ico { width: 36px; height: 36px; }
.done-dialog h2 { font-size: var(--t-title2); margin-bottom: var(--s-2); }
.done-dialog p { color: var(--ink-2); margin-bottom: var(--s-6); }
.done-dialog .actions-row { justify-content: center; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

/* Responsive */
@media (max-width: 680px) {
  .appbar { gap: var(--s-2); padding-inline: var(--s-3); }
  .appbar-brand span { display: none; }
  .appbar-nav a { padding: 6px 10px; }
  .sheet { padding: 0 var(--s-4) var(--s-10); }
  .hero { grid-template-columns: 1fr; gap: var(--s-5); padding: var(--s-8) 0 var(--s-6); }
  .brand-tile { width: 88px; height: 88px; border-radius: var(--r-lg); order: -1; }
  .lede { font-size: var(--t-body); }
  .progress-bar { margin-inline: calc(var(--s-4) * -1); padding-inline: var(--s-4); }
  .fields-grid { grid-template-columns: 1fr; }
  .criterion { padding: var(--s-4); }
  .rate small { display: none; }
  .rate span { min-height: 46px; }
  .score-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .score-strip .score-main { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
  .actions-row .btn { flex: 1 1 auto; }
  .actions-row .btn-primary { flex-basis: 100%; }
}

/* Print: a clean, paper-ready record */
@media print {
  :root { --canvas: #fff; }
  .appbar, .progress-bar, .form-actions .actions-row, .skip-link, .toast-container, .brand-upload, .scale-legend summary, .done-dialog { display: none !important; }
  .scale-legend { display: block; } .scale-legend ol { display: flex !important; }
  .sheet { max-width: none; padding: 0; }
  .hero { padding: 0 0 12px; }
  .hero h1 { font-size: 26px; }
  .group, .score-strip > div { box-shadow: none; border: 1px solid #d2d2d7; }
  .rate span { min-height: 0; padding: 4px; }
  .rate input:checked + span { background: #1d1d1f !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .form-section { break-inside: avoid; margin-bottom: 14px; }
  .criterion { break-inside: avoid; padding: 8px 12px; }
}
