/* The locked component set. See docs/design/COMPONENTS.md. */

/* ---------- Wordmark ---------- */

.wordmark { display: inline-flex; align-items: center; gap: var(--s-5); color: var(--text); }
.wordmark__mark { color: var(--accent); flex: none; }
.wordmark__text { display: flex; flex-direction: column; gap: var(--s-1); }
.wordmark__name {
  font: 600 0.8125rem/1 var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.wordmark__module { font: var(--t-micro); color: var(--text-tertiary); letter-spacing: 0.04em; }
.wordmark--lg .wordmark__name { font-size: 0.9375rem; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  height: var(--control-h);
  padding: 0 var(--s-5);
  border-radius: var(--r-1);
  border: 1px solid transparent;
  font: var(--t-label);
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out),
              border-color var(--dur-1) var(--ease-out),
              color var(--dur-1) var(--ease-out);
}
.btn--lg { height: var(--control-h-lg); padding: 0 var(--s-7); }
.btn--block { width: 100%; }

.btn--primary { background: var(--accent); color: var(--text-inverse); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent); }

.btn--secondary { border-color: var(--hairline-strong); color: var(--text); }
.btn--secondary:hover { background: var(--surface-hover); border-color: var(--text-faint); }

.btn--quiet { color: var(--text-muted); padding: 0 var(--s-4); }
.btn--quiet:hover { background: var(--surface-hover); color: var(--text); }

.btn--danger { border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-sunk); }

.btn[disabled], .btn[aria-disabled="true"] {
  color: var(--text-faint);
  cursor: not-allowed;
  pointer-events: none;
}
.btn--primary[disabled], .btn--primary[aria-disabled="true"] {
  background: var(--surface-hover);
  color: var(--text-faint);
}

.btn__spin {
  width: 14px; height: 14px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn__spin { display: none; } }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--r-1);
  color: var(--text-muted);
  position: relative;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.iconbtn:hover { background: var(--surface-hover); color: var(--text); }
.iconbtn__count {
  position: absolute;
  top: var(--s-3); right: var(--s-3);
  min-width: 15px; height: 15px;
  padding: 0 var(--s-2);
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--text-inverse);
  font: 600 0.625rem/15px var(--font-ui);
  text-align: center;
}

/* ---------- Fields ---------- */

.field { display: flex; flex-direction: column; gap: var(--s-4); }
.field__head { display: flex; align-items: center; gap: var(--s-4); }
.field__label { font: var(--t-label); color: var(--text-muted); }
.field__hint { font: var(--t-micro); color: var(--text-tertiary); max-width: var(--w-prose); }
.field__error { font: var(--t-micro); color: var(--danger); }

.chip-auto {
  font: 500 0.625rem/1 var(--font-ui);
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  padding: 3px var(--s-3);
}

.input, .select, .textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--s-5);
  background: var(--canvas-sunk);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  color: var(--text);
  font: var(--t-body-s);
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.textarea { height: auto; min-height: 84px; padding: var(--s-4) var(--s-5); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input[readonly] { color: var(--text-muted); }

.select {
  appearance: none;
  padding-right: var(--s-9);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
                    linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background: var(--surface-raised); color: var(--text); }

.value-block {
  padding: var(--s-4) var(--s-5);
  background: var(--canvas-sunk);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  color: var(--text);
  font: var(--t-body-s);
  min-height: var(--control-h);
  display: flex;
  align-items: center;
  user-select: text;
}

.toggle { display: inline-flex; align-items: center; gap: var(--s-5); cursor: pointer; }
.toggle__track {
  width: 34px; height: 20px;
  border-radius: var(--r-pill);
  background: var(--surface-hover);
  border: 1px solid var(--hairline-strong);
  position: relative;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
  flex: none;
}
.toggle__dot {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.toggle[aria-checked="true"] .toggle__track { background: var(--accent-sunk); border-color: var(--accent-line); }
.toggle[aria-checked="true"] .toggle__dot { transform: translateX(14px); background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .toggle__dot { transition: none; } }

.segmented {
  display: inline-flex;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  overflow: hidden;
}
.segmented button {
  height: 26px;
  padding: 0 var(--s-5);
  font: var(--t-micro);
  color: var(--text-tertiary);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.segmented button + button { border-left: 1px solid var(--hairline); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-hover); color: var(--text); }

/* ---------- Brand row ---------- */

.brandrow { display: inline-flex; align-items: center; gap: var(--s-5); min-width: 0; }
.brandrow__logo {
  display: block;
  height: 18px;
  width: auto;
  max-width: 148px;
  max-height: 18px;
  padding: 0;
  box-sizing: border-box;
  object-fit: contain;
  object-position: left center;
  border-radius: 0;
  flex: none;
  background: transparent;
  filter: none;
  mix-blend-mode: normal;
}
.brandrow--lg .brandrow__logo,
.brandrow__logo--lg,
.tile .brandrow__logo {
  height: 22px;
  width: auto;
  max-width: 168px;
  max-height: 22px;
  padding: 0;
}
.brandrow--logo { gap: 0; }
.brandrow__label { display: inline-flex; align-items: baseline; gap: 0; min-width: 0; }
.brandrow__short { font: var(--t-mono-s); color: var(--text-tertiary); }
.brandrow__dot { color: var(--text-faint); padding: 0 var(--s-3); }
.brandrow__full { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Menu ---------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  z-index: var(--z-menu);
  min-width: 260px;
  max-height: 60vh;
  overflow: auto;
  background: var(--surface-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  padding: var(--s-3);
  animation: menuIn var(--dur-2) var(--ease-out);
}
.menu--right { left: auto; right: 0; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  @keyframes menuIn { from { opacity: 0; } to { opacity: 1; } }
}

.menu__search { padding: var(--s-2) var(--s-2) var(--s-4); position: sticky; top: 0; background: var(--surface-raised); }
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  width: 100%;
  min-height: var(--control-h);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-1);
  text-align: left;
  color: var(--text);
  transition: background-color var(--dur-1) var(--ease-out);
}
.menu__item:hover, .menu__item.is-active { background: var(--surface-hover); }
.menu__item[aria-selected="true"] { background: var(--accent-sunk); }
.menu__item-sub { font: var(--t-micro); color: var(--text-tertiary); display: block; margin-top: var(--s-1); }
.menu__item-main { min-width: 0; flex: 1; overflow: visible; white-space: nowrap; }
.menu__empty { padding: var(--s-5) var(--s-4); font: var(--t-micro); color: var(--text-tertiary); }
.menu__sep { height: 1px; background: var(--hairline); margin: var(--s-3) 0; }

.combo {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--s-5);
  background: var(--canvas-sunk);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  text-align: left;
  transition: border-color var(--dur-1) var(--ease-out);
}
.combo:hover { border-color: var(--text-faint); }
.combo[aria-expanded="true"] { border-color: var(--accent); }
.combo[disabled] { color: var(--text-faint); cursor: not-allowed; }
.combo__value { flex: 1; min-width: 0; overflow: hidden; display: flex; align-items: center; }
.combo__caret { color: var(--text-tertiary); flex: none; }

/* ---------- Table ---------- */

.tablewrap {
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  overflow: auto;
  background: var(--canvas);
}
table.table { width: 100%; border-collapse: collapse; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--canvas-sunk);
  text-align: left;
  font: var(--t-micro);
  color: var(--text-tertiary);
  height: 36px;
  padding: 0 var(--s-6);
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
.table td {
  height: var(--row-h);
  padding: 0 var(--s-6);
  font: var(--t-body-s);
  color: var(--text);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover td { background: var(--surface-hover); }
.table tbody tr:focus-visible { outline: none; }
.table tbody tr:focus-visible td { background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--accent); }
.table td.cell-dim { color: var(--text-tertiary); }
.table td.cell-mono { font: var(--t-mono-s); color: var(--text-muted); }
.table th.col-right, .table td.col-right { text-align: right; }
.rowacts { display: inline-flex; align-items: center; gap: var(--s-2); }
.table .col-sticky { position: sticky; left: 0; background: var(--canvas); }
.table tbody tr:hover .col-sticky { background: var(--surface-hover); }
.table .perm { font: var(--t-mono-s); height: 26px; padding: 0 var(--s-3); }
.table .perm--off { color: var(--text-faint); }
.table .perm--on { color: var(--accent); }

.table-caption {
  display: flex;
  align-items: baseline;
  gap: var(--s-5);
  margin-bottom: var(--s-5);
}
.table-caption h2 { font: var(--t-subtitle); }
.table-caption span { font: var(--t-micro); color: var(--text-tertiary); }

/* ---------- Status pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  height: 20px;
  padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  font: var(--t-micro);
}
.pill__glyph { width: 7px; height: 7px; flex: none; }
.pill--sent { background: var(--ok-sunk); color: var(--ok); }
.pill--sent .pill__glyph { background: currentColor; border-radius: 50%; }
.pill--queued { background: var(--warn-sunk); color: var(--warn); }
.pill--queued .pill__glyph { border: 1.5px solid currentColor; border-radius: 50%; }
.pill--failed { background: var(--danger-sunk); color: var(--danger); }
.pill--failed .pill__glyph { background: currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--s-4);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-1);
  font: var(--t-micro);
  color: var(--text-tertiary);
}
.tag--accent { border-color: var(--accent-line); color: var(--accent); background: var(--accent-sunk); }

/* ---------- Notice ---------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--hairline);
  border-left-width: 2px;
  border-left-color: var(--hairline-strong);
  border-radius: var(--r-1);
  background: var(--surface);
  font: var(--t-body-s);
  color: var(--text-muted);
}
.notice__icon { color: var(--text-tertiary); flex: none; margin-top: 1px; }
.notice__body { flex: 1; max-width: var(--w-prose); }
.notice__body strong { color: var(--text); font-weight: 500; }
.notice--warn { border-left-color: var(--warn); }
.notice--warn .notice__icon { color: var(--warn); }
.notice--danger { border-left-color: var(--danger); }
.notice--danger .notice__icon { color: var(--danger); }

/* ---------- Empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-5);
  padding: var(--s-11) var(--s-6);
}
.empty h2 { font: var(--t-display-m); color: var(--text); }
.empty p { font: var(--t-body); color: var(--text-muted); max-width: 46ch; }

/* ---------- Skeleton ---------- */

.sk { background: var(--surface); border-radius: var(--r-1); }
.sk-row { height: var(--row-h); border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: var(--s-8); padding: 0 var(--s-6); }
.sk-bar { height: 9px; background: var(--surface-hover); border-radius: var(--r-1); }

/* ---------- Dialog ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  animation: fadeIn var(--dur-3) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  width: 480px;
  max-width: 100%;
  max-height: 86vh;
  overflow: auto;
  background: var(--surface-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-pop);
  padding: var(--s-8);
  animation: dialogIn var(--dur-3) var(--ease-out);
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  @keyframes dialogIn { from { opacity: 0; } to { opacity: 1; } }
}
.dialog h2 { font: var(--t-subtitle); margin-bottom: var(--s-4); }
.dialog__body { font: var(--t-body-s); color: var(--text-muted); max-width: var(--w-prose); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-4) var(--s-5); margin-top: var(--s-8); }
.dialog__actions .btn { flex: 0 1 auto; max-width: 100%; }

.copyblock {
  background: var(--canvas-sunk);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  padding: var(--s-5);
  font: var(--t-mono);
  color: var(--text-muted);
  user-select: all;
}

/* ---------- Drawer ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-drawer);
  animation: fadeIn var(--dur-3) var(--ease-out);
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--surface-raised);
  border-left: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-pop);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  animation: drawerIn var(--dur-3) var(--ease-out);
}
@keyframes drawerIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  @keyframes drawerIn { from { opacity: 0; } to { opacity: 1; } }
}
.drawer__head {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-6);
  border-bottom: 1px solid var(--hairline);
}
.drawer__head h2 { font: var(--t-subtitle); flex: 1; }
.drawer__body { padding: var(--s-6); overflow: auto; flex: 1; }

.deflist { display: grid; grid-template-columns: 108px 1fr; gap: var(--s-5) var(--s-6); align-items: baseline; }
.deflist dt { font: var(--t-micro); color: var(--text-tertiary); }
.deflist dd { margin: 0; font: var(--t-body-s); color: var(--text); word-break: break-word; }

/* ---------- Toast ---------- */

.toasts {
  position: fixed;
  right: var(--s-6);
  bottom: var(--s-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
  width: 320px;
  padding: var(--s-5) var(--s-6);
  background: var(--surface-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  font: var(--t-body-s);
  color: var(--text);
  pointer-events: auto;
  animation: toastIn var(--dur-2) var(--ease-out);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  @keyframes toastIn { from { opacity: 0; } to { opacity: 1; } }
}
.toast.is-out { opacity: 0; transition: opacity var(--dur-2) var(--ease-in); }
.toast__glyph { width: 7px; height: 7px; margin-top: 7px; flex: none; border-radius: 50%; }
.toast--ok .toast__glyph { background: var(--ok); }
.toast--fail .toast__glyph { background: var(--danger); border-radius: 0; }
.toast__text { flex: 1; }

/* ---------- Preview frame ---------- */

.preview {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface);
  overflow: hidden;
  min-height: 420px;
}
.preview__bar {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 36px;
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex: none;
}
.preview__status { font: var(--t-micro); color: var(--text-tertiary); }
.preview__stage {
  flex: 1;
  background: var(--canvas-sunk);
  padding: var(--s-8);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
}
.preview__meta {
  width: min(640px, 100%);
  font: var(--t-micro);
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.preview__meta strong { color: var(--text); font-weight: 500; }
.preview__paper {
  width: auto;
  max-width: 100%;
  height: auto;
  transition: opacity var(--dur-2) var(--ease-out);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  overflow: hidden;
  background: #ffffff;
  position: relative;
}
.preview__paper.is-phone {
  width: 390px;
  max-width: 100%;
  min-height: 120px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
}
.preview__paper.is-stale { opacity: 0.45; }

/* Phone mode keeps the 390 width and the tall screen, without a drawn handset. */
.phone { display: flex; flex-direction: column; align-items: center; position: relative; }
.phone.is-desktop { display: contents; }
.phone__screen { position: relative; }
.phone__notch,
.phone__bar { display: none; }
.phone:not(.is-desktop) {
  width: 390px;
  max-width: 100%;
}
.phone:not(.is-desktop) .phone__screen {
  width: 390px;
  max-width: 100%;
  height: 844px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  overflow: hidden;
}
.phone:not(.is-desktop) .preview__paper {
  width: 390px;
  max-width: 100%;
  height: 100%;
  border: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.phone:not(.is-desktop) .preview__paper::-webkit-scrollbar { width: 0; height: 0; }
.preview__text.is-hidden { display: none; }
.phone.is-hidden { display: none; }
.preview iframe {
  display: block;
  width: auto;
  max-width: none;
  min-height: 0;
  height: auto;
  border: 0;
  background: #ffffff;
}
.preview__paper.is-phone iframe {
  position: static;
  left: auto;
  top: auto;
  transform-origin: top left;
}
.preview__text {
  width: min(640px, 100%);
  max-width: 100%;
  white-space: pre-wrap;
  font: var(--t-mono);
  color: var(--text-muted);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  padding: var(--s-6);
}
.preview__text.is-phone {
  width: 390px;
  height: 844px;
  overflow-y: auto;
  scrollbar-width: none;
}
.preview--factory { min-height: 240px; }
.preview--factory .preview__paper { width: min(640px, 100%); max-width: 100%; }
.preview--factory iframe { width: auto; min-height: 0; height: auto; }
.factory__rebuilding {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-5);
  min-height: 220px;
  padding: var(--s-8);
}
.factory__rebuilding .btn__spin {
  width: 18px;
  height: 18px;
}
