.security-app {
  --sec-muted: #606b82;
  --sec-accent: #4a5fca;
  padding-top: 12px;
}
.dark .security-app {
  --sec-muted: #acb7cb;
  --sec-accent: #a0b0ff;
}
.security-app h2 {
  letter-spacing: -0.7px;
}
.security-app p {
  line-height: 1.75;
}
.security-app [hidden] {
  display: none !important;
}
.security-app a {
  color: var(--sec-accent);
}
.sec-unlock-layout,
.sec-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(290px, 1fr);
  gap: 24px;
  align-items: start;
}
.sec-unlock-layout {
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.15fr);
}
.sec-unlock-form,
.sec-sidebar,
.sec-review,
.sec-compare-method {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  padding: 24px;
  min-width: 0;
}
.sec-unlock-form .sec-drop {
  padding: 22px 12px;
  margin: 0 0 24px;
  border-radius: 18px;
}
.sec-drop {
  margin: 12px 0 28px;
  padding: 34px 24px;
  background:
    linear-gradient(135deg, rgba(100, 120, 217, 0.05), transparent 60%),
    var(--surface);
  transition:
    border-color 0.2s,
    background 0.2s;
}
.sec-drop.drag-over {
  border-color: var(--sec-accent);
  background: rgba(100, 120, 217, 0.1);
}
.sec-upload-icon {
  display: grid;
  place-items: center;
  width: 66px;
  height: 76px;
  border-radius: 18px;
  background: rgba(100, 120, 217, 0.1);
  color: var(--sec-accent);
  font-size: 32px;
  margin: 0 auto 18px;
}
.sec-drop h2 {
  font-size: 23px;
}
.sec-drop p {
  font-size: 13px;
  color: var(--sec-muted);
}
.sec-drop small {
  font-size: 11px;
  color: var(--sec-muted);
}
.sec-file {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  margin: 14px 0 24px;
  overflow-wrap: anywhere;
}
.sec-file > i {
  font-size: 30px;
  color: var(--sec-accent);
}
.sec-file > div:first-of-type {
  flex: 1;
  min-width: 0;
}
.sec-file strong {
  font-size: 14px;
}
.sec-file p,
.sec-file span {
  font-size: 12px;
  color: var(--sec-muted);
  margin: 5px 0;
}
.sec-file .m-toolbar {
  flex-shrink: 0;
}
.sec-password {
  display: flex;
  gap: 8px;
  align-items: end;
  margin: 16px 0;
}
.sec-password label {
  flex: 1;
  min-width: 0;
}
.sec-password input {
  width: 100%;
}
.sec-password button {
  margin-bottom: 1px;
  min-height: 44px;
}
.sec-inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.security-app .m-field {
  margin-bottom: 16px;
}
.security-app .m-field input {
  max-width: 100%;
}
.security-app meter {
  width: 100%;
  height: 10px;
  margin-top: 16px;
}
.sec-warning {
  padding: 12px 14px;
  border-left: 3px solid #bd8543;
  background: rgba(189, 133, 67, 0.07);
  font-size: 12px;
  color: var(--ink);
}
.sec-trust-card {
  display: flex;
  gap: 15px;
  padding: 24px;
}
.sec-trust-card > i {
  font-size: 28px;
  color: var(--sec-accent);
}
.sec-trust-card h3 {
  font-size: 15px;
  margin: 0;
}
.sec-trust-card p {
  font-size: 12px;
  color: var(--sec-muted);
}
.sec-paper {
  height: 590px;
  min-height: 240px;
  background: var(--surface-soft, #edf0f6);
  overflow: auto;
  align-items: flex-start;
}
.sec-stage {
  flex: none;
  margin: auto;
  position: relative;
  min-width: 0;
}
.sec-stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.sec-overlay {
  position: absolute;
  inset: 0;
  touch-action: auto;
  overflow: visible;
}
.sec-redact .sec-overlay.marking {
  touch-action: none;
  cursor: crosshair;
}
.sec-region {
  position: absolute;
  border: 2px solid var(--sec-accent);
  background: rgba(100, 120, 217, 0.18);
  touch-action: none;
  cursor: move;
  box-sizing: border-box;
  outline-offset: 3px;
}
.sec-region.redaction {
  background: rgba(0, 0, 0, 0.65);
  border-color: #df5472;
}
.sec-region.selected {
  outline: 2px solid var(--sec-accent);
}
.sec-region img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  object-fit: fill;
}
.sec-region .sec-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  border: 2px solid white;
  border-radius: 5px;
  background: var(--sec-accent);
  cursor: nwse-resize;
  padding: 0;
  touch-action: none;
}
.sec-region-label {
  position: absolute;
  left: -2px;
  top: -22px;
  font-size: 10px;
  font-weight: 700;
  line-height: 19px;
  white-space: nowrap;
  background: var(--sec-accent);
  color: white;
  padding: 0 7px;
  border-radius: 5px;
}
.sec-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}
.sec-cta p {
  color: var(--sec-muted);
  font-size: 12px;
  margin: 6px 0;
}
.sec-cta .m-btn {
  min-width: 230px;
}
.sec-selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
}
.sec-selection-bar .m-field {
  margin: 0;
  min-width: 140px;
}
.sec-selection-bar input {
  width: 160px;
}
.sec-selection-bar > strong {
  margin-right: auto;
  font-size: 13px;
}
.sec-placement-list {
  display: grid;
  gap: 7px;
  margin: 14px 0;
}
.sec-placement-list button {
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  font-size: 12px;
}
.sec-placement-list button.active {
  background: rgba(100, 120, 217, 0.12);
  border-color: var(--sec-accent);
}
#signature-pad {
  width: 100%;
  height: 150px;
  background: #fff;
  border: 1px dashed #8d98bb;
  border-radius: 15px;
  touch-action: none;
  display: block;
  margin: 16px 0;
  cursor: crosshair;
}
#signature-sample {
  width: 100%;
  height: 95px;
  object-fit: contain;
  background: repeating-conic-gradient(#f4f5f9 0% 25%, white 0% 50%) 0/14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 15px 0;
}
.sec-sign-tabs {
  margin: 18px 0;
}
.sec-sign-tabs button {
  flex: 1;
}
.sec-review {
  margin: 22px 0;
  border-color: #b78951;
}
.sec-review h3 {
  margin: 0;
}
.sec-review p {
  font-size: 13px;
  color: var(--sec-muted);
}
.sec-downloads {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0;
}
.sec-uploads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.sec-uploads > .sec-drop {
  grid-row: 1;
}
.sec-uploads > .sec-file {
  grid-row: 2;
}
.sec-uploads .sec-file {
  flex-wrap: wrap;
}
.sec-uploads .sec-file .m-toolbar {
  width: 100%;
}
.sec-uploads .sec-drop:nth-of-type(2) {
  grid-column: 2;
}
.sec-comparison-top {
  justify-content: space-between;
  margin: 6px 0 24px;
}
.sec-compare-method {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}
.sec-compare-toolbar {
  margin: 25px 0;
  align-items: center;
}
.sec-compare-toolbar .m-field {
  margin: 0;
  min-width: 155px;
}
.sec-compare-toolbar .m-option {
  min-width: 120px;
}
.sec-dual-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  position: relative;
}
.sec-dual-preview .sec-paper {
  height: 550px;
}
.sec-dual-preview[data-view="original"],
.sec-dual-preview[data-view="revised"],
.sec-dual-preview[data-view="overlay"] {
  grid-template-columns: minmax(0, 1fr);
}
.sec-dual-preview[data-view="original"] #revised-preview-panel,
.sec-dual-preview[data-view="revised"] #original-preview-panel,
.sec-dual-preview[data-view="overlay"] #revised-preview-panel {
  display: none;
}
.sec-differences {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
  margin: 28px 0;
}
.sec-differences > div,
.sec-differences > section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  min-width: 0;
  background: var(--surface);
}
#difference-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}
#difference-list button {
  text-align: left;
  justify-content: flex-start;
  white-space: normal;
  font-size: 12px;
}
#text-changes {
  max-height: 500px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.8;
}
#text-changes del {
  background: rgba(219, 65, 91, 0.15);
  color: #b02645;
}
#text-changes ins {
  background: rgba(40, 150, 100, 0.15);
  color: #126e48;
  text-decoration: none;
}
.dark #text-changes del {
  color: #ffabbc;
}
.dark #text-changes ins {
  color: #91e4bd;
}
.sec-diff-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#search-candidates {
  max-height: 310px;
  overflow: auto;
  margin-top: 15px;
}
.sec-candidate {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.sec-page-tools .m-btn {
  padding: 8px 10px;
  font-size: 11px;
}
.sec-page-tools {
  gap: 6px;
}
.sec-page-tools input {
  width: 55px;
}
.security-app :is(button, input, select):focus-visible {
  outline: 3px solid var(--sec-accent);
  outline-offset: 3px;
}
.security-app .m-settings-group p {
  max-width: 90ch;
}
.sec-region-list-note {
  font-size: 12px;
}
.sec-preview h3 {
  font-size: 16px;
}
.sec-uploads > .sec-file:nth-of-type(3) {
  grid-column: 1;
}
.sec-uploads > .sec-file:nth-of-type(4) {
  grid-column: 2;
}
@media (max-width: 900px) {
  .sec-unlock-layout,
  .sec-edit-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sec-unlock-form {
    order: 0;
  }
  .sec-differences {
    grid-template-columns: 1fr;
  }
  .sec-dual-preview {
    grid-template-columns: 1fr;
  }
  .sec-dual-preview[data-view="side"] #revised-preview-panel {
    display: none;
  }
  .sec-compare-method {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .sec-paper {
    height: 520px;
  }
  .sec-compare-toolbar {
    gap: 10px;
  }
  .sec-sidebar,
  .sec-unlock-form {
    padding: 20px;
  }
  .sec-dual-preview .sec-paper {
    height: 500px;
  }
}
@media (max-width: 550px) {
  .security-app {
    padding-left: 14px;
    padding-right: 14px;
  }
  .sec-uploads {
    display: block;
  }
  .sec-drop {
    padding: 25px 16px;
  }
  .sec-file {
    flex-wrap: wrap;
  }
  .sec-file .m-toolbar {
    width: 100%;
  }
  .sec-preview {
    padding: 14px;
  }
  .sec-page-tools .m-btn {
    font-size: 0;
    gap: 0;
    min-width: 35px;
    min-height: 38px;
  }
  .sec-page-tools .m-btn i {
    font-size: 14px;
  }
  .sec-cta {
    flex-direction: column;
    align-items: stretch;
    padding: 20px;
  }
  .sec-cta .m-btn {
    width: 100%;
    min-width: 0;
    font-size: 13px;
  }
  .sec-paper {
    height: 450px;
  }
  .sec-inline-fields {
    gap: 10px;
  }
  .sec-selection-bar {
    gap: 14px;
  }
  .sec-selection-bar > * {
    max-width: 100%;
  }
  .sec-password {
    align-items: stretch;
  }
  .sec-password button {
    align-self: end;
    min-width: 65px;
  }
  .security-app .advanced-body {
    padding: 18px;
  }
  .sec-comparison-top {
    align-items: flex-start;
  }
  .sec-compare-toolbar .m-option {
    font-size: 11px;
  }
  .sec-differences > div,
  .sec-differences > section {
    padding: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .security-app * {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

.sec-sign .sec-overlay,
.sec-redact .sec-overlay {
  pointer-events: auto;
}

.sec-focused-difference {
  position: absolute;
  border: 3px solid #e12b57;
  background: rgba(225, 43, 87, 0.08);
  box-shadow: 0 0 0 3px #fff8;
  pointer-events: none;
  box-sizing: border-box;
}

.sec-mobile-compare-tabs {
  display: none;
}
#signature-pad {
  height: auto;
  aspect-ratio: 3/1;
}
@media (max-width: 900px) {
  .sec-mobile-compare-tabs {
    display: flex;
    margin: 16px 0;
  }
  .sec-mobile-compare-tabs button {
    flex: 1;
  }
}

.security-app a:not(.m-btn) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sec-result-preview {
  margin: 24px 0;
}
.sec-result-preview > .m-toolbar {
  justify-content: space-between;
  margin: 16px 0;
}
.sec-result-preview h3 {
  font-size: 17px;
}
.sec-result-preview .sec-paper {
  height: 650px;
}
@media (max-width: 550px) {
  .sec-result-preview .sec-paper {
    height: 460px;
  }
}
