:root {
  color-scheme: light;
  --ink: #171713;
  --muted: #68675f;
  --faint: #8b897f;
  --cream: #f3f1eb;
  --surface: #fffefb;
  --surface-soft: #f8f6f0;
  --line: #dedbd2;
  --line-strong: #c8c4b9;
  --gold: #a78343;
  --green: #17623a;
  --green-soft: #e7f2ea;
  --amber: #835b00;
  --amber-soft: #fff1c4;
  --red: #a43c30;
  --red-soft: #fae9e5;
  --shadow: 0 18px 48px rgb(32 29 20 / 10%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(167 131 67 / 35%);
  outline-offset: 2px;
}

.client-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 254 251 / 94%);
  backdrop-filter: blur(16px);
}

.client-brand {
  display: inline-flex;
  align-items: center;
}

.client-brand img {
  display: block;
  width: auto;
  height: 38px;
  max-width: none;
}

.identity-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.identity-button:hover {
  background: var(--surface-soft);
}

.identity-button > img {
  width: 16px;
  height: 16px;
}

.identity-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 750;
}

.identity-button strong {
  max-width: 180px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-menu {
  position: fixed;
  z-index: 30;
  top: 56px;
  right: 24px;
  display: grid;
  width: 240px;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.identity-menu > strong {
  font-size: 14px;
}

.identity-menu > span {
  color: var(--muted);
  font-size: 12px;
}

.identity-menu button {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  margin-top: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.identity-menu button:hover {
  background: var(--surface-soft);
}

.identity-menu button img {
  width: 17px;
  height: 17px;
}

.client-main {
  min-height: calc(100vh - 64px);
}

.access-screen {
  display: grid;
  min-height: calc(100vh - 64px);
  padding: 48px 22px;
  place-items: center;
}

.access-card {
  display: grid;
  width: min(440px, 100%);
  justify-items: center;
  padding: 48px 42px 36px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.compact-card {
  width: min(380px, 100%);
}

.access-card h1 {
  max-width: 340px;
  margin: 20px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 550;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.access-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.access-code-card {
  justify-items: stretch;
  text-align: left;
}

.access-code-card > h1,
.access-code-card > p {
  justify-self: center;
  text-align: center;
}

.access-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.access-icon img {
  width: 23px;
  height: 23px;
}

.access-form {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 26px;
}

.access-form label {
  font-size: 13px;
  font-weight: 700;
}

.access-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: white;
  font-size: 15px;
}

.access-form .code-input {
  padding-left: calc(13px + 0.22em);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: 0.22em;
  text-align: center;
}

.access-form .primary-button {
  width: 100%;
  margin-top: 4px;
}

.access-form .code-destination {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.access-form .access-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}

.text-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover:not(:disabled) {
  color: var(--ink);
}

.text-button:disabled {
  cursor: default;
  opacity: 0.7;
}

.access-mark {
  width: 42px;
  height: 42px;
}

.primary-button,
.secondary-button,
.quiet-button,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.primary-button {
  gap: 7px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
}

.button-check {
  width: 17px;
  height: 17px;
  filter: invert(1);
}

.primary-button:hover {
  background: #2c2b26;
}

.primary-button.is-approved,
.primary-button.is-approved:hover {
  border-color: var(--green);
  background: var(--green);
  animation: approved-pop 420ms ease both;
}

@keyframes approved-pop {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.secondary-button,
.quiet-button {
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--ink);
}

.secondary-button:hover,
.quiet-button:hover {
  border-color: #a9a599;
  background: var(--surface-soft);
}

.opening-seal {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
}

.opening-seal::before,
.opening-seal::after,
.opening-seal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  content: "";
}

.opening-seal::before {
  border: 1px solid var(--line);
  background: rgb(255 254 251 / 72%);
  box-shadow: 0 12px 32px rgb(32 29 20 / 8%);
  animation: seal-breathe 1.8s ease-in-out infinite;
}

.opening-seal::after {
  inset: -1px;
  background: conic-gradient(from 90deg, transparent 0 67%, var(--gold) 82%, transparent 96%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  animation: seal-turn 1.45s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

.opening-seal-ring {
  inset: 8px;
  border: 1px solid rgb(167 131 67 / 20%);
  animation: seal-ring 1.8s ease-in-out infinite;
}

.opening-seal-mark {
  position: relative;
  z-index: 1;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgb(32 29 20 / 10%);
  animation: seal-mark 1.8s ease-in-out infinite;
}

.opening-seal-mark img {
  display: block;
  width: 34px;
  height: 34px;
}

@keyframes seal-turn {
  to { transform: rotate(360deg); }
}

@keyframes seal-breathe {
  0%, 100% { transform: scale(0.97); opacity: 0.82; }
  50% { transform: scale(1); opacity: 1; }
}

@keyframes seal-ring {
  0%, 100% { transform: scale(0.94); opacity: 0.45; }
  50% { transform: scale(1.04); opacity: 0.9; }
}

@keyframes seal-mark {
  0%, 100% { transform: translateY(1px); }
  50% { transform: translateY(-1px); }
}

.room-screen {
  width: min(1500px, 100%);
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  padding: 24px 28px 30px;
}

.room-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  gap: 24px;
  margin-bottom: 16px;
}

.room-heading > div:first-child {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.room-heading h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: clamp(21px, 2vw, 27px);
  font-weight: 720;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-state {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 30px;
  gap: 7px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
}

.room-state > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.room-state b {
  font-weight: 750;
}

.room-state[data-state="approved"],
.room-state[data-state="signed"],
.room-state[data-state="complete"] {
  background: var(--green-soft);
  color: var(--green);
}

.room-state[data-state="changes"] {
  background: var(--red-soft);
  color: var(--red);
}

.room-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-tools .quiet-button {
  gap: 8px;
}

.room-tools img {
  width: 18px;
  height: 18px;
}

.comments-button {
  gap: 8px;
}

.comments-button span {
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: white;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button img {
  width: 19px;
  height: 19px;
}

[data-tooltip]::after {
  position: absolute;
  z-index: 50;
  right: 0;
  bottom: calc(100% + 8px);
  display: none;
  min-width: max-content;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 650;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1040px) minmax(320px, 360px);
  align-items: start;
  justify-content: center;
  gap: 18px;
}

.document-pane {
  position: relative;
  width: 100%;
  height: calc(100vh - 166px);
  min-height: 660px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #252522;
  box-shadow: 0 12px 32px rgb(32 29 20 / 8%);
}

.document-pane iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #252522;
  transition: filter 180ms ease, opacity 180ms ease;
}

.document-pane.is-refreshing iframe {
  filter: blur(0.4px);
  opacity: 0.42;
}

.document-sign-action {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 18px;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 10px;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: 0 16px 44px rgb(0 0 0 / 30%);
  cursor: pointer;
  transform: translateX(-50%);
  transition: background 120ms ease, transform 120ms ease;
}

.document-sign-action:hover {
  background: #2c2b26;
  transform: translateX(-50%) translateY(-1px);
}

.document-sign-action span {
  display: inline-grid;
  min-height: 30px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  background: rgb(255 255 255 / 12%);
  color: rgb(255 255 255 / 76%);
  font-size: 12px;
  font-weight: 700;
}

.document-sign-action strong {
  font-size: 13px;
  font-weight: 750;
}

.document-refresh {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  display: grid;
  min-width: 190px;
  justify-items: center;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid rgb(255 255 255 / 32%);
  border-radius: 14px;
  background: rgb(23 23 19 / 92%);
  color: white;
  box-shadow: 0 18px 52px rgb(0 0 0 / 34%);
  transform: translate(-50%, -50%);
}

.document-refresh-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: rgb(255 255 255 / 12%);
}

.document-refresh-mark img {
  width: 20px;
  height: 20px;
  filter: invert(1);
}

.document-refresh strong {
  font-size: 13px;
}

.document-refresh[data-state="done"] .document-refresh-mark {
  background: var(--green);
  animation: approved-pop 420ms ease both;
}

.task-panel {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
}

.task-card,
.invoice-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(32 29 20 / 7%);
}

#agreement-task,
.agreement-complete {
  padding: 26px;
}

.task-icon,
.complete-icon,
.dialog-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
}

.task-icon img,
.complete-icon img,
.dialog-mark img {
  width: 22px;
  height: 22px;
}

.complete-icon {
  background: var(--green-soft);
}

.task-card h2,
.invoice-card h2,
.client-dialog h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.task-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.invoice-history summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  justify-content: space-between;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  list-style: none;
}

.invoice-history summary::-webkit-details-marker {
  display: none;
}

.invoice-history summary::after {
  color: var(--muted);
  content: "+";
  font-size: 18px;
  font-weight: 400;
}

.invoice-history[open] summary::after {
  content: "−";
}

.thread {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.comment {
  padding: 12px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.comment.is-revision {
  background: var(--red-soft);
}

.comment > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.comment strong {
  font-size: 13px;
}

.comment span {
  color: var(--faint);
  font-size: 12px;
}

.comment p {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 13px;
  white-space: pre-wrap;
}

.empty-thread {
  margin: 0 0 12px !important;
  color: var(--faint) !important;
  font-size: 13px !important;
}

.comment-composer {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.comment-composer > label,
.dialog-field > span {
  font-size: 13px;
  font-weight: 700;
}

.comment-composer textarea,
.dialog-field textarea,
.dialog-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  font-size: 14px;
}

.comment-composer textarea,
.dialog-field textarea {
  min-height: 86px;
  padding: 10px 11px;
  resize: vertical;
}

.comment-composer > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-select {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.page-select select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  font-size: 13px;
}

.send-button {
  min-height: 36px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  font-size: 13px;
}

.task-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 26px;
}

.task-actions.is-single {
  grid-template-columns: 1fr;
}

.task-actions button {
  font-size: 13px;
  white-space: nowrap;
}

.agreement-complete {
  text-align: left;
}

.receipt-link {
  margin-top: 22px;
}

.party-progress {
  padding: 18px 26px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.party-progress h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#party-progress-list {
  display: grid;
  gap: 7px;
}

.party-progress-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  min-height: 36px;
  align-items: center;
  gap: 9px;
}

.party-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  font-size: 12px;
  font-weight: 750;
}

.party-progress-row strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-state {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.party-state[data-state="done"] {
  background: var(--green-soft);
  color: var(--green);
}

.party-state[data-state="ready"] {
  background: var(--amber-soft);
  color: var(--amber);
}

.party-state[data-state="changes"] {
  background: var(--red-soft);
  color: var(--red);
}

.billing-gate {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.billing-gate span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.billing-gate strong {
  font-size: 13px;
}

.invoice-card {
  padding: 22px;
}

.invoice-card > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.invoice-card header > div > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.invoice-state {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.invoice-state[data-state="paid"] {
  background: var(--green-soft);
  color: var(--green);
}

.invoice-state[data-state="overdue"] {
  background: var(--red-soft);
  color: var(--red);
}

.invoice-amount {
  display: block;
  margin-top: 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.invoice-number {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.invoice-due,
.project-balance {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.project-balance {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.invoice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.invoice-actions > * {
  flex: 1 1 130px;
}

.invoice-history {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

#invoice-history-list {
  display: grid;
}

#invoice-history-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

#invoice-history-list strong {
  white-space: nowrap;
}

.payment-dialog {
  width: min(480px, calc(100vw - 28px));
}

.payment-bank-heading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.chase-bank-logo {
  display: block;
  width: 162px;
  height: auto;
}

.payment-bank-heading h2 {
  white-space: nowrap;
}

.payment-bank-heading p {
  overflow: hidden;
  max-width: 165px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-details {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.payment-details > div {
  display: grid;
  grid-template-columns: minmax(112px, 0.65fr) minmax(0, 1fr);
  min-height: 48px;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.payment-details > div:first-child {
  border-top: 0;
}

.payment-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.payment-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.payment-details .copy-row dd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.payment-details .copy-row button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.payment-details .copy-row button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.payment-dialog footer .primary-button {
  min-width: 104px;
}

.client-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgb(0 0 0 / 24%);
}

.client-dialog::backdrop {
  background: rgb(20 19 16 / 46%);
  backdrop-filter: blur(3px);
}

.client-dialog > form {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.client-dialog > .dialog-shell {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.client-dialog header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.client-dialog header p,
.confirm-dialog > form > p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.comments-dialog {
  width: min(500px, calc(100vw - 28px));
}

.comments-dialog .thread {
  max-height: min(310px, 38vh);
}

.comments-dialog .comment p {
  color: var(--ink);
}

.client-dialog header .icon-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--surface-soft);
}

.dialog-field {
  display: grid;
  gap: 7px;
}

.dialog-field input {
  height: 44px;
  padding: 0 11px;
}

.client-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 28px));
  text-align: center;
}

.confirm-dialog form {
  justify-items: center;
  padding: 32px 28px 26px;
}

.confirm-dialog .dialog-mark {
  margin: 0;
}

.confirm-dialog footer {
  width: 100%;
  justify-content: stretch;
}

.confirm-dialog footer button {
  flex: 1;
}

.signature-mark {
  display: flex;
  min-height: 84px;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.signature-method {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.signature-method button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.signature-method button.is-selected {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 4px rgb(32 29 20 / 10%);
}

.signature-drawing {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
}

.signature-drawing canvas {
  display: block;
  width: 100%;
  height: 144px;
  cursor: crosshair;
  touch-action: none;
}

.signature-drawing button {
  position: absolute;
  top: 9px;
  right: 9px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgb(255 254 251 / 92%);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.signature-mark span {
  color: var(--muted);
  font-size: 20px;
}

.signature-mark strong {
  overflow: hidden;
  font-size: 28px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signature-consent {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 13px;
}

.signature-consent input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--ink);
}

.dialog-error {
  margin: -6px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 15px;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  box-shadow: 0 16px 44px rgb(0 0 0 / 20%);
  font-size: 13px;
  font-weight: 650;
}

.is-busy {
  cursor: wait;
  opacity: 0.68;
}

@media (max-width: 980px) {
  .room-screen {
    padding-inline: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .task-panel {
    position: static;
    grid-row: 1;
  }

  .document-pane {
    height: 76vh;
    min-height: 560px;
  }

  .task-card,
  .invoice-card {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .client-header {
    height: 58px;
    padding: 0 14px;
  }

  .client-brand img {
    width: auto;
    height: 26px;
  }

  .identity-button strong {
    display: none;
  }

  .client-main,
  .access-screen {
    min-height: calc(100vh - 58px);
  }

  .access-screen {
    padding: 24px 14px;
  }

  .access-card {
    padding: 34px 24px 26px;
  }

  .room-screen {
    min-height: calc(100vh - 58px);
    padding: 14px 12px 24px;
  }

  .room-heading {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .room-heading > div:first-child {
    display: grid;
    gap: 7px;
  }

  .room-heading h1 {
    white-space: normal;
  }

  .room-tools .quiet-button {
    position: relative;
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .room-tools .quiet-button img {
    width: 19px;
    height: 19px;
  }

  .comments-button span {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border: 1px solid var(--surface);
    background: var(--ink);
    color: white;
    font-size: 12px;
  }

  .document-pane {
    height: 68vh;
    min-height: 460px;
  }

  .document-sign-action {
    bottom: 12px;
    min-height: 46px;
  }

  #agreement-task,
  .agreement-complete,
  .invoice-card,
  .party-progress {
    padding: 20px;
  }

  .task-actions {
    grid-template-columns: 1fr;
  }

  .task-actions .primary-button {
    grid-row: 1;
  }

  .client-dialog > form {
    padding: 20px;
  }

  .client-dialog > .dialog-shell {
    padding: 20px;
  }

  .client-dialog footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .payment-details > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .payment-bank-heading {
    display: grid;
    gap: 10px;
  }

  .chase-bank-logo {
    width: min(180px, 62vw);
  }

  .payment-bank-heading p {
    max-width: min(230px, 68vw);
  }

  .payment-dialog footer {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
