/* Formsink admin — hand-written stylesheet implementing the Claude Design
   handoff (Formsink.dc.html): Space Grotesk + IBM Plex Mono, violet
   gradient accent, grid-paper backdrop, manual dark/light theme toggle.

   Theming: every token picks its value with light-dark(), so with the
   default `color-scheme: light dark` the palette follows the browser
   preference on its own. An explicit toggle choice sets
   `data-theme="light|dark"` on <html> (persisted in localStorage), which
   pins color-scheme and thereby overrides the preference. */

/* --- Fonts (self-hosted, latin subset) ----------------------------------- */

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/space-grotesk-var.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-600.woff2") format("woff2");
}

/* --- Design tokens -------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: light-dark(#f4f4f1, #0b0c10);
  --bg-grid: light-dark(rgba(20, 20, 30, 0.035), rgba(255, 255, 255, 0.028));
  --panel: light-dark(#ffffff, #141620);
  --panel-2: light-dark(#fbfbfa, #181b26);
  --panel-inset: light-dark(#f4f4f2, #10121a);
  --border: light-dark(#e7e6e1, #262a37);
  --border-strong: light-dark(#d9d8d2, #333849);
  --text: light-dark(#17181d, #edeef4);
  --text-2: light-dark(#4a4d57, #a9adbe);
  --muted: light-dark(#8a8d99, #6c7183);
  --accent: light-dark(#5b3df5, #8b7bff);
  --accent-2: light-dark(#7c6cff, #a99bff);
  --accent-soft: light-dark(rgba(91, 61, 245, 0.09), rgba(139, 123, 255, 0.14));
  --accent-line: light-dark(rgba(91, 61, 245, 0.28), rgba(139, 123, 255, 0.42));
  --danger: light-dark(#d63a3a, #ff6b6b);
  --danger-soft: light-dark(rgba(214, 58, 58, 0.08), rgba(255, 107, 107, 0.12));
  --ok: light-dark(#16915b, #46d58a);
  --ok-soft: light-dark(rgba(22, 145, 91, 0.1), rgba(70, 213, 138, 0.12));
  --warn: light-dark(#b45309, #fbbf24);
  --warn-soft: light-dark(rgba(180, 83, 9, 0.1), rgba(251, 191, 36, 0.12));
  --glow: light-dark(rgba(124, 108, 255, 0.1), rgba(139, 123, 255, 0.16));
  /* The two schemes use different shadow geometry, which light-dark()
     can't express directly — so each layer fades to transparent in the
     scheme it doesn't belong to. */
  --shadow:
    0 1px 2px light-dark(rgba(20, 20, 40, 0.05), rgba(0, 0, 0, 0.4)),
    0 8px 24px light-dark(rgba(20, 20, 40, 0.05), transparent),
    0 12px 40px light-dark(transparent, rgba(0, 0, 0, 0.45));

  --font-ui: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Explicit choice from the in-app toggle: pinning color-scheme flips every
   light-dark() token at once. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* --- Animations ------------------------------------------------------------ */

@keyframes fk-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes fk-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fk-pop {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

@keyframes fk-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

/* --- Base ------------------------------------------------------------------ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  transition: background 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}

/* Fixed decorative layers */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 0%, #000, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000, transparent 78%);
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -260px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(circle, var(--glow), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

/* --- Header ------------------------------------------------------------ */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  border-radius: 9px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px var(--glow);
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 2px 6px;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.dev-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 5px 10px;
  white-space: nowrap;
}

.dev-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: currentColor;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

/* --- Layout / typography ------------------------------------------------- */

.container {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

.view {
  animation: fk-fade 0.4s ease both;
}

.narrow {
  max-width: 760px;
}

.overline {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.15;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 22px;
  text-decoration: none;
  transition: color 0.15s ease;
  border-radius: 5px;
}

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

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 64px 0;
  text-align: center;
}

.loading::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 11px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: fk-spin 0.8s linear infinite;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease,
    color 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-accent {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px var(--glow);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px var(--glow);
}

.btn-accent-lg {
  font-size: 15px;
  border-radius: 12px;
  padding: 14px 28px;
  box-shadow: 0 6px 20px var(--glow);
}

.btn-outline {
  color: var(--text-2);
  background: var(--panel);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-line);
}

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

.btn-danger-soft:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

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

.btn-muted {
  color: var(--text-2);
  background: var(--panel-inset);
  border-color: var(--border-strong);
}

.btn-plain {
  color: var(--text-2);
  background: none;
  border: none;
  font-size: 15px;
  padding: 14px 4px;
}

.btn-sm {
  font-size: 13.5px;
  padding: 9px 15px;
  border-radius: 9px;
}

.spin {
  animation: fk-spin 0.8s linear infinite;
}

.spin-once {
  animation: fk-spin 0.7s linear;
  transform-origin: center;
}

/* --- Dashboard list ------------------------------------------------------ */

.list-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.list-head,
.list-row {
  display: grid;
  grid-template-columns: 2.2fr 2.4fr 1fr 1.2fr 1.2fr;
  gap: 16px;
  align-items: center;
}

.list-head {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.list-row {
  width: 100%;
  text-align: left;
  padding: 18px 24px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease;
  animation: fk-rise 0.4s ease both;
}

.list-row:hover {
  background: var(--panel-2);
}

.row-name {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.row-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--accent-line);
}

.row-name span:last-child {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-recipient {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-count {
  font-size: 14px;
  color: var(--text-2);
}

.pill-accent {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 7px;
  padding: 3px 9px;
}

.row-date {
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.list-foot {
  padding: 14px 24px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.list-foot .mono {
  font-family: var(--font-mono);
}

/* Skeleton loading */
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.skeleton-row:last-child {
  border-bottom: none;
}

.shimmer {
  height: 16px;
  width: 180px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--panel-inset), var(--panel-2), var(--panel-inset));
  background-size: 800px 100%;
  animation: fk-shimmer 1.3s linear infinite;
}

.shimmer-end {
  height: 12px;
  width: 220px;
  margin-left: auto;
}

/* Error / empty states */
.error-card {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
}

.empty-card {
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  padding: 64px 40px;
  text-align: center;
  box-shadow: var(--shadow);
}

.icon-tile {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
}

.icon-tile-danger {
  background: var(--panel);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.icon-tile-accent {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  margin-bottom: 22px;
}

.icon-tile-muted {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--panel-inset);
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.state-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.state-title-sm {
  font-size: 19px;
  font-weight: 600;
}

.state-copy {
  margin: 0 auto 26px;
  color: var(--text-2);
  font-size: 15px;
  max-width: 420px;
  line-height: 1.5;
}

.state-copy code,
.inline-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}

/* --- Panel cards / builder ------------------------------------------------ */

.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.step-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.step-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}

.req-star {
  color: var(--accent);
}

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

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

input,
select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-inset);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 14px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" stroke="%238a8d99" stroke-width="2.4" stroke-linecap="round"><path d="M2 4l4 4 4-4"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* --- Custom select (Popover API + CSS anchor positioning, with a
       signal-driven absolute-position fallback for other browsers) -------- */

.select-wrap {
  position: relative;
  min-width: 0;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-inset);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select-trigger:focus-visible,
.select-trigger.open,
.select-wrap:has(.select-pop:popover-open) .select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.select-chevron {
  margin-left: auto;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.select-trigger.open .select-chevron,
.select-wrap:has(.select-pop:popover-open) .select-chevron {
  transform: rotate(180deg);
}

.select-pop {
  /* Anchor the panel to its trigger (position-anchor is set inline):
     below and left-aligned, flipping above when out of space. */
  position: fixed;
  position-area: block-end span-inline-end;
  position-try-fallbacks: flip-block;
  inset: auto;
  margin: 6px 0 0;
  width: anchor-size(width);
  min-width: 180px;
  max-height: 300px;
  overflow: hidden auto;
  display: none;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow), 0 16px 48px rgba(0, 0, 0, 0.18);
  padding: 5px;
  color: var(--text);
  animation: fk-pop 0.16s ease both;
}

.select-pop:popover-open {
  display: flex;
}

/* Fallback mode: no popover/anchor support - a plain absolutely
   positioned panel directly under the trigger. Anchor properties are
   explicitly neutralized so partially-supporting browsers cannot mix
   the two positioning schemes. */
.select-pop-fallback {
  position: absolute;
  position-area: none;
  position-try-fallbacks: none;
  top: calc(100% + 6px);
  bottom: auto;
  left: 0;
  right: 0;
  width: auto;
  margin: 0;
  z-index: 40;
}

.select-pop-fallback.open {
  display: flex;
}

.select-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: transparent;
}

.select-search-wrap {
  position: sticky;
  top: 0;
  background: var(--panel);
  padding: 2px 2px 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}

.select-search {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
}

.select-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-options {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.select-option:hover,
.select-option:focus-visible {
  background: var(--accent-soft);
  outline: none;
  box-shadow: none;
}

.select-option.selected {
  color: var(--accent);
  font-weight: 600;
}

.select-option-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--muted);
}

.select-option.selected .select-option-icon,
.select-trigger .select-option-icon {
  color: var(--accent);
}

/* The check sits at the right edge of the row. */
.select-option-check {
  order: 2;
  margin-left: auto;
  width: 12px;
  display: inline-flex;
  flex-shrink: 0;
  color: var(--accent);
}

.select-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 10px;
  text-align: center;
}

/* Field-builder grid */
.field-grid-head,
.field-grid-row {
  display: grid;
  grid-template-columns: 1.6fr 1.1fr auto auto;
  gap: 12px;
  align-items: center;
}

.field-grid-head {
  padding: 0 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.field-grid-head .center {
  text-align: center;
}

.field-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Opacity-only on purpose: a transform animation (even one that ends at
   `none` with fill-mode both) turns the row into the containing block for
   position:fixed descendants, which would shrink the select's full-screen
   click-away backdrop down to the row. */
.field-item {
  animation: fk-fade 0.22s ease both;
}

.field-grid-row input {
  border-radius: 9px;
  padding: 10px 12px;
}

.field-options-row {
  margin-top: 8px;
  padding-left: 2px;
}

.field-options-row input {
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
}

.req-toggle {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel-inset);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  transition: all 0.15s ease;
  justify-self: center;
}

.req-toggle.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.row-remove {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel-inset);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: all 0.15s ease;
}

.row-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.add-field {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px dashed var(--accent-line);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: border-style 0.15s ease;
}

.add-field:hover {
  border-style: solid;
}

.banner-danger {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 11px;
  padding: 13px 16px;
  margin-bottom: 22px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  animation: fk-pop 0.25s ease both;
}

.builder-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

/* --- Form detail ---------------------------------------------------------- */

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.detail-head h1 {
  margin: 0 0 10px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13.5px;
  color: var(--text-2);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.meta-item svg {
  color: var(--muted);
  flex-shrink: 0;
}

.meta-item .mono {
  font-family: var(--font-mono);
  color: var(--text);
}

.endpoint-card {
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  margin: 26px 0 22px;
  box-shadow: var(--shadow);
}

.card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 13px;
}

.endpoint-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.method {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid var(--ok);
  border-radius: 7px;
  padding: 5px 10px;
  letter-spacing: 0.5px;
}

.endpoint {
  flex: 1;
  min-width: 220px;
  font-family: var(--font-mono);
  font-size: 14.5px;
  color: var(--text);
  background: var(--panel-inset);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 11px 14px;
  overflow-x: auto;
  white-space: nowrap;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-inset);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 11px 16px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.copy-btn.copied {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: var(--ok);
}

.chips-block {
  margin-bottom: 26px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 13px;
}

.chip-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.chip-type {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 2px 7px;
}

.chip-required {
  color: var(--danger);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
}

/* Submissions */
.subs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.subs-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.subs-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.count {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 4px 11px;
}

.count:empty {
  display: none;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

thead tr {
  background: var(--panel-2);
}

th {
  text-align: left;
  padding: 13px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.extra {
  color: var(--accent);
}

td {
  padding: 15px 20px;
  font-size: 14px;
  color: var(--text);
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  max-width: 280px;
  overflow-wrap: break-word;
}

tbody tr:last-child td {
  border-bottom: none;
}

td.time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

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

.file-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 7px;
  padding: 5px 9px;
}

.file-pill:hover {
  text-decoration: underline;
}

.file-pill .size {
  color: var(--muted);
}

.snippet-card {
  margin: 0 0 26px;
}

.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.snippet-head .card-label {
  margin-bottom: 0;
}

.snippet.snippet-full {
  max-width: none;
  margin: 0;
}

.snippet {
  display: block;
  max-width: 440px;
  margin: 0 auto;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* --- Delete dialog --------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 7, 10, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fk-fade 0.2s ease both;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  animation: fk-pop 0.25s ease both;
}

.modal .icon-tile {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  margin: 0 0 18px;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal p {
  margin: 0 0 24px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

.modal p strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 720px) {
  .header-inner,
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .container {
    padding-top: 28px;
  }

  .page-title {
    font-size: 28px;
  }

  .user-name {
    display: none;
  }

  .list-head,
  .list-row {
    grid-template-columns: 2fr 1fr 1.4fr;
  }

  .col-recipient,
  .col-fields {
    display: none;
  }

  .field-grid-head {
    display: none;
  }

  .field-grid-row {
    grid-template-columns: 1fr 1fr;
  }

  .field-grid-row input {
    grid-column: 1 / -1;
  }

  .req-toggle,
  .row-remove {
    justify-self: start;
  }

  .row-remove {
    justify-self: end;
  }
}
