.check-header { gap: 28px; }
.check-header nav a { font-size: 14px; }
.check-header nav a:hover { color: #fff; }
.check-header-context { margin-left: auto; font-size: 13px; }
.check-header-context:not([hidden]) { display: flex; align-items: center; gap: 10px; }
.cabinet-profile, [data-theme="dark"] .cabinet-profile {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
}
.cabinet-profile:hover, [data-theme="dark"] .cabinet-profile:hover { background: #273c4a; }
#cabinet-username { max-width: min(18ch, 24vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  background: #244441;
  color: #a5efe0;
  font-size: 12px;
  font-weight: 700;
}
.profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mobile-preferences, .mobile-delete { display: none; }
.auth-screen { max-width: 480px; }
.auth-screen .panel-head h1 { font-size: 21px; margin: 0; }
.auth-description { margin: 0; color: var(--muted); }
.auth-modes { display: flex; gap: 4px; padding: 4px; border-radius: 7px; background: #f1f5f5; }
.auth-modes button { flex: 1; border-color: transparent; color: var(--muted); background: transparent; }
.auth-modes button[aria-pressed="true"] { background: #fff; border-color: #d7e7e2; color: var(--teal); }
.auth-message, .history-message { margin: 0; padding: 12px 18px; color: var(--muted); }
.auth-message:empty, .history-message:empty { display: none; }
.auth-message { padding-top: 0; }
.auth-screen form[hidden] + .auth-message { padding-top: 12px; }
.check-main { max-width: 1120px; padding: 36px 28px 48px; font-size: 14px; }
.cabinet-title { margin: 0 0 20px; font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; }
.check-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); align-items: start; gap: 18px; }
.check-main .panel-head { padding: 15px 20px; min-height: 56px; }
.check-main .panel-head h2 { font-size: 16px; font-weight: 650; }
.check-main .pill { font-size: 11px; }
.check-form { display: grid; gap: 14px; padding: 16px 18px; }
.check-form label { display: block; margin-bottom: 5px; font-weight: 650; }
.check-form input:not([type="hidden"]) { display: block; width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 5px; font: inherit; color: var(--ink); background: #f8fafb; }
.check-form input[type="url"] { background: #fff; }
.check-form input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.check-form button { justify-self: start; }
.check-form .note { margin: 0; }
.check-form .note:empty { display: none; }
.check-composer { margin-bottom: 18px; }
.check-composer .check-form { gap: 10px; padding: 18px 20px; }
.check-composer label { margin-bottom: 7px; font-size: 15px; }
.check-url-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, max-content); gap: 10px; }
.check-url-row input:not([type="hidden"]) { min-height: 42px; padding-inline: 12px; }
.check-url-row button { width: 100%; min-height: 42px; padding-inline: 16px; font-size: 14px; font-weight: 600; }
.check-composer .note { font-size: 12px; }
#partner-url-help { margin-top: 6px; }
.check-disclosure summary { width: fit-content; cursor: pointer; font-weight: 600; }
.check-disclosure summary::marker { color: var(--teal); }
.check-disclosure summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 2px; }
.check-terms { padding-top: 1px; }
.check-terms p { margin: 8px 0 4px; }
.check-main .textlink { font-size: inherit; }
.check-main .textlink:hover { text-decoration: underline; }
.check-links { padding: 11px 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; }
.check-result { padding: 16px 20px 20px; }
.check-empty, .check-summary { margin: 0; line-height: 1.55; }
.check-empty { color: var(--muted); }
.check-time { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.check-id { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.check-steps { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.check-step { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.check-step-title { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.check-step p { margin: 5px 0 0; }
.check-result > :is(.check-finding, .check-review, .check-sources, .check-more) {
  margin-top: clamp(21px, 3vw, 28px);
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.check-finding h3 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.check-quotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check-quotes .version { margin: 0; }
.check-quotes .version span { font-size: 12px; }
.check-quotes p { margin: 4px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.check-basis { margin-top: 10px; }
.check-basis p { margin: 4px 0; }
.check-review { display: grid; gap: 16px; }
.check-review h3, .check-review legend { margin: 0; font-size: 14px; font-weight: 650; }
.check-review p { margin: 0; }
.check-review fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.check-review-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.check-review-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.check-review-option input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.check-review-option :checked + span { color: var(--teal); font-weight: 650; }
.check-comment textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  resize: vertical;
  font: inherit;
}
.check-review-footer {
  margin-top: 28px;
  padding: 12px;
  border-radius: 10px;
  background: #e9f4f1;
}
.check-review-footer .check-review-save {
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border-radius: 7px;
  font-size: 16px;
  font-weight: 700;
}
.check-saved-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.check-correction {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.check-correction-request { margin: 24px 0 0; }
.check-correction :is(h3, p) { margin: 0; }
.check-correction h3 { font-size: 14px; }
.check-correction .check-more-actions { margin-top: 0; }
#cabinet-title:focus-visible, #result-heading:focus-visible, #history-heading:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 2px;
}
.history-filter { padding: 12px 18px 14px; border-bottom: 1px solid var(--line); }
#history-filter-label { margin: 0 0 8px; font-size: 12px; font-weight: 650; }
.history-filter-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.history-filter-options button {
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1.25;
}
.history-filter-options button[aria-pressed="true"] {
  border-color: var(--teal);
  background: #e9f4f1;
  color: var(--teal);
}
.history-filter .history-message { padding: 8px 0 0; font-size: 12px; }
.check-history ol { max-height: 420px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.check-history li + li { border-top: 1px solid var(--line); }
.check-history-entry {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 11px 17px;
  border: 0;
  border-inline-start: 3px solid transparent;
  border-radius: 0;
  text-align: start;
}
.check-history-entry[aria-current="true"] { border-inline-start-color: var(--teal); background: #f1f7f6; }
.check-history-entry:focus-visible { outline-offset: -3px; }
.check-history-source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.check-history-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.check-history time, .check-history-decision { color: var(--muted); font-size: 11px; }
.check-history-meta .check-id { font-size: 11px; }
.check-history-correction { color: var(--teal); }
.check-more-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.history-delete { color: var(--red); }
.check-result > .mobile-delete[data-outside-filter] { display: block; margin-top: 14px; }

.cabinet-dialog {
  width: min(420px, calc(100% - 32px));
  padding: clamp(18px, 5vw, 24px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgb(18 44 58 / 24%);
  color: var(--ink);
}

.cabinet-dialog h2 { margin: 0 0 8px; font-size: 21px; font-weight: 650; letter-spacing: -.3px; }
.cabinet-dialog::backdrop { background: rgb(18 35 49 / 49%); backdrop-filter: blur(2px); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dialog-actions button { min-height: 42px; font-weight: 600; }
.cabinet-dialog .dialog-message { margin: 0 0 12px; color: var(--muted); }
.dialog-message:empty { display: none; }
.preferences-dialog h2 { margin-bottom: 18px; }
.preferences-dialog fieldset { display: grid; gap: 6px; min-width: 0; margin: 0 0 18px; padding: 0; border: 0; }
.preferences-dialog label { font-size: 14px; font-weight: 600; }
.preferences-dialog select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.preferences-dialog select + label { margin-top: 8px; }
.preferences-dialog select:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.avatar-setting {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.avatar-preview { width: 56px; height: 56px; font-size: 19px; }
.avatar-setting-content { min-width: 0; }
.avatar-setting-title { margin: 0 0 5px; font-size: 14px; font-weight: 650; }
.avatar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.avatar-file { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.preferences-dialog .avatar-upload {
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--teal);
  font-size: 13px;
  cursor: pointer;
}
.avatar-upload:hover { background: var(--bg); }
.avatar-file:focus-visible + .avatar-upload { outline: 2px solid var(--teal); outline-offset: 2px; }
.avatar-file:disabled + .avatar-upload { opacity: .55; cursor: default; }
#avatar-remove { min-height: 36px; border-color: transparent; color: var(--red); }
.avatar-hint { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.preferences-dialog #avatar-message { margin: 0 0 6px; font-size: 13px; }

.delete-dialog { border: 0; }
.delete-dialog .dialog-actions button:focus-visible {
  outline: none;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.delete-dialog-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  border-radius: 11px;
  background: #faedef;
  color: #a0313b;
  font-size: 22px;
  font-weight: 650;
}

.delete-dialog #delete-description { margin: 0; color: var(--muted); }
.delete-dialog-record {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin: 16px 0 20px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f7f9fa;
}

.delete-dialog-record time { font-variant-numeric: tabular-nums; font-weight: 600; }
.delete-dialog-record strong { width: 100%; overflow-wrap: anywhere; }
.dialog-actions .delete-confirm { background: #ae3540; border-color: #ae3540; color: #fff; }
.dialog-actions .delete-confirm:hover { background: #932a34; border-color: #932a34; }

@media (prefers-reduced-motion: no-preference) {
  .cabinet-dialog[open] { animation: dialog-in 190ms cubic-bezier(.2, .65, .3, 1); }
  .cabinet-dialog[open]::backdrop { animation: dialog-backdrop-in 160ms ease-out; }
}

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

@keyframes dialog-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

[hidden] { display: none; }
.check-header [hidden] { display: none; }

#auth-heading .text-reveal { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .reveal-result > *, .reveal-result .check-step {
    animation: text-in 240ms cubic-bezier(.2, .65, .3, 1) var(--reveal-delay, 0ms) backwards;
  }
  .reveal-result .check-steps { animation: none; }
  .reveal-result .check-step { --reveal-delay: 65ms; }
  .reveal-result .check-step + .check-step { --reveal-delay: 105ms; }
  .reveal-result .check-finding { --reveal-delay: 140ms; }
  .reveal-result .check-more, .reveal-result .check-review { --reveal-delay: 170ms; }
  .reveal-result :focus-within { animation: none; }
}

@media (max-width: 760px) {
  .check-layout { grid-template-columns: minmax(0, 1fr); }
  .check-header { gap: 12px; flex-wrap: wrap; min-height: 72px; height: auto; padding-block: 10px; }
  .check-header nav { width: auto; margin-right: auto; gap: 16px; }
  .check-main { padding-inline: 18px; }
}

:root[data-density="compact"] .check-main { padding-block-start: 22px; }
:root[data-density="compact"] .cabinet-title { margin-bottom: 12px; }
:root[data-density="compact"] .check-composer .check-form { gap: 7px; padding-block: 12px; }
:root[data-density="compact"] .check-main .panel-head { min-height: 48px; padding-block: 9px; }
:root[data-density="compact"] .check-history-entry { gap: 4px; padding-block: 7px; }
:root[data-density="compact"] .check-result { padding-block: 11px 14px; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101922;
  --ink: #e8eff5;
  --muted: #acbcca;
  --line: #34495a;
  --teal: #77d6c5;
  --red: #ffa8af;
  --amber: #f2cb83;
  --green: #8fe0ba;
}

[data-theme="dark"] :is(.panel, .cabinet-dialog),
[data-theme="dark"] button,
[data-theme="dark"] .check-form input:not([type="hidden"]),
[data-theme="dark"] .check-comment textarea,
[data-theme="dark"] .preferences-dialog select {
  background: #1b2936;
  color: var(--ink);
}

[data-theme="dark"] .history-delete { color: var(--red); }
[data-theme="dark"] button:hover { background: #273c4a; }
[data-theme="dark"] .primary { background: #08776a; border-color: #08776a; color: #fff; }
[data-theme="dark"] .primary:hover { background: #0a685d; }
[data-theme="dark"] .secondary { background: #25423f; border-color: #385e57; color: var(--teal); }
[data-theme="dark"] .secondary:hover, [data-theme="dark"] .check-history-entry[aria-current="true"] { background: #244441; }
[data-theme="dark"] .check-review-footer { background: #243645; }
[data-theme="dark"] .history-filter-options button[aria-pressed="true"] { background: #244441; color: var(--teal); }
[data-theme="dark"] :is(.check-quotes .version, .delete-dialog-record) { background: #243645; }
[data-theme="dark"] .pill { background: #304452; color: #d4e3ef; }
[data-theme="dark"] .pill.high, [data-theme="dark"] .delete-dialog-mark { background: #512e39; color: var(--red); }
[data-theme="dark"] .pill.medium { background: #493b24; color: var(--amber); }
[data-theme="dark"] .pill.ok { background: #244338; color: var(--green); }
[data-theme="dark"] .delete-confirm { background: #ae3540; color: #fff; }
[data-theme="dark"] .delete-confirm:hover { background: #932a34; }

@media (max-width: 640px) {
  html { scroll-padding-block: 12px calc(78px + env(safe-area-inset-bottom, 0px)); }

  .check-header {
    flex-wrap: nowrap;
    min-height: 64px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
      8px max(16px, env(safe-area-inset-left, 0px));
  }

  .check-header-context:not([hidden]) { gap: 6px; }
  #cabinet-username { max-width: 22vw; }
  #preferences-button { display: none; }
  .check-header-context button { min-height: 44px; }

  .check-header #cabinet-nav:not([hidden]) {
    position: fixed;
    inset: auto 0 0;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 7px max(12px, env(safe-area-inset-right, 0px))
      calc(7px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 -6px 22px rgb(24 44 61 / 8%);
  }

  .check-header #cabinet-nav :is(a, .mobile-preferences) {
    display: grid;
    place-items: center;
    height: auto;
    min-height: 48px;
    padding: 6px 2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
  }

  .check-header #cabinet-nav a[aria-current] { background: #e9f4f1; color: var(--teal); }
  [data-theme="dark"] .check-header #cabinet-nav:not([hidden]) { background: #1b2936; }
  [data-theme="dark"] .check-header #cabinet-nav a[aria-current] { background: #244441; }

  .check-main { min-height: calc(100svh - 135px); padding: 22px 14px 24px; }
  .check-main[data-view="history"] :is(.cabinet-title, .check-composer, .check-result-panel),
  .check-main:not([data-view="history"]) .check-history { display: none; }
  .check-layout { gap: 12px; }
  .check-composer { margin-bottom: 12px; }
  .check-composer .check-form, .check-main .panel-head, .check-result, .history-filter { padding-inline: 14px; }
  .check-main .panel-head { flex-wrap: wrap; gap: 5px 10px; }
  .check-main .pill { white-space: normal; }
  .reveal-result > *, .reveal-result .check-step { animation: none; }
  .check-history ol { max-height: none; overflow: visible; }
  .check-history-entry { min-width: 0; }
  .check-step p, .check-finding p { overflow-wrap: anywhere; }
  .check-quotes, .check-url-row { grid-template-columns: minmax(0, 1fr); }

  .auth-screen { min-height: 0; padding: 24px 14px 48px; }
  #auth-submit { width: 100%; }
  .check-main button, .auth-screen button, .dialog-actions button { min-height: 44px; }
  .preferences-dialog .avatar-upload, #avatar-remove { min-height: 44px; }
  .check-disclosure summary { min-height: 44px; padding-block: 10px; }
  .check-result > :is(.check-sources, .check-more) { padding-top: 6px; }
  .check-review-options, .check-more-actions { display: grid; grid-template-columns: 1fr; }
  .check-result > .mobile-delete { display: block; width: 100%; margin-top: 14px; }
  .check-form input:not([type="hidden"]), .check-comment textarea, .preferences-dialog select {
    min-height: 44px;
    font-size: 16px;
  }

  .cabinet-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 24px);
    margin: 0;
    padding: 20px max(16px, env(safe-area-inset-right, 0px))
      calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    border-radius: 18px 18px 0 0;
    overscroll-behavior: contain;
  }

  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #cabinet-screen:not([hidden]) ~ footer { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
}
