:root {
  color-scheme: light;
  font:
    var(--font-size-body) / var(--line-height-body) "Pretendard Variable",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    sans-serif;
  color: var(--foreground);
  background: var(--background);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--primary);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button,
input,
select,
textarea {
  border-radius: var(--radius);
}
button {
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font-weight: 700;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}
button.secondary {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
button:hover:not(:disabled) {
  box-shadow: inset 0 0 0 100px var(--primary-hover-overlay);
}
button.secondary:hover:not(:disabled) {
  box-shadow: none;
  background: var(--muted);
}
button.danger {
  color: var(--destructive);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button[aria-busy="true"] {
  cursor: progress;
}
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
/* Every <details>, including those the scripts create, shows a chevron that turns down when it is open. */
summary {
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}
summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 10px 2px 2px;
  border-right: 2px solid var(--muted-foreground);
  border-bottom: 2px solid var(--muted-foreground);
  transform: rotate(-45deg);
  transition: transform 150ms ease;
  vertical-align: middle;
}
details[open] > summary::before {
  transform: rotate(45deg);
}
summary:hover {
  background: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
  summary::before {
    transition: none;
  }
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: var(--space-4) var(--space-8);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--foreground);
  text-decoration: none;
  font-size: var(--font-size-h3);
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand img {
  border-radius: var(--radius-lg);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.product-label {
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
main {
  padding: var(--space-8);
  max-width: 1560px;
  margin: auto;
}
h1,
h2,
h3 {
  letter-spacing: -0.035em;
  text-wrap: balance;
}
h1 {
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
  margin: 0;
}
h2 {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
  margin: 0;
}
h3 {
  font-size: var(--font-size-h3);
  line-height: var(--line-height-h3);
  margin: 0;
}
p {
  overflow-wrap: anywhere;
  word-break: keep-all;
}
.page-heading {
  margin-bottom: var(--space-6);
}
body:has(#workspace:not([hidden])) .page-heading {
  position: relative;
  overflow: hidden;
  padding: var(--space-6) var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--muted);
}
/* As in the approved design, the illustration multiplies into the panel color and fades in from the left. */
body:has(#workspace:not([hidden])) .page-heading::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 28%;
  background: url("../landing/comment-to-dm.webp") center / cover no-repeat;
  mix-blend-mode: multiply;
  mask-image: linear-gradient(90deg, transparent, var(--foreground) 20%);
  pointer-events: none;
}
body:has(#workspace:not([hidden])) .page-heading > * {
  position: relative;
  z-index: 1;
  max-width: 68%;
}
.page-eyebrow {
  display: none;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-family: "Courier New", monospace;
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-foreground);
}
body:has(#workspace:not([hidden])) .page-eyebrow {
  display: flex;
}
.page-eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-foreground);
}
.intro {
  margin: var(--space-2) 0 0;
  color: var(--muted-foreground);
}
.hint {
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  margin: var(--space-2) 0 0;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.card {
  min-width: 0;
}
.loading-state {
  padding: var(--space-10) 0;
  color: var(--muted-foreground);
}
.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.notice-bar:has(#notice:not(:empty)) {
  margin-bottom: var(--space-5);
}
#notice {
  flex: 1;
  min-width: 0;
}
#notice:not(:empty) {
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--success);
  background: var(--success-background);
  color: var(--success);
}
#notice.error {
  color: var(--destructive);
  border-color: var(--destructive);
  background: var(--destructive-background);
}
.action-error {
  margin: var(--space-2) 0 0;
  color: var(--destructive);
}
.action-error:empty {
  display: none;
}
#retry-load {
  margin-bottom: var(--space-5);
}
/* Auth is a single split surface, separate from the signed-in work area. */
body:has(#auth:not([hidden])) main {
  max-width: 1180px;
  padding-top: 56px;
}
body:has(#auth:not([hidden])) .page-heading {
  display: none;
}
.auth-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 570px;
}
.auth-copy {
  padding: 56px;
  background: var(--muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-headline {
  margin: 0;
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
  letter-spacing: -0.04em;
}
.auth-lead {
  margin: var(--space-3) 0 0;
  color: var(--muted-foreground);
}
.auth-bubbles {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-8) 0 var(--space-6);
}
.auth-bubble {
  width: fit-content;
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.auth-bubble.incoming {
  background: var(--card);
}
.auth-bubble.outgoing {
  justify-self: end;
  background: var(--accent);
  color: var(--accent-foreground);
}
.onboarding {
  list-style: none;
  padding: var(--space-5) 0 0;
  margin: 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: var(--space-3);
}
.onboarding li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.onboarding li > span:last-child {
  color: var(--muted-foreground);
}
.auth-note {
  margin: var(--space-6) 0 0;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.auth-forms {
  padding: 64px var(--space-12);
  align-self: center;
}
.auth-forms h2 {
  margin: 0;
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
  letter-spacing: -0.04em;
}
.auth-forms form {
  margin-top: var(--space-6);
}
.auth-actions {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-4);
}
.auth-secondary-note {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
}
.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.link-button:hover:not(:disabled),
.password-toggle:hover:not(:disabled) {
  box-shadow: none;
  color: var(--foreground);
}
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: var(--space-12);
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-1);
  transform: translateY(-50%);
  min-height: 0;
  padding: var(--space-2);
  border: 0;
  background: none;
  color: var(--muted-foreground);
}
/* One navigation rail; layers: skip link (2), normal document and sticky preview (auto). */
body:has(#workspace:not([hidden])) {
  isolation: isolate;
}
body:has(#workspace:not([hidden])) main {
  margin-left: 184px;
  max-width: none;
}
.workspace-nav {
  position: fixed;
  top: 106px;
  left: 20px;
  width: 144px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.workspace-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  color: var(--muted-foreground);
  text-decoration: none;
  font-weight: 700;
  border-radius: var(--radius);
}
.workspace-nav a:hover {
  color: var(--primary);
  background: var(--muted);
}
.workspace-nav a[aria-current] {
  color: var(--accent-foreground);
  background: var(--accent);
}
/* The automation screen keeps the send guidance one click away: a short state line, the detail inside. */
.send-summary {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}
.send-summary p {
  margin: var(--space-2) 0 0;
}
.send-notice {
  margin: var(--space-2) 0;
}
.send-notice summary {
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  color: var(--muted-foreground);
}
.step-num {
  margin-right: var(--space-2);
  font-family: "Courier New", monospace;
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--accent-foreground);
}
body:has(#workspace:not([hidden]))::before {
  content: "";
  position: fixed;
  inset: 76px auto 0 0;
  width: 184px;
  background: var(--background);
  border-right: 1px solid var(--border);
  z-index: -1;
}
.delivery-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "icon title action"
    "icon text action";
  align-items: center;
  column-gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--warning-border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  background: var(--warning-background);
  color: var(--warning);
  margin-bottom: var(--space-8);
}
.delivery-icon {
  grid-area: icon;
  width: 24px;
  height: 24px;
}
#delivery-title {
  grid-area: title;
}
#delivery-status {
  grid-area: text;
}
#send-settings-refresh {
  grid-area: action;
}
.delivery-banner.enabled {
  border-color: var(--success-border);
  border-left-color: var(--success);
}
.delivery-banner strong {
  font-size: var(--font-size-body);
}
.delivery-banner p {
  margin: 2px 0 0;
  font-size: var(--font-size-help);
}
.delivery-banner.enabled {
  border-color: var(--success);
  background: var(--success-background);
  color: var(--success);
}
/* A view receives focus only so screen readers announce the menu switch; it is not a control. */
.view:focus,
.view:focus-visible {
  outline: none;
}
.getting-started {
  margin-bottom: var(--space-8);
}
.checklist {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.checklist li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.checklist li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--primary);
  font-size: var(--font-size-caption);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.checklist li.done::before {
  content: "✓" / "";
  background: var(--success-background);
  color: var(--success);
}
.checklist strong {
  display: block;
}
.checklist .hint {
  margin: 2px 0 0;
}
.step-state:empty {
  display: none;
}
.step-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 700;
  text-decoration: none;
}
.step-action:hover {
  box-shadow: inset 0 0 0 100px var(--primary-hover-overlay);
}
@media (max-width: 600px) {
  .checklist li {
    grid-template-columns: 28px 1fr;
  }
  .checklist .step-state,
  .checklist .step-action {
    grid-column: 2;
    justify-self: start;
  }
}
#accounts-section,
#workspace-settings-section,
#webhooks-section,
#members-section {
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--border);
}
#accounts-section .section-heading,
#workspace-settings-section .section-heading,
#webhooks-section .section-heading,
#inbox-labels-section .section-heading,
#members-section .section-heading {
  margin-bottom: var(--space-3);
}
/* One card per connected account: identity, message switches, connection state and data deletion. */
.account-list {
  display: grid;
  gap: var(--space-4);
}
.account-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}
.account-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}
.account-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 700;
}
.account-identity {
  display: grid;
  flex: 1;
  min-width: 0;
}
.account-identity small {
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.account-identity strong {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
  overflow-wrap: anywhere;
}
.account-identity .badges {
  margin-top: var(--space-1);
}
.danger-link {
  color: var(--destructive);
}
.account-body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
}
.account-settings,
.account-status {
  padding: var(--space-5) var(--space-6);
}
.account-status {
  border-left: 1px solid var(--border);
}
.account-settings h3,
.account-status h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-h3);
  line-height: var(--line-height-h3);
}
.account-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.account-setting .hint {
  margin: 0;
}
/* A switch: its text states the value, and the drawn track shows it at a glance. */
button.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  font-weight: 600;
}
button.switch::after {
  content: "";
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle at 10px 50%, var(--card) 7px, transparent 7.5px) var(--input);
}
button.switch[aria-checked="true"] {
  color: var(--foreground);
}
button.switch[aria-checked="true"]::after {
  background: radial-gradient(circle at 26px 50%, var(--card) 7px, transparent 7.5px) var(--primary);
}
button.switch:hover:not(:disabled) {
  box-shadow: none;
}
.account-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-3);
}
.account-facts dt {
  color: var(--muted-foreground);
}
.account-facts dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}
.account-status .hint {
  margin: 0 0 var(--space-2);
}
.account-foot {
  padding: 0 var(--space-6);
  border-top: 1px solid var(--border);
}
@media (max-width: 767px) {
  .account-body {
    grid-template-columns: 1fr;
  }
  .account-status {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .account-head,
  .account-settings,
  .account-status {
    padding: var(--space-4);
  }
  .account-foot {
    padding: 0 var(--space-4);
  }
}
.data-export {
  margin-top: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.data-export .hint {
  margin: var(--space-2) 0 0;
}
.invite-form,
.invite-result {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}
/* No bottom margin, so each input shares a bottom edge with the button the row aligns to its end. */
.invite-form label {
  display: grid;
  gap: var(--space-1);
  margin-bottom: 0;
}
.invite-form input {
  min-width: min(260px, 100%);
}
.invite-result input {
  flex: 1;
  min-width: min(260px, 100%);
}
.invite-result label,
.invite-result .hint {
  width: 100%;
}
.invite-result .hint {
  margin: 0;
}
#invites-title,
#webhook-deliveries-title {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--font-size-body);
}
.connection-data summary {
  min-height: 44px;
  padding: var(--space-2) 0;
  color: var(--primary);
}
.deletion-form {
  max-width: 520px;
  margin-bottom: var(--space-3);
}
.deletion-form button {
  margin-top: var(--space-3);
}
.form-error {
  color: var(--destructive);
}
.form-error:empty {
  display: none;
}
.deletion-records {
  list-style: none;
  margin: 0;
  padding: 0;
}
.deletion-records li {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}
.deletion-records strong {
  font-size: var(--font-size-help);
}
.count {
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--accent-foreground);
  background: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2);
  font-variant-numeric: tabular-nums;
  margin-left: var(--space-2);
  font-weight: 600;
  vertical-align: middle;
}
.badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.badge {
  display: inline-block;
  font-size: var(--font-size-caption);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge.success {
  background: var(--success-background);
  color: var(--success);
}
.badge.warning {
  background: var(--warning-background);
  color: var(--warning);
}
.badge.danger {
  background: var(--destructive-background);
  color: var(--destructive);
}
.columns {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  border-top: 1px solid var(--border);
  align-items: start;
}
.columns:has(.rule-list-card[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.rule-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: start;
  min-width: 0;
}
.rule-actions {
  grid-column: 1 / -1;
  flex-wrap: wrap;
  padding: var(--space-5) var(--space-6);
}
.rule-actions > .action-error {
  grid-column: 1 / -1;
  flex-basis: 100%;
  order: 1;
}
#rule-preview-toggle {
  display: none;
}
.rule-list-card {
  padding: var(--space-6) var(--space-5) 0 0;
}
.rule-list-card .section-heading {
  flex-wrap: wrap;
}
#new-rule {
  font-size: var(--font-size-body);
  padding: var(--space-2) var(--space-3);
}
.item {
  padding: var(--space-4) 0;
  overflow-wrap: anywhere;
}
.item + .item {
  border-top: 1px solid var(--border);
}
.item p {
  margin: var(--space-2) 0;
}
#rules .item {
  padding: var(--space-4) var(--space-3);
  border-left: 2px solid transparent;
}
#rules .item.active-rule {
  background: var(--background);
  border-left-color: var(--primary);
}
#rules .item > strong {
  font-size: var(--font-size-caption);
  font-variant-numeric: tabular-nums;
}
#rules .item .badges {
  margin-top: var(--space-2);
}
#rules .item button {
  margin-top: var(--space-2);
  font-size: var(--font-size-body);
  padding: var(--space-2) var(--space-3);
}
#rules .item button + button {
  margin-left: var(--space-2);
}
.rule-summary {
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
}
.editor {
  padding: var(--space-6);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.media-picker {
  margin-top: var(--space-6);
}
.media-picker h4 {
  margin: 0;
  font-size: var(--font-size-help);
}
.media-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-1);
}
.media-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 76px;
  padding: var(--space-3);
  text-align: left;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
}
.media-option[aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.media-copy {
  min-width: 0;
  flex: 1;
}
.media-copy strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
}
.media-copy span,
.rule-target > span {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
.media-option img,
.media-placeholder,
.selected-media img,
.rule-target img {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: cover;
  border-radius: var(--radius);
}
.media-placeholder {
  display: grid;
  place-items: center;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
.selected-media,
.rule-target {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
/* A failed post lookup (title plus hint, no image) stacks instead of squeezing the title into one column. */
.rule-target:has(> span) {
  display: block;
}
.selected-media {
  flex-wrap: wrap;
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--background);
  border-radius: var(--radius);
}
.selected-media a {
  font-size: var(--font-size-caption);
}
#media-more {
  width: 100%;
  margin-top: var(--space-2);
}
@media (max-width: 767px) {
  .media-list {
    grid-template-columns: 1fr;
    max-height: 300px;
  }
}
.editor .section-heading {
  margin-bottom: var(--space-1);
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.form-section {
  margin: var(--space-8) 0;
}
.form-section + .form-section {
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
}
legend {
  font-weight: 800;
  font-size: var(--font-size-body);
  padding: 0 var(--space-3) 0 0;
}
label {
  display: block;
  font-size: var(--font-size-body);
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
}
input,
select,
textarea {
  width: 100%;
  display: block;
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  min-height: 44px;
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  font-size: var(--font-size-body);
  font-weight: 400;
}
/* Single-line controls match the 44px buttons beside them, so a row of inputs, selects and buttons lines up at the
   top as well as the bottom. Date and time inputs otherwise grow with their native picker parts. */
input:not([type="checkbox"], [type="radio"], [type="file"]),
select {
  height: 44px;
}
textarea {
  resize: vertical;
  line-height: var(--line-height-body);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
}
input[readonly],
input:disabled,
textarea:disabled,
select:disabled {
  background: var(--background);
  color: var(--muted-foreground);
}
/* The native control drew its own arrow and, in Safari, ignored the padding, so selects did not match the inputs
   beside them. The chevron is two gradients in the muted token, so it follows the theme. The more specific
   select:disabled rule above resets the background, so a disabled select shows no chevron. */
select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%), linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select:disabled {
  cursor: not-allowed;
}
.optional {
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
  font-weight: 400;
}
.field-meta {
  display: flex;
  gap: var(--space-3);
}
.field-meta p {
  flex: 1;
}
#message-count {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: 44px;
  cursor: pointer;
}
.toggle input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 3px 0 0;
  flex: none;
  accent-color: var(--primary);
}
.toggle small {
  display: block;
  font-weight: 400;
  font-size: var(--font-size-help);
  color: var(--muted-foreground);
  margin-top: 3px;
}
.nested-panel {
  border-left: 2px solid var(--border);
  padding: var(--space-1) 0 var(--space-1) var(--space-4);
  margin-top: var(--space-3);
}
.flow-summary {
  font-size: var(--font-size-help);
  color: var(--muted-foreground);
}
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
}
.save-bar p {
  margin: 0;
}
.save-bar button {
  flex: none;
}
.inline-note {
  padding: var(--space-3);
  background: var(--background);
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
}
.empty-state {
  padding: var(--space-6) 0;
  color: var(--muted-foreground);
}
.empty-state strong {
  display: block;
  font-size: var(--font-size-body);
  color: var(--foreground);
}
.empty-state p {
  margin: var(--space-1) 0 0;
  font-size: var(--font-size-help);
}
.conversation-preview {
  padding: var(--space-6) 0 var(--space-6) var(--space-5);
  position: sticky;
  top: 24px;
  min-width: 0;
}
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.preview-heading span {
  font-size: var(--font-size-caption);
  color: var(--muted-foreground);
}
.conversation {
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--background);
  border-radius: var(--radius-lg);
}
.conversation-account {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.conversation-account img {
  border-radius: var(--radius-lg);
}
.conversation-account strong {
  font-size: var(--font-size-caption);
  overflow-wrap: anywhere;
  min-width: 0;
}
.conversation-label {
  font-size: var(--font-size-caption);
  text-align: center;
  color: var(--muted-foreground);
  margin: var(--space-6) 0 var(--space-3);
}
.inbox-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr);
  gap: var(--space-6);
  margin-top: var(--space-6);
}
/* With no conversation listed or open, the two panes would show an empty list beside "대화를 선택하세요"; the status line stands alone as the empty state instead. */
.inbox-layout:has(#inbox-conversations:empty):has(#inbox-conversation-controls[hidden]) {
  display: none;
}
#inbox-status:not(:empty):has(+ .inbox-layout #inbox-conversations:empty) {
  margin-top: var(--space-6);
  padding: var(--space-6) var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}
.inbox-search-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}
.inbox-search-row input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
.inbox-search-row button {
  flex: none;
}
.inbox-unread-toggle {
  align-items: center;
}
.inbox-unread-toggle input {
  margin: 0;
}
#inbox-conversations .conversation-line {
  display: block;
}
#inbox-conversations .conversation-sender {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
#inbox-conversations .conversation-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}
#inbox-conversations .conversation-id {
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
#inbox-conversations .conversation-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: baseline;
}
.unread-badge {
  flex: none;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: var(--font-size-caption);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.inbox-conversation-controls {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
}
.inbox-conversation-controls .composer-actions {
  justify-content: flex-start;
}
#inbox-messages {
  overflow-wrap: anywhere;
}
#inbox-messages .bubble {
  white-space: pre-wrap;
}
#inbox-conversations button {
  text-align: left;
  width: 100%;
  margin-bottom: var(--space-2);
}
#inbox-conversations button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--muted);
}
.inbox-thread {
  min-width: 0;
  padding-left: var(--space-6);
  border-left: 1px solid var(--border);
}
.inbox-thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
/* The list sits beside the conversation on the two-column layout, so "목록으로" is shown only on one column. */
#inbox-back-to-list {
  display: none;
}
.inbox-message {
  max-width: 90%;
  margin: var(--space-5) 0;
}
.outgoing-message {
  margin-left: auto;
}
.inbox-composer {
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
  margin-top: var(--space-6);
}
.inbox-composer h4 {
  margin: 0;
}
.inbox-composer textarea,
.reply-decision textarea {
  width: 100%;
}
.composer-footer,
.composer-actions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.composer-actions {
  justify-content: flex-end;
}
/* The assignee select carries its label above it, so the row aligns to the bottom edge it shares with the claim and close buttons. */
#inbox-conversation-controls .composer-actions {
  align-items: flex-end;
}
#inbox-assign-label {
  margin-bottom: 0;
}
#inbox-reply-count {
  font-variant-numeric: tabular-nums;
}
.reply-warning {
  color: var(--warning);
}
.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}
.label-chip {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: var(--font-size-caption);
  overflow-wrap: anywhere;
}
.label-chip.archived {
  background: var(--muted);
  color: var(--muted-foreground);
  border-style: dashed;
}
.inbox-label-editor {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
}
.label-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
}
.label-option {
  margin: 0;
  align-items: center;
  font-weight: 500;
}
.label-option input {
  margin: 0;
}
.contacts-heading-actions,
.inbox-heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}
/* The title keeps its width at phone size, so the three buttons beside it wrap instead of breaking it per letter. */
#contacts-section > .section-heading > h2 {
  flex: none;
}
.reminder-count {
  display: inline-block;
  min-width: 24px;
  margin-left: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.reminder-filter.has-due .reminder-count {
  background: var(--warning);
  color: var(--card);
}
.reminder-filter[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--muted);
}
.reminder-chip {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
  font-variant-numeric: tabular-nums;
}
.reminder-chip.due {
  border-color: var(--warning);
  background: var(--warning-background);
  color: var(--warning);
  font-weight: 700;
}
.inbox-reminder-editor {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
}
.inbox-reminder-editor.due #inbox-reminder-state {
  color: var(--warning);
  font-weight: 700;
}
.reminder-fields {
  display: grid;
  grid-template-columns: minmax(0, 210px) minmax(0, 1fr);
  gap: 0 var(--space-3);
}
.reminder-fields label {
  margin-top: var(--space-3);
}
#inbox-reminder-note-count {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .reminder-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}
.inbox-notes {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px dashed var(--warning);
  border-radius: var(--radius);
  background: var(--warning-background);
}
.inbox-notes h4 {
  margin: 0;
}
.note-scope {
  margin-left: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--warning);
  font-size: var(--font-size-caption);
  font-weight: 600;
}
.inbox-note-form textarea {
  width: 100%;
}
.note-list {
  margin-top: var(--space-3);
}
.note-item {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.note-item p {
  margin: 0;
}
.note-body {
  white-space: pre-wrap;
}
#inbox-note-count {
  font-variant-numeric: tabular-nums;
}
.label-rename {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  min-width: min(260px, 100%);
}
.label-rename input {
  flex: 1;
  min-width: 0;
  margin: 0;
}
#inbox-label-rules-section .section-heading {
  margin-bottom: var(--space-3);
}
.label-rule-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3) var(--space-3);
  margin-top: var(--space-4);
}
.label-rule-form label {
  display: grid;
  gap: var(--space-1);
}
.label-rule-form .wide {
  grid-column: 1 / -1;
}
.label-rule-form .hint {
  margin: 0;
}
.label-rule-form .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.label-rule-form.editing {
  padding: var(--space-3);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
}
.label-rule-terms {
  width: 100%;
  margin: 0;
}
@media (max-width: 600px) {
  .label-rule-form {
    grid-template-columns: minmax(0, 1fr);
  }
}
.reply-decision {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.reply-decision form,
.reply-schedule-picker {
  display: grid;
  gap: var(--space-2);
}
.reply-schedule-picker {
  margin: var(--space-4) 0;
}
.reply-decision input,
.reply-schedule-picker input {
  width: 100%;
  min-width: 0;
}
.reply-decision[open] summary {
  margin-bottom: var(--space-3);
}
.reply-audit {
  margin-top: var(--space-2);
}
@media (max-width: 700px) {
  .inbox-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  #inbox-back-to-list {
    display: inline-block;
  }
  .inbox-thread {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-top: var(--space-4);
  }
  .inbox-message {
    max-width: 100%;
  }
}
.bubble {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
.bubble.incoming {
  margin: 0 var(--space-6) 0 0;
  background: var(--card);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border);
}
.bubble.outgoing {
  margin: 0 0 0 var(--space-5);
  background: var(--accent);
  color: var(--accent-foreground);
  border-bottom-right-radius: 2px;
}
.preview-branch {
  padding-top: var(--space-5);
}
.preview-branch > span {
  display: block;
  font-size: var(--font-size-caption);
  color: var(--muted-foreground);
  margin-bottom: var(--space-2);
}
#activity-section {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}
#activity .item {
  font-size: var(--font-size-help);
}
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-6) var(--space-8);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
body:has(#workspace:not([hidden])) footer {
  margin-left: 184px;
}
footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
}
footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted-foreground);
}
section {
  scroll-margin-top: 24px;
}
/* Line icons drawn with the current text color, from the approved screen designs. */
.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.workspace-nav a {
  gap: var(--space-3);
}
.shortcuts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.shortcut {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  color: var(--foreground);
  text-decoration: none;
  background: var(--card);
}
.shortcut + .shortcut {
  border-left: 1px solid var(--border);
}
.shortcut:hover {
  background: var(--muted);
}
.shortcut > span:not(.shortcut-arrow) {
  display: grid;
  flex: 1;
  min-width: 0;
}
.shortcut small {
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.count-badge {
  margin-left: var(--space-2);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  font-weight: 600;
  vertical-align: middle;
}
.activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.activity-toolbar .hint {
  margin: 0;
}
.activity-filter-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.activity-filter-label select {
  width: auto;
}
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.activity-table {
  width: 100%;
  border-collapse: collapse;
}
.activity-table th,
.activity-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.activity-table th {
  background: var(--muted);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.activity-table tbody tr:last-child td,
.activity-table tbody tr:has(+ .activity-reason) td {
  border-bottom: 0;
}
.activity-media {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.activity-none {
  color: var(--muted-foreground);
}
.activity-reason td {
  padding-top: 0;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
@media (max-width: 767px) {
  .shortcuts {
    grid-template-columns: 1fr;
  }
  .shortcut + .shortcut {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .delivery-banner {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon title"
      "icon text"
      "action action";
    row-gap: var(--space-2);
  }
  body:has(#workspace:not([hidden])) .page-heading {
    padding: var(--space-5);
  }
  body:has(#workspace:not([hidden])) .page-heading::after {
    display: none;
  }
  body:has(#workspace:not([hidden])) .page-heading > * {
    max-width: none;
  }
  .activity-table thead {
    display: none;
  }
  .activity-table,
  .activity-table tbody,
  .activity-table tr,
  .activity-table td {
    display: block;
  }
  .activity-table tbody tr:not(.activity-reason) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-4);
    border-top: 1px solid var(--border);
  }
  .activity-table tbody tr:first-child {
    border-top: 0;
  }
  .activity-table td {
    padding: 0;
    border: 0;
  }
  .activity-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted-foreground);
    font-size: var(--font-size-caption);
    line-height: var(--line-height-caption);
    font-weight: 400;
  }
  .activity-table .activity-media {
    grid-column: 1 / -1;
  }
  .activity-reason td {
    padding: 0 var(--space-4) var(--space-4);
  }
}
/* On wide screens the header stays at the top beside the fixed navigation rail, so content clears its 76px height. */
@media (min-width: 768px) {
  header {
    position: sticky;
    top: 0;
    z-index: 1;
  }
  section,
  .contacts-detail {
    scroll-margin-top: 100px;
  }
  .conversation-preview {
    top: 100px;
  }
}
.skip-link {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 2;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  background: var(--card);
  border: 2px solid var(--primary);
}
.skip-link:focus {
  width: auto;
  height: auto;
  padding: var(--space-3) var(--space-4);
  clip-path: none;
}
@media (min-width: 1600px) {
  .columns {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .rule-workbench {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}
@media (max-width: 1200px) {
  .columns {
    grid-template-columns: 180px minmax(0, 1fr);
  }
  .conversation-preview {
    grid-column: 1;
    position: static;
    border-left: 1px solid var(--border);
    padding: var(--space-6);
  }
  .rule-workbench {
    grid-template-columns: minmax(0, 1fr);
  }
  .editor {
    border-right: 0;
  }
  .conversation {
    max-width: 400px;
  }
  .account-list .item > .badges {
    flex-basis: calc(100% - 180px);
  }
}
@media (max-width: 767px) {
  header {
    padding: var(--space-4) var(--space-5);
    min-height: 68px;
  }
  .brand {
    font-size: var(--font-size-body);
  }
  .brand img {
    width: 30px;
    height: 30px;
  }
  .product-label {
    display: none;
  }
  main,
  body:has(#auth:not([hidden])) main {
    padding: var(--space-6) var(--space-5);
  }
  body:has(#workspace:not([hidden])) main,
  body:has(#workspace:not([hidden])) footer {
    margin-left: 0;
  }
  body:has(#workspace:not([hidden]))::before {
    display: none;
  }
  h1 {
    font-size: var(--font-size-h1-mobile);
  }
  .workspace-nav {
    position: static;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0 0 var(--space-5);
    border-bottom: 1px solid var(--border);
  }
  .workspace-nav a {
    flex-shrink: 0;
    padding: var(--space-3);
    font-size: var(--font-size-help);
  }
  .columns {
    display: block;
  }
  .rule-workbench {
    display: flex;
    flex-direction: column;
  }
  .rule-workbench > * {
    width: 100%;
  }
  .rule-actions {
    position: sticky;
    top: 0;
    z-index: 1;
    order: -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-2);
    padding: var(--space-3) 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
  }
  .rule-actions #save-status {
    grid-column: 1 / -1;
  }
  #rule-preview-toggle {
    display: block;
    white-space: normal;
  }
  .rule-workbench:not(.preview-open) .conversation-preview,
  .rule-workbench.preview-open .editor {
    display: none;
  }
  #rule-fields :is(input, select, textarea),
  #media-title,
  #preview-title {
    scroll-margin-top: 160px;
  }
  .rule-list-card {
    padding: var(--space-5) 0;
  }
  #rules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-2);
  }
  .editor {
    padding: var(--space-6) 0;
    border: 0;
    border-top: 1px solid var(--border);
  }
  .conversation-preview {
    padding: var(--space-6) 0;
    border: 0;
    border-top: 1px solid var(--border);
  }
  .conversation {
    max-width: none;
  }
  input,
  select,
  textarea {
    font-size: var(--font-size-input-mobile);
  }
  .account-list .item > strong {
    min-width: 0;
  }
  .account-list .item > .badges {
    flex-basis: 100%;
  }
  .save-bar {
    flex-wrap: wrap;
  }
  .save-bar button {
    width: 100%;
  }
  .auth-card {
    display: block;
    min-height: 0;
    border: 0;
    background: transparent;
  }
  .auth-copy {
    padding: var(--space-3) 0 var(--space-6);
    background: transparent;
    border: 0;
  }
  .auth-bubbles,
  .onboarding {
    display: none;
  }
  .auth-forms {
    padding: 0;
  }
  footer {
    padding: var(--space-6) var(--space-5);
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

.dm-response-button {
  margin: calc(var(--space-1) * -1) 0 var(--space-4) auto;
  width: 86%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  color: var(--primary);
  text-align: center;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.contacts-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.contacts-filter label {
  flex: 1 1 180px;
  margin: 0;
}
/* The native file input stays focusable and clickable through its label, but its browser-language text is hidden
   behind a Korean button and the chosen file name. */
.file-picker-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.file-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  opacity: 0;
}
.file-picker-button {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 700;
  color: var(--foreground);
  cursor: pointer;
}
.file-picker:hover .file-picker-button {
  background: var(--muted);
}
.file-picker input[type="file"]:focus-visible + .file-picker-button {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.file-picker-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
}
/* The group editor takes the filter's full width; its groups and leaves wrap like the filter row. */
.condition-tree {
  flex: 1 1 100%;
  min-width: 0;
}
.condition-tree-group {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.condition-tree-group > legend {
  padding: 0 var(--space-2);
}
.condition-tree-leaf,
.condition-tree-actions {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
}
.condition-tree-leaf {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.condition-tree .hint {
  flex: 1 1 100%;
  overflow-wrap: anywhere;
}
.condition-tree label {
  flex: 1 1 160px;
  min-width: 0;
  margin: 0;
}
.condition-tree input,
.condition-tree select {
  width: 100%;
}
.segment-save {
  margin-bottom: var(--space-5);
}
.segment-save summary {
  min-height: 44px;
  padding: var(--space-2) 0;
  color: var(--primary);
}
/* Contacts: the list of people on the left and the selected person's detail on the right. */
.contacts-layout {
  display: grid;
  grid-template-columns: minmax(205px, 0.38fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
  margin-top: var(--space-4);
}
.contacts-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}
.contacts-panel-head {
  margin: 0;
  padding: var(--space-4);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.contacts-list .empty-state {
  padding: var(--space-5) var(--space-4);
}
.contacts-panel > #contacts-more {
  width: calc(100% - var(--space-8));
  margin: var(--space-3) var(--space-4) var(--space-4);
}
.contact-row {
  display: block;
  width: 100%;
  min-height: 0;
  padding: var(--space-4);
  text-align: left;
  font-weight: 400;
  color: var(--foreground);
  background: var(--card);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.contact-row:last-child {
  border-bottom: 0;
}
.contact-row:hover:not(:disabled) {
  box-shadow: none;
  background: var(--muted);
}
.contact-row[aria-pressed="true"],
.contact-row[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--muted);
  box-shadow: inset 3px 0 var(--accent-foreground);
}
.contact-row-name {
  display: block;
  overflow-wrap: anywhere;
}
.contact-row-facts {
  display: block;
  margin: var(--space-1) 0 var(--space-2);
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}
.contact-row-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}
.contact-row-tags {
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}
/* A status pill: a dot before the text, green while allowed and amber while stopped. */
.badge.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-full);
  font-weight: 600;
  background: var(--success-background);
  color: var(--success);
}
.badge.status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: currentColor;
}
.badge.status.off {
  background: var(--warning-background);
  color: var(--warning);
}
.contact-detail-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.contact-detail-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.contact-detail-label,
.contact-detail-id {
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
}
/* The list row shows the tags in full at desktop width; the bar repeats them only where the row cuts them. */
.contact-detail-tags {
  display: none;
  margin-top: var(--space-1);
}
.contact-detail-name {
  overflow-wrap: anywhere;
}
.contact-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.contact-detail-editor {
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.contact-detail-editor textarea {
  width: 100%;
}
.contact-detail-editor button {
  margin: var(--space-2) var(--space-2) 0 0;
}
.contact-detail-body {
  padding: var(--space-5) var(--space-5) var(--space-4);
  overflow-wrap: anywhere;
}
.contact-detail-section + .contact-detail-section,
.contact-detail-content + .contact-detail-section {
  margin-top: var(--space-6);
}
.contact-detail-section h4 {
  display: flex;
  align-items: center;
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}
.contact-detail-section > p {
  margin: 0;
}
.contact-detail-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.contact-consent-scroll {
  overflow-x: auto;
}
.contact-consent-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  text-align: left;
}
.contact-consent-table th,
.contact-consent-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.contact-consent-table thead th {
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--muted-foreground);
  background: var(--background);
}
.contact-consent-table tbody th {
  font-weight: 600;
}
.contact-consent-table tbody tr:last-child > * {
  border-bottom: 0;
}
.contact-consent-no {
  color: var(--muted-foreground);
}
.contact-dm-cards {
  display: grid;
  gap: var(--space-3);
}
.contact-dm-section > .contact-dm-card,
.contact-dm-section .contact-dm-cards:not(:empty) {
  margin-bottom: var(--space-3);
}
.contact-dm-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.contact-dm-name {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.contact-dm-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin: 0;
  padding: 0 var(--space-4) var(--space-3);
}
.contact-dm-metrics dt,
.contact-detail-values dt {
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--muted-foreground);
}
.contact-dm-metrics dd {
  margin: 0;
  font-weight: 600;
}
.contact-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--muted);
  border-top: 1px solid var(--border);
}
.contact-link-row button.secondary {
  background: var(--card);
}
.contact-link-row .hint {
  flex-basis: 100%;
  margin: 0;
}
.contact-link-state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-help);
}
.contact-detail-values {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}
.contact-detail-values dd {
  margin: 0;
}
.contact-detail-record {
  border-top: 1px solid var(--border);
  background: var(--background);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
}
.contact-detail-record > summary {
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
}
.contact-detail-record-body {
  padding: 0 var(--space-5) var(--space-4);
  overflow-wrap: anywhere;
}
@media (max-width: 740px) {
  .contacts-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .contacts-panel-head {
    display: none;
  }
  .contacts-list {
    display: flex;
    overflow-x: auto;
  }
  .contact-row {
    flex: 1 0 145px;
    padding: var(--space-3);
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }
  .contact-row:last-child {
    border-right: 0;
  }
  .contact-row-facts {
    margin: var(--space-1) 0;
  }
  /* The narrow strip keeps the tags on one line so every row stays the same height. */
  .contact-row-tags {
    flex: 1 1 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .contact-detail-tags:not([hidden]) {
    display: flex;
  }
  .contacts-list .empty-state {
    flex: 1 1 auto;
  }
  .contact-detail-top,
  .contact-detail-editor,
  .contact-detail-body,
  .contact-detail-record > summary,
  .contact-detail-record-body {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .contact-dm-metrics {
    gap: var(--space-2) var(--space-4);
  }
}
@media (max-width: 600px) {
  .contacts-filter button {
    width: 100%;
  }
  /* A leaf's move and remove buttons share a row, so ten leaves stay short at phone width. */
  .contacts-filter .condition-tree-leaf button,
  .contacts-filter .condition-tree-actions button {
    width: auto;
    flex: 1 1 auto;
  }
}

.field-definition {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.field-definition span {
  min-width: 0;
}
.contact-field-editor input,
.contact-field-editor select {
  width: 100%;
}

/* Flows (#30): list, step outline, read-only graph and test run. */
#flows-section {
  padding-bottom: var(--space-6);
  margin: var(--space-10) 0 var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.flow-editor {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.flow-editor h4 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--font-size-body);
}
.flow-editor h5 {
  margin: var(--space-4) 0 var(--space-1);
  font-size: var(--font-size-body);
}
.flow-editor h6 {
  margin: var(--space-4) 0 var(--space-1);
  font-size: var(--font-size-help);
}
.flow-name {
  max-width: 520px;
}
.flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.flow-alert {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--destructive);
  background: var(--destructive-background);
  color: var(--destructive);
  overflow-wrap: anywhere;
}
.flow-alert.warning {
  border-color: var(--warning);
  background: var(--warning-background);
  color: var(--warning);
}
.flow-alert p {
  margin: 0 0 var(--space-2);
}
/* A static warning: its lead sentence reads at body size and the explanation after it at help size. */
.alert-detail {
  font-size: var(--font-size-help);
}
.alert-lead {
  display: block;
  font-size: var(--font-size-body);
}
.flow-alert ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}
.flow-alert a {
  color: inherit;
}
.flow-sequence {
  list-style: none;
  margin: 0;
  padding: 0;
}
.flow-step,
.flow-slot,
.flow-link {
  min-width: 0;
  margin: 0 0 var(--space-2);
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow-wrap: anywhere;
}
.flow-slot {
  border-style: dashed;
  background: transparent;
}
.flow-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  background: var(--background);
}
.flow-link button {
  margin-left: auto;
}
/* Only the title row: a condition step contains its branches, and the branch not taken is not on the path. */
.flow-step.on-path > .flow-step-title,
.flow-link.on-path {
  border-left: 4px solid var(--success);
  background: var(--accent);
  color: var(--accent-foreground);
}
.flow-step.on-path > .flow-step-title {
  margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0;
  padding: var(--space-3) var(--space-3) var(--space-2) var(--space-2);
}
.flow-step.has-error {
  border-color: var(--destructive);
}
.flow-step-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-2);
  margin: 0;
}
.flow-step-summary {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: var(--space-1) 0 0;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  white-space: pre-wrap;
}
.flow-step-errors {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  color: var(--destructive);
  font-size: var(--font-size-help);
}
.flow-slot-text {
  margin: 0;
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
}
.flow-branches {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.flow-branch {
  min-width: 0;
  padding-left: var(--space-3);
  border-left: 2px solid var(--border);
}
.flow-branch-label {
  margin: 0 0 var(--space-2);
  color: var(--muted-foreground);
  font-size: var(--font-size-caption);
  font-weight: 700;
}
.flow-step-menu summary,
.flow-test-values legend {
  color: var(--primary);
}
.flow-step-menu summary {
  min-height: 44px;
  padding: var(--space-3) 0 0;
}
.flow-step-menu > button {
  margin-top: var(--space-3);
}
.flow-step-menu button,
.flow-slot-form button,
.flow-link button {
  font-size: var(--font-size-body);
  padding: var(--space-2) var(--space-3);
}
.flow-config label {
  margin-top: var(--space-3);
}
.flow-hint {
  display: block;
  font-weight: 400;
}
.flow-slot-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}
.flow-slot-form label {
  flex: 1 1 180px;
  min-width: 0;
  margin: 0;
}
.flow-checks {
  margin-top: var(--space-3);
}
.flow-checks legend {
  font-size: var(--font-size-body);
  font-weight: 600;
}
.flow-checks label,
.flow-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  margin: 0;
  font-weight: 400;
}
.flow-checks input,
.flow-check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  flex: none;
  accent-color: var(--primary);
}
.flow-unreachable {
  margin-top: var(--space-4);
}
.flow-graph {
  max-width: 100%;
  overflow-x: auto;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
}
.flow-graph svg {
  display: block;
}
.flow-graph-node rect {
  fill: var(--card);
  stroke: var(--border);
  stroke-width: 1.5;
}
.flow-graph-node.unreachable rect {
  stroke-dasharray: 3 4;
}
.flow-graph-node.has-error rect {
  stroke: var(--destructive);
  stroke-width: 2;
}
.flow-graph-node.on-path rect {
  stroke: var(--success);
  stroke-width: 3;
}
.flow-graph-node text {
  fill: var(--foreground);
  font-size: var(--font-size-caption);
  font-weight: 700;
}
.flow-graph-node .flow-graph-detail {
  fill: var(--muted-foreground);
  font-size: var(--font-size-caption);
  font-weight: 400;
}
.flow-graph-edge {
  fill: none;
  stroke: var(--muted-foreground);
  stroke-width: 1.5;
}
.flow-graph-edge.on-path {
  stroke: var(--success);
  stroke-width: 3;
}
.flow-graph-arrow,
.flow-graph-port {
  fill: var(--muted-foreground);
}
.flow-graph-port {
  font-size: var(--font-size-caption);
}
.flow-test {
  margin-top: var(--space-6);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}
.flow-test-form {
  max-width: 720px;
}
.flow-test-values {
  margin-top: var(--space-4);
}
.flow-test-values legend {
  font-size: var(--font-size-body);
  font-weight: 600;
}
#flow-test-run {
  margin-top: var(--space-4);
}
.flow-test-result {
  max-width: 720px;
}
.flow-test-result ol,
.flow-test-result ul {
  margin: 0;
  padding-left: var(--space-5);
}
.flow-test-message {
  margin: 0 0 var(--space-2);
}
.flow-test-payload {
  max-width: 100%;
  margin: 0 0 var(--space-2);
  padding: var(--space-2);
  overflow-x: auto;
  background: var(--background);
  font-size: var(--font-size-caption);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#contacts-export-format summary,
#contacts-import > summary,
.contacts-filter-more > summary,
.contacts-tools > summary {
  min-height: 44px;
  padding: var(--space-2) 0;
  color: var(--primary);
}
/* The field tools reuse .segment-save; inside the tools list the three disclosures sit at one even rhythm. */
.contacts-tools .segment-save {
  margin-bottom: 0;
}

/* Long help text sits behind an info button; its popover opens under the button (app.js places it). */
.help-info {
  margin-bottom: var(--space-3);
}
.help-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: var(--font-size-help);
  line-height: var(--line-height-help);
  cursor: pointer;
}
.help-icon {
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border: 1.5px solid currentcolor;
  border-radius: var(--radius-full);
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  font-weight: 700;
}
.help-popover {
  position: fixed;
  inset: auto;
  max-width: min(32rem, calc(100vw - var(--space-8)));
  /* A page scroll closes the popover, so text taller than the viewport scrolls inside it without moving the page. */
  max-height: calc(100vh - var(--space-8));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
}
.help-popover > :first-child {
  margin-top: 0;
}
.help-popover > :last-child {
  margin-bottom: 0;
}
/* The folded conditions take a whole row of the filter, under the account, tag and apply controls. */
.contacts-filter-more {
  flex: 1 1 100%;
}
/* "필터 더 보기" ends the filter, so "현재 조건을 필터로 저장" follows it directly, at the rhythm of the tools list. */
#contacts-filter > .contacts-filter:has(> .contacts-filter-more:last-child) {
  margin-bottom: 0;
}
/* The tools that change or export data sit under the list, apart from finding contacts. */
.contacts-tools {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.template-panel {
  margin: var(--space-3) 0 var(--space-5);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.template-panel summary {
  font-weight: 600;
}
.template-values,
.reply-template-form {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
.template-values label,
.reply-template-form label {
  display: grid;
  gap: var(--space-1);
}
.template-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.template-output {
  padding: var(--space-3);
  background: var(--muted);
  border-radius: var(--radius);
}
.reply-template-card {
  border-top: 1px solid var(--border);
  padding: var(--space-3) 0;
}
.reply-template-card h3 {
  overflow-wrap: anywhere;
  min-width: 0;
}

#campaign-report-form,
#manual-report-form,
#flow-report-form,
#handoff-report-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  gap: var(--space-4);
}
/* A label's own bottom margin would lift its input above the submit button that the grid aligns to the row end. */
#campaign-report-form label,
#manual-report-form label,
#flow-report-form label,
#handoff-report-form label {
  margin-bottom: 0;
}
/* A result group's title shows only once the group has counts, so a report that has not been run lists no bare titles. */
.view h3:has(+ .manual-report-counts:empty) {
  display: none;
}
/* The page heading already names the view, so its intro and refresh button sit on one line above the report cards. */
.reports-toolbar p {
  margin: 0;
}
.reports-toolbar button {
  flex: none;
}
.manual-report-counts:empty {
  margin: 0;
}
.manual-report-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}
.manual-report-counts > div {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.manual-report-counts dt {
  font-size: var(--font-size-caption);
}
.manual-report-counts dd {
  margin: var(--space-2) 0 0;
  font-size: var(--font-size-h2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* A breakdown table scrolls inside its own box so the page never overflows at phone width. */
.report-breakdown {
  max-width: 100%;
  overflow-x: auto;
}
.report-breakdown:not(:empty) {
  margin: var(--space-4) 0;
}
.report-breakdown table {
  border-collapse: collapse;
}
.report-breakdown caption {
  text-align: left;
  font-size: var(--font-size-caption);
  padding-bottom: var(--space-2);
}
.report-breakdown th,
.report-breakdown td {
  padding: var(--space-2);
  border-top: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.report-breakdown th[scope="row"],
.report-breakdown th[rowspan] {
  text-align: left;
}
.report-breakdown th[scope="colgroup"] {
  text-align: center;
}

/* Saved drafts are cards like the contact cards; the editor below is set apart by a rule and its own heading. */
#campaign-draft-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.campaign-draft-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}
.campaign-draft-empty {
  margin: 0;
  padding: var(--space-6) var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted-foreground);
  font-size: var(--font-size-help);
  text-align: center;
}
#campaign-draft-editor-title {
  margin: var(--space-8) 0 var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}
.campaign-draft-card h3 {
  min-width: 0;
  overflow-wrap: anywhere;
  flex: 1 1 180px;
  margin: 0;
}
#campaign-drafts-section .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.campaign-draft-preview {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.campaign-draft-preview h4 {
  margin: 0 0 var(--space-1);
}
/* An empty live region stays rendered (never display: none) so later warnings are announced, but takes no space. */
.campaign-draft-preview-warnings:empty {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}
.campaign-draft-preview-warnings p:last-child {
  margin-bottom: 0;
}
.campaign-draft-preview-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
}
.campaign-draft-preview-summary dt {
  font-size: var(--font-size-caption);
}
.campaign-draft-preview-summary dd {
  margin: 2px 0 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.campaign-draft-preview-table {
  max-width: 100%;
  overflow-x: auto;
}
.campaign-draft-preview-table table {
  width: 100%;
  border-collapse: collapse;
}
.campaign-draft-preview-table caption {
  text-align: left;
  font-size: var(--font-size-caption);
  padding-bottom: var(--space-2);
}
.campaign-draft-preview-table th,
.campaign-draft-preview-table td {
  padding: var(--space-2) var(--space-1);
  border-top: 1px solid var(--border);
  text-align: left;
}
.campaign-draft-preview-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.campaign-draft-preview-table thead th:last-child {
  text-align: right;
}
.campaign-approval h5 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--font-size-body);
}
.campaign-approval-schedule {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
}
.campaign-approval-schedule > * {
  flex: 1 1 200px;
  min-width: 0;
}
.campaign-approval-schedule input,
.campaign-approval-schedule select {
  max-width: 100%;
}
.campaign-approval-confirm {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.campaign-approval-confirm h5 {
  margin-top: 0;
}
.campaign-approval h6 {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--font-size-help);
}
.campaign-approval-confirm h6 {
  margin-top: 0;
}
/* Dark mode separates elements with surfaces, not lines: the page is the darkest layer, each section is a raised
   card, controls sit in a darker inset fill, and decorative borders recede. Light mode is unchanged. */
/* The workspace sits on the page background and groups each section in a card, in both color schemes. */
body:has(#workspace:not([hidden])) {
  background: var(--background);
}
#workspace .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
}
#workspace .columns {
  border-top: 0;
  gap: var(--space-4);
}
#workspace .columns .card {
  padding: var(--space-4);
}
@media (prefers-color-scheme: dark) {
  body:has(#workspace:not([hidden]))::before {
    border-right-color: transparent;
  }
  /* Multiplied as-is, the light illustration vanishes into the dark panel; inverted with its hue turned back, its white ground drops out under screen and the green and line work stay. */
  body:has(#workspace:not([hidden])) .page-heading::after {
    filter: invert(1) hue-rotate(180deg);
    mix-blend-mode: screen;
  }
  input,
  select,
  textarea {
    background-color: var(--background);
    border-color: var(--border);
  }
  input:hover:not(:disabled),
  select:hover:not(:disabled),
  textarea:hover:not(:disabled) {
    border-color: var(--input);
  }
  button.secondary {
    background: var(--muted);
    border-color: transparent;
  }
  button.secondary:hover:not(:disabled) {
    background: var(--muted);
    box-shadow: inset 0 0 0 100px var(--primary-hover-overlay);
  }
  .bubble.incoming {
    background: var(--muted);
    border-color: transparent;
  }
}
