@font-face {
  font-family: "Dancing Script";
  src: url("/fonts/dancing-script-latin-600-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1b2333;
  --muted: #5c6578;
  --border: #dfe3ea;
  --primary: #2347b8;
  --primary-hover: #1b3a9c;
  --primary-soft: #e9eeff;
  --sender: #2347b8;
  --sender-soft: rgba(35, 71, 184, 0.12);
  --client: #c2560c;
  --client-soft: rgba(234, 108, 18, 0.14);
  --success: #157f3c;
  --success-soft: #e5f5ea;
  --danger: #c22a2a;
  --danger-soft: #fdecec;
  --warning: #a8530a;
  --warning-soft: #fff3df;
  --ink: #14213d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-raised: 0 8px 24px rgba(16, 24, 40, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--primary);
}

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(35, 71, 184, 0.45);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.optional {
  color: var(--muted);
  font-weight: 400;
}

/* ---------- Buttons and inputs ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

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

.button-primary {
  background: var(--primary);
  color: #fff;
}

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

.button-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.button-secondary:not(:disabled):hover {
  background: #f6f7fa;
}

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

.button-danger-outline {
  background: var(--surface);
  border-color: #f0c4c4;
  color: var(--danger);
}

.button-danger-outline:not(:disabled):hover {
  background: var(--danger-soft);
}

.button-link {
  min-height: 32px;
  padding: 4px 6px;
  background: none;
  color: var(--primary);
  font-weight: 600;
}

.button-link:not(:disabled):hover {
  text-decoration: underline;
}

.link-danger {
  color: var(--danger);
}

.button-block {
  width: 100%;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--text);
  font-size: 20px;
  text-decoration: none;
}

.icon-button:hover {
  background: #eef0f4;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cdd3dd;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(35, 71, 184, 0.18);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
}

.form-field .input {
  font-weight: 400;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row > .form-field {
  flex: 1 1 0;
  min-width: 0;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field-hint {
  color: var(--muted);
  font-size: 13px;
}

.form-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
}

.check-row input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--primary);
}

/* ---------- App frame ---------- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 max(8px, calc((100% - 1000px) / 2 + 8px)) 0 max(20px, calc((100% - 1000px) / 2 + 20px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-logo {
  border-radius: 7px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.nav-link:hover {
  background: #f0f2f6;
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.avatar-large {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header p {
  margin-top: 6px;
  max-width: 620px;
}

.back-link {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  color: var(--primary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-title {
  margin-bottom: 14px;
  font-size: 16px;
}

.centred {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  padding: 20px;
}

.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

.state-error {
  color: var(--danger);
  font-weight: 600;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d6dbe5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Status chips ---------- */

.status-chip {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-draft {
  background: #eef0f4;
  color: #4a5366;
}

.status-sent {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-completed {
  background: var(--success-soft);
  color: var(--success);
}

.status-voided {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-admin {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- Sign in ---------- */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
}

.auth-brand {
  margin-bottom: 4px;
}

.auth-title {
  font-size: 22px;
}

/* ---------- Documents list ---------- */

.list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.chip-count {
  font-weight: 500;
  opacity: 0.8;
}

.search-input {
  width: 260px;
  min-height: 38px;
}

.doc-list {
  padding: 0;
  overflow: hidden;
}

.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}

.doc-row:last-child {
  border-bottom: 0;
}

.doc-row:hover {
  background: #f8f9fc;
}

.doc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 46px;
  border-radius: 6px;
  background: #fdeaea;
  color: #c0392b;
  font-size: 11px;
  font-weight: 800;
}

.doc-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.doc-title {
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-date {
  flex: none;
  width: 96px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: right;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state p {
  max-width: 440px;
}

.empty-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-illustration svg,
.drop-zone-icon svg {
  width: 32px;
  height: 32px;
}

/* ---------- New document ---------- */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 16px;
  border: 2px dashed #c6cddb;
  border-radius: var(--radius);
  background: #fafbfd;
  text-align: center;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone:focus-within {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-soft);
}

.drop-zone-icon {
  display: flex;
  color: var(--primary);
}

.drop-zone-title {
  max-width: 100%;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Document details ---------- */

.doc-detail .page-header {
  align-items: flex-end;
}

.doc-detail .page-header .status-chip {
  margin-bottom: 3px;
}

.detail-card > .button-link {
  margin-left: -6px;
}

.doc-detail .page-header h1 {
  overflow-wrap: anywhere;
}

.detail-grid {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.detail-grid > .card {
  flex: 1 1 0;
  min-width: 0;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
}

.summary-list > div {
  display: flex;
  gap: 12px;
}

.summary-list dt {
  flex: none;
  width: 110px;
  color: var(--muted);
  font-size: 14px;
}

.summary-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
}

.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 5px;
  width: 2px;
  background: var(--border);
}

.timeline-dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: #aab2c2;
}

.timeline-sender_signed .timeline-dot,
.timeline-link_created .timeline-dot {
  background: var(--primary);
}

.timeline-viewed .timeline-dot {
  background: var(--warning);
}

.timeline-client_signed .timeline-dot {
  background: var(--success);
}

.timeline-voided .timeline-dot {
  background: var(--danger);
}

.timeline-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ---------- Team and account ---------- */

.form-row-3 > .form-field {
  flex-basis: 0;
}

.member-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.member-row:last-child {
  border-bottom: 0;
}

.member-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 200px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.member-main .muted {
  font-size: 13.5px;
}

.member-actions {
  display: flex;
  gap: 4px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

/* ---------- Dialogs and toasts ---------- */

.dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow-raised);
  color: var(--text);
}

.dialog-wide {
  width: min(600px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
}

.dialog-title {
  font-size: 19px;
}

.dialog-text {
  color: var(--muted);
}

.dialog-text.small {
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.success-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 26px;
  font-weight: 700;
}

.link-box {
  display: flex;
  gap: 8px;
}

.link-box .input {
  min-width: 0;
  font-size: 14px;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  background: #1f2937;
  box-shadow: var(--shadow-raised);
  color: #fff;
  font-weight: 600;
  transform: translateX(-50%);
  transition: opacity 0.3s;
}

.toast-error {
  background: var(--danger);
}

.toast-hide {
  opacity: 0;
}

/* ---------- Signature dialog ---------- */

.tab-list {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: #eef0f4;
}

.tab {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
}

.signature-pad-wrap {
  position: relative;
}

.signature-pad {
  display: block;
  width: 100%;
  height: 200px;
  border: 1px solid #cdd3dd;
  border-radius: 10px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.signature-pad.is-readonly {
  cursor: default;
}

.signature-baseline {
  position: absolute;
  right: 24px;
  bottom: 52px;
  left: 24px;
  border-bottom: 1px solid #d5dae3;
  pointer-events: none;
}

.pad-clear {
  position: absolute;
  top: 6px;
  right: 8px;
}

.signature-pad-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #a3abba;
  font-size: 15px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ---------- PDF pages and fields ---------- */

.full-screen {
  min-height: 100vh;
  background: #e7eaf0;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-bar-public {
  justify-content: center;
}

.app-bar-title {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.app-bar-heading {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-status,
.app-bar-sub {
  color: var(--muted);
  font-size: 13px;
}

.editor-toolbar {
  position: sticky;
  top: 60px;
  z-index: 14;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.05);
}

.role-switch {
  display: flex;
  flex: none;
  padding: 3px;
  border-radius: 9px;
  background: #eef0f4;
}

.role-option {
  min-height: 34px;
  padding: 4px 14px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.role-option.role-sender[aria-checked="true"] {
  background: var(--sender);
  color: #fff;
}

.role-option.role-client[aria-checked="true"] {
  background: var(--client);
  color: #fff;
}

.field-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.palette-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.palette-button:hover {
  border-color: #b9c1cf;
}

.palette-icon {
  display: inline-flex;
  color: var(--muted);
}

.palette-button[aria-pressed="true"] .palette-icon {
  color: inherit;
}

.palette-button.armed-sender {
  border-color: var(--sender);
  background: var(--sender-soft);
  color: var(--sender);
}

.palette-button.armed-client {
  border-color: var(--client);
  background: var(--client-soft);
  color: var(--client);
}

.editor-hint {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: 13.5px;
}

.editor-body {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 16px 0;
}

.details-panel {
  width: min(100%, 880px);
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.details-panel summary {
  font-weight: 700;
  cursor: pointer;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 12px;
}

.form-grid .form-field {
  flex: 1 1 220px;
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0 120px;
}

.pdf-page-wrap {
  width: min(100%, 880px);
}

.pdf-page {
  position: relative;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.18), 0 6px 18px rgba(16, 24, 40, 0.08);
  container-type: inline-size;
}

.pdf-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.field-layer {
  position: absolute;
  inset: 0;
}

.is-placing .field-layer {
  cursor: crosshair;
}

.page-number {
  padding: 6px 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 1.5px solid;
  border-radius: 3px;
  color: var(--ink);
  font: inherit;
  line-height: 1;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-width: 0;
  overflow: hidden;
  padding: 0 2px;
  font-size: clamp(9px, 1.5cqw, 12px);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.field-label > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-label svg {
  flex: none;
  width: 1.25em;
  height: 1.25em;
}

.field-sender {
  border-color: var(--sender);
  background: var(--sender-soft);
  color: var(--sender);
}

.field-client {
  border-color: var(--client);
  background: var(--client-soft);
  color: var(--client);
}

/* Editor-only behaviour */
.editor-screen .field {
  cursor: move;
  touch-action: none;
}

.editor-screen .field.is-selected {
  z-index: 2;
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(35, 71, 184, 0.25);
}

.editor-screen .field-client.is-selected {
  box-shadow: 0 0 0 3px rgba(234, 108, 18, 0.28);
}

.field-delete,
.field-resize {
  display: none;
}

.editor-screen .field.is-selected .field-delete {
  position: absolute;
  top: -12px;
  right: -12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.editor-screen .field.is-selected .field-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: currentColor;
  cursor: nwse-resize;
}

/* Signing behaviour */
.field-action {
  cursor: pointer;
  animation: field-glow 2.4s ease-in-out infinite;
}

.field-action.field-done,
.field-action.field-check {
  animation: none;
}

@keyframes field-glow {
  50% {
    box-shadow: 0 0 0 4px rgba(234, 108, 18, 0.18);
  }
}

.field-sender.field-action {
  animation-name: none;
}

.field-done {
  border-style: dashed;
  border-width: 1px;
  background: transparent;
}

.field-attention {
  animation: field-attention 0.9s ease-out 2;
}

@keyframes field-attention {
  0% {
    box-shadow: 0 0 0 0 rgba(234, 108, 18, 0.6);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(234, 108, 18, 0);
  }
}

.field-text,
.field-input {
  justify-content: flex-start;
  padding: 0 2px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
}

.field-input {
  border-style: solid;
  font-family: "Liberation Sans", Arial, Helvetica, sans-serif;
  user-select: text;
  -webkit-user-select: text;
}

.field-input::placeholder {
  color: inherit;
  opacity: 0.6;
}

.field-text {
  font-family: "Liberation Sans", Arial, Helvetica, sans-serif;
}

.field-check {
  justify-content: center;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

/* Bigger tap area for small tick boxes */
button.field-check::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.field-filled {
  border-color: transparent;
  background: transparent;
}

.field-placeholder {
  border-style: dashed;
  opacity: 0.75;
}

.signature-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.sign-intro {
  width: min(calc(100% - 32px), 880px);
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 14px;
}

.sign-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px max(16px, calc((100% - 880px) / 2));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 14px rgba(16, 24, 40, 0.08);
}

.sign-progress {
  font-weight: 600;
}

.sign-bar-actions {
  display: flex;
  gap: 10px;
}

.signing-pages {
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: 24px;
}

.client-body {
  max-width: 920px;
  margin: 0 auto;
}

.client-intro {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 16px 0;
}

.client-intro h1 {
  font-size: 21px;
  overflow-wrap: anywhere;
}

.completed-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  margin: 40px 16px;
  padding: 36px 24px;
  text-align: center;
}

@media (min-width: 560px) {
  .completed-card {
    margin: 48px auto;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  .detail-grid {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 14px 64px;
  }

  .top-bar {
    padding: 0 12px;
  }

  .nav-account-name {
    display: none;
  }

  .nav-link {
    padding: 6px 8px;
  }

  .page-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  h1 {
    font-size: 21px;
  }

  .form-row {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }

  .doc-row {
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 12px 14px;
  }

  .doc-main {
    flex-basis: calc(100% - 52px);
  }

  .doc-row .status-chip {
    margin-left: 50px;
  }

  .doc-date {
    width: auto;
    margin-left: auto;
  }

  .app-bar .button-primary {
    padding: 8px 12px;
    font-size: 14px;
  }

  .editor-toolbar {
    gap: 8px;
    padding: 8px 10px;
  }

  .field-palette {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 2px;
  }

  .palette-button {
    flex: none;
  }

  .editor-hint {
    flex-basis: 100%;
    font-size: 13px;
  }

  .signing-pages,
  .editor-body {
    padding-left: 8px;
    padding-right: 8px;
  }

  .sign-intro {
    width: calc(100% - 16px);
  }

  .sign-bar {
    padding: 10px 12px;
  }

  .sign-progress {
    width: 100%;
    font-size: 14px;
  }

  .sign-bar-actions {
    width: 100%;
  }

  .sign-bar-actions .button {
    flex: 1;
  }

  .account-card {
    flex-wrap: wrap;
  }

  .action-row .button {
    flex: 1 1 100%;
  }

  .member-actions {
    width: 100%;
    padding-left: 42px;
  }
}
