@font-face {
  font-family: "Geist";
  src: url(/assets/geist.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url(/assets/inter.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font-display: "Geist", "Inter", system-ui, -apple-system, sans-serif;
  --font-sans: "Inter", "Geist", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;

  /* Nordic Ocean / Arctic Cyan palette derived from the Mailroom icon */
  --abyss: #06182b;
  --navy: #0a2545;
  --ocean: #0b3c70;
  --cobalt: #0066e6;
  --cobalt-bright: #0ea5e9;
  --cobalt-deep: #004eb8;
  --cyan: #0dc4f2;
  --aqua: #38e4ff;
  --ice: #e4f7ff;
  --ice-soft: #f0f9ff;

  --canvas: #edf4fa;
  --surface: #ffffff;
  --surface-soft: #f5faff;
  --surface-glass: rgba(255, 255, 255, 0.86);

  --ink: #0b2033;
  --text: #324c64;
  --muted: #58728c;
  --muted-soft: #647f99;

  --line: rgba(10, 38, 71, 0.085);
  --line-strong: rgba(10, 38, 71, 0.145);
  --line-cyan: rgba(13, 196, 242, 0.38);

  --danger: #c81e45;
  --danger-bg: #fff1f4;
  --danger-line: rgba(200, 30, 69, 0.24);
  --success: #047857;
  --success-bg: #ecfdf5;

  --shadow-xs: 0 1px 2px rgba(6, 24, 43, 0.04);
  --shadow-sm: 0 2px 10px -2px rgba(6, 32, 64, 0.06), 0 1px 2px rgba(6, 24, 43, 0.035);
  --shadow-md: 0 14px 32px -10px rgba(6, 44, 92, 0.11), 0 2px 8px rgba(6, 24, 43, 0.04);
  --shadow-lg: 0 24px 60px -18px rgba(6, 37, 78, 0.18), 0 6px 16px -4px rgba(6, 24, 43, 0.06);

  --sidebar: 252px;
  --topbar: 66px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 310px;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background: var(--canvas);
  overflow-x: clip;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(760px 480px at 90% -5%, rgba(44, 224, 255, 0.17), transparent 68%),
    radial-gradient(640px 440px at 22% 8%, rgba(0, 136, 245, 0.08), transparent 72%),
    radial-gradient(600px 420px at 78% 95%, rgba(13, 196, 242, 0.08), transparent 70%);
}

button, input, textarea, select { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--cobalt); }
a:hover { color: var(--cobalt-deep); }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ===================== APP SHELL ===================== */
.layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  background: linear-gradient(180deg, rgba(252, 254, 255, 0.94) 0%, rgba(243, 250, 255, 0.90) 100%);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
  transition: transform 0.28s var(--ease), box-shadow 0.28s var(--ease);
}

.sidebar-top { flex: none; margin-bottom: 14px; }

.brand {
  display: inline-flex;
  align-items: center;
  padding: 2px 4px;
  margin: 0 0 16px 4px;
  border-radius: 10px;
  transition: transform 0.2s var(--ease);
}
.brand:hover { transform: translateY(-1px); }
.brand img { width: 158px; height: auto; display: block; }

[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  flex: none;
}
[data-icon] svg,
.nav-item svg,
.button svg,
.icon-btn svg {
  display: block;
}

.workspace-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(13, 196, 242, 0.075);
  border: 1px solid rgba(13, 196, 242, 0.16);
  min-width: 0;
}
.workspace-strip strong {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 560;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.workspace-mode {
  font-size: 10.5px;
  font-weight: 580;
  color: #036091;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid rgba(13, 196, 242, 0.20);
  flex: none;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(13, 196, 242, 0.22);
  flex: none;
}

/* ===================== ANIMATED SIDEBAR NAVIGATION ===================== */
.nav-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 10px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 38, 71, 0.14) transparent;
}

/* Smooth gliding active pill indicator */
.nav-indicator {
  position: absolute;
  left: 0;
  right: 2px;
  top: 0;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(13, 196, 242, 0.16) 0%, rgba(0, 118, 235, 0.08) 100%);
  box-shadow: inset 0 0 0 1px rgba(13, 196, 242, 0.25), 0 4px 14px -6px rgba(13, 196, 242, 0.35);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transform: translateY(0);
  transition:
    transform 0.32s var(--ease),
    height 0.22s var(--ease),
    opacity 0.2s ease;
}
.nav-indicator::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--aqua) 0%, #0284c7 100%);
  box-shadow: 0 0 12px rgba(44, 224, 255, 0.8);
}

.nav-heading {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted-soft);
  text-transform: uppercase;
  letter-spacing: 0.085em;
  margin: 0 10px 6px;
}
.nav-heading:not(:first-of-type) { margin-top: 18px; }

.nav-item {
  position: relative;
  z-index: 1;
  border: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  width: 100%;
  height: 38px;
  margin: 2px 0;
  padding: 0 11px;
  border-radius: 11px;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 480;
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.22s var(--ease), transform 0.18s var(--ease);
}
.nav-item svg { flex: none; opacity: 0.72; transition: opacity 0.2s ease, color 0.2s ease, transform 0.22s var(--ease); }
.nav-item:hover {
  background: rgba(13, 196, 242, 0.08);
  color: var(--abyss);
  transform: translateX(2px);
}
.nav-item:hover svg { opacity: 1; color: #0284c7; }
#nav .nav-item[aria-current="page"] {
  background: transparent;
  color: #034a8c;
  font-weight: 580;
  transform: none;
}
#nav .nav-item[aria-current="page"] svg { opacity: 1; color: #0284c7; transform: scale(1.05); }

/* Bottom utility items keep their own active glow since they're outside #nav */
.sidebar-bottom .nav-item[aria-current="page"] {
  background: linear-gradient(90deg, rgba(13, 196, 242, 0.16) 0%, rgba(0, 118, 235, 0.08) 100%);
  color: #034a8c;
  font-weight: 580;
  box-shadow: inset 0 0 0 1px rgba(13, 196, 242, 0.25);
}
.sidebar-bottom .nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--aqua) 0%, #0284c7 100%);
}
.sidebar-bottom .nav-item[aria-current="page"] svg { opacity: 1; color: #0284c7; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--muted-soft);
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(10, 38, 71, 0.045);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.nav-item[aria-current="page"] .nav-count {
  background: rgba(13, 196, 242, 0.20);
  color: #034a8c;
}
.nav-badge-alert {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #fff;
  padding: 1px 7px;
  border-radius: 99px;
  background: radial-gradient(120% 140% at 15% 0%, #48ecff 0%, #0dbef2 45%, #0077eb 100%);
  box-shadow: 0 2px 10px rgba(13, 190, 242, 0.45);
}

.sidebar-bottom {
  flex: none;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.end { margin-left: auto; color: var(--muted-soft); display: flex; transition: transform 0.18s var(--ease); }
.nav-item:hover .end { transform: translate(2px, -2px); color: #0284c7; }

/* ===================== TOPBAR + INLINE SEARCH + PROFILE ===================== */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: rgba(244, 249, 255, 0.84);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  height: var(--topbar);
  padding: 0 clamp(20px, 3vw, 44px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.crumb, .top-actions { display: flex; align-items: center; gap: 10px; }
.crumb { font-size: 14px; min-width: 0; }
.crumb-root { color: var(--muted-soft); font-weight: 450; }
.slash { color: var(--line-strong); font-weight: 400; }
.crumb-current {
  color: var(--abyss);
  font-family: var(--font-display);
  font-weight: 560;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inline Live Global Search Bar (ZERO modal!) */
.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(240px, 24vw, 330px);
  transition: width 0.24s var(--ease);
}
.global-search-wrap:focus-within {
  width: clamp(300px, 32vw, 410px);
}
.global-search-icon {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-soft);
  pointer-events: none;
  z-index: 1;
}
.topbar .global-search-wrap input[type="search"] {
  min-height: 38px;
  padding: 7px 60px 7px 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.90);
  border: 1px solid var(--line-strong);
  font-size: 13px;
}
.topbar .global-search-wrap input[type="search"]:focus {
  background: #ffffff;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(13, 196, 242, 0.18), var(--shadow-sm);
}
.global-kbd {
  position: absolute;
  right: 9px;
  pointer-events: none;
}
.global-search-wrap:focus-within .global-kbd { opacity: 0; }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 5px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: menuIn 0.18s var(--ease);
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 38, 71, 0.18) transparent;
}
.search-dropdown::-webkit-scrollbar { width: 6px; }
.search-dropdown::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.search-dropdown::-webkit-scrollbar-thumb { background: rgba(10, 38, 71, 0.18); border-radius: 99px; }
.search-dropdown::-webkit-scrollbar-thumb:hover { background: rgba(10, 38, 71, 0.30); }
.search-dropdown .list-row {
  padding: 8px 8px 8px 10px;
  gap: 10px;
  border-radius: 10px;
  border-bottom-color: rgba(10, 38, 71, 0.05);
}
.search-dropdown .tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}
.search-dropdown .tile-icon svg { width: 15px; height: 15px; }
.search-dropdown .row-main strong { font-size: 13.5px; }
.search-dropdown .row-icon { width: 28px; height: 28px; border-radius: 8px; }
.search-dropdown .row-quick-copy { opacity: 0.68; }
.search-dropdown .tag { padding: 2px 7px; font-size: 10.5px; }
.search-dropdown-foot {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px 4px;
  font-size: 11px;
  color: var(--muted-soft);
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

/* Topbar Profile Pill (Right side of navbar — clean, modern position!) */
.topbar-profile {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 5px;
  min-height: 38px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.16s var(--ease);
}
.topbar-profile:hover {
  background: #ffffff;
  border-color: var(--line-cyan);
  box-shadow: 0 6px 18px -6px rgba(13, 196, 242, 0.22);
  transform: translateY(-1px);
}
.topbar-profile[aria-current="page"] {
  border-color: var(--cyan);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(13, 196, 242, 0.14);
}
.topbar-profile-meta {
  display: grid;
  line-height: 1.15;
  max-width: 132px;
}
.topbar-profile strong {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 560;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-profile small {
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 25% 20%, #48ecff 0%, #0dbef2 48%, #0066e6 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 620;
  flex: none;
  box-shadow: 0 3px 10px -2px rgba(13, 190, 242, 0.5);
}

/* ===================== BUTTON SYSTEM (RESTORED BRUTAL LUMINOUS ARCTIC GLOW!) ===================== */
.button, .icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 15px;
  min-height: 38px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 540;
  letter-spacing: -0.01em;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: background 0.2s var(--ease), border-color 0.2s ease, box-shadow 0.22s var(--ease), transform 0.16s var(--ease), color 0.18s ease;
  white-space: nowrap;
}
.button:not(.icon-btn) > svg:first-child,
.button:not(.icon-btn) > [data-icon]:first-child {
  margin-left: -3px;
}
.button:hover, .icon-btn:hover {
  border-color: var(--line-cyan);
  background: #ffffff;
  box-shadow: 0 6px 18px -6px rgba(13, 196, 242, 0.22);
  transform: translateY(-1px);
}
.button:active, .icon-btn:active {
  transform: translateY(0) scale(0.985);
}
.button.primary svg {
  stroke-width: 2.15;
}

/* Primary Button: Aqua Glass */
.button.primary {
  background: linear-gradient(135deg, rgba(44, 224, 255, 0.26) 0%, rgba(14, 165, 233, 0.22) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #043866;
  border: 1px solid rgba(14, 165, 233, 0.44);
  border-radius: 11px;
  padding: 0 16px;
  box-shadow: 0 8px 22px -8px rgba(14, 165, 233, 0.30);
}
.button.primary:hover {
  background: linear-gradient(135deg, rgba(44, 224, 255, 0.42) 0%, rgba(14, 165, 233, 0.34) 100%);
  color: #03284b;
  border-color: rgba(14, 165, 233, 0.68);
  box-shadow: 0 10px 26px -8px rgba(14, 165, 233, 0.45);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text);
}
.button.ghost:hover {
  background: rgba(13, 196, 242, 0.10);
  border-color: transparent;
  color: var(--ocean);
  box-shadow: none;
}
.button.danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: #fff;
}
.button.danger:hover {
  background: var(--danger-bg);
  border-color: rgba(200, 30, 69, 0.4);
  box-shadow: none;
}
.button.danger-confirm {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%) !important;
  color: #fff !important;
  border-color: #be123c !important;
  box-shadow: 0 6px 18px -4px rgba(190, 18, 60, 0.42) !important;
  animation: pulseWarn 0.25s var(--ease);
}
.button.copied {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border-color: #059669 !important;
  color: #fff !important;
  box-shadow: 0 8px 20px -6px rgba(5, 150, 105, 0.42) !important;
}
.button.sm, .button.small { min-height: 32px; padding: 0 11px; font-size: 12px; border-radius: 9px; }

.icon-btn { width: 38px; padding: 0; flex: none; }
.menu-toggle { display: none; }

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 550;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(242, 248, 255, 0.9);
  color: var(--muted);
  white-space: nowrap;
}

/* Inline Popover Menu */
.new-wrap { position: relative; }
.popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 262px;
  max-height: min(74dvh, 520px);
  overflow-y: auto;
  padding: 6px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 45;
  display: grid;
  gap: 2px;
  transform-origin: top right;
  animation: menuIn 0.18s var(--ease);
}
.popover-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-soft);
  padding: 7px 10px 4px;
}
.popover-item {
  border: 0;
  background: transparent;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}
.popover-item:hover {
  background: rgba(13, 196, 242, 0.12);
  color: #034a8c;
}
.popover-item .tile-icon { width: 27px; height: 27px; border-radius: 8px; }
.popover-item .tile-icon svg { width: 14px; height: 14px; }

/* ===================== CONTENT & TYPOGRAPHY ===================== */
.content {
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding: 26px clamp(20px, 3vw, 44px) 52px;
}

.view-enter { animation: viewIn 0.26s var(--ease) both; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title-group {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  flex-wrap: wrap;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 2.5vw, 35px);
  font-weight: 520;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--abyss);
}
h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 520;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
  color: var(--abyss);
}
h3 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 550;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
  color: var(--ink);
}
p { line-height: 1.55; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }

.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  background: rgba(13, 196, 242, 0.13);
  color: #03538c;
  border: 1px solid rgba(13, 196, 242, 0.22);
}
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 540;
  background: rgba(10, 38, 71, 0.055);
  color: var(--ocean);
  border: 1px solid var(--line);
}

/* ===================== COLLECTION SUB-TABS (FIXED: FLUSH LEFT, ZERO STRAY LINE, CLEARLY CLICKABLE!) ===================== */
.collection-tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  margin: 0 0 18px;
  border-radius: 13px;
  background: rgba(10, 38, 71, 0.055);
  border: 1px solid rgba(10, 38, 71, 0.075);
}
.collection-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 14px;
  border-radius: 9px;
  border: 1px solid rgba(10, 38, 71, 0.08);
  background: rgba(255, 255, 255, 0.58);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.14s var(--ease);
}
.collection-tabs button:hover {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--line-cyan);
  color: #034a8c;
  transform: translateY(-1px);
}
.collection-tabs button[aria-pressed="true"] {
  background: #ffffff;
  color: #034a8c;
  font-weight: 580;
  border-color: rgba(13, 196, 242, 0.42);
  box-shadow: 0 3px 10px -2px rgba(6, 36, 74, 0.11), 0 0 0 1px rgba(13, 196, 242, 0.14);
  transform: none;
}
.collection-tabs .tab-badge {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(10, 38, 71, 0.065);
  color: var(--muted);
}
.collection-tabs button[aria-pressed="true"] .tab-badge {
  background: rgba(13, 196, 242, 0.16);
  color: #035a8c;
}

/* ===================== HERO (LUMINOUS ARCTIC MESH) ===================== */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius-xl);
  min-height: 234px;
  display: flex;
  align-items: center;
  padding: 34px 38px;
  color: #ffffff;
  margin-bottom: 22px;
  background:
    radial-gradient(58% 120% at 10% 10%, rgba(56, 232, 255, 0.52) 0%, transparent 56%),
    radial-gradient(50% 95% at 88% 58%, rgba(18, 212, 255, 0.56) 0%, transparent 58%),
    radial-gradient(66% 95% at 68% 0%, rgba(14, 130, 255, 0.72) 0%, transparent 64%),
    linear-gradient(126deg, #051c36 0%, #093b75 42%, #006ce6 78%, #042f61 100%);
  box-shadow:
    0 24px 52px -18px rgba(4, 28, 58, 0.44),
    0 4px 16px rgba(13, 196, 242, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.16), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 45%);
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 540px;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(10px);
  color: #ecfbff;
  margin-bottom: 14px;
}
.hero h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 3.2vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.045em;
  font-weight: 520;
  color: #ffffff;
  margin: 0 0 20px;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.hero-btn {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--abyss);
  border: 1px solid rgba(255, 255, 255, 0.92);
  font-weight: 560;
  box-shadow: 0 12px 26px -8px rgba(4, 20, 42, 0.36);
}
.hero-btn:hover { background: #ffffff; color: #0058c4; border-color: #ffffff; }
.hero-btn svg { stroke-width: 2; }

.hero-btn-ghost {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-weight: 520;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.hero-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.48);
  color: #ffffff;
  box-shadow: 0 10px 24px -8px rgba(3, 18, 38, 0.32);
}

.hero-quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.hero-quick-label {
  font-size: 11px;
  font-weight: 560;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(220, 245, 255, 0.72);
  margin-right: 2px;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 220px;
  min-height: 31px;
  padding: 0 11px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(5, 26, 52, 0.34);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f0fbff;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s var(--ease);
}
.hero-pill:hover {
  background: rgba(56, 228, 255, 0.24);
  border-color: rgba(145, 242, 255, 0.56);
  transform: translateY(-1px);
}
.hero-pill code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #79f2ff;
  flex: none;
}
.hero-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-pill svg {
  opacity: 0.76;
  flex: none;
}
.hero-pill:hover svg { opacity: 1; }

.hero-art {
  position: absolute;
  inset: 0 0 0 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.hero-burst {
  position: absolute;
  right: -32px;
  top: 50%;
  width: 340px;
  height: 340px;
  transform: translateY(-50%);
  opacity: 0.19;
  filter: drop-shadow(0 0 32px rgba(56, 228, 255, 0.55));
}
.hero-orbit {
  position: absolute;
  right: -4%;
  top: -22%;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  border: 1px solid rgba(214, 247, 255, 0.22);
}
.hero-orbit.inner {
  right: 8%;
  top: 2%;
  width: 300px;
  height: 300px;
  border-style: dashed;
  border-color: rgba(56, 228, 255, 0.30);
}
.hero-chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 540;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 34px -8px rgba(3, 18, 38, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.hero-chip code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(56, 228, 255, 0.25);
  color: #ecfcff;
}
.hero-chip.one { left: 16%; top: 20%; animation: chipFloat 6.5s ease-in-out infinite; }
.hero-chip.two { left: 40%; top: 56%; animation: chipFloat 7.2s ease-in-out 1.1s infinite; }
.hero-chip.three { left: 66%; top: 22%; animation: chipFloat 6.0s ease-in-out 0.5s infinite; }

/* ===================== RICH BENTO TOOL CARDS ===================== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}
.section-head h2 { margin: 0; white-space: nowrap; }

.toolgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.tool {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  min-height: 152px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s ease;
  animation: cardStagger 0.32s var(--ease) both;
  overflow: hidden;
}
.tool:nth-child(2) { animation-delay: 0.04s; }
.tool:nth-child(3) { animation-delay: 0.08s; }
.tool:nth-child(4) { animation-delay: 0.12s; }
.tool:hover {
  transform: translateY(-3px);
  border-color: var(--line-cyan);
  box-shadow: var(--shadow-md);
}
.tool-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tool-title-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.tool strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 520;
  color: var(--abyss);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.tool-stat {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 420;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: #0284c7;
  line-height: 1;
}
.tool-preview {
  margin-top: auto;
  padding-top: 12px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(13, 196, 242, 0.10);
  color: #035b8a;
  font-size: 11.5px;
  font-weight: 540;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-chip.mono { font-family: var(--font-mono); font-size: 11px; }
.tool .tool-arrow {
  color: var(--muted-soft);
  display: flex;
  transition: transform 0.2s var(--ease), color 0.2s ease;
}
.tool:hover .tool-arrow { transform: translate(3px, -3px); color: #0284c7; }

/* Tile Icons */
.tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  color: #0284c7;
  background: linear-gradient(135deg, #dff6ff 0%, #c6eeff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.tile-icon.template, .tile-icon.reply { background: linear-gradient(135deg, #e2efff 0%, #cbe2ff 100%); color: #0060df; }
.tile-icon.signature, .tile-icon.preset { background: linear-gradient(135deg, #d8f8f2 0%, #bcf0e7 100%); color: #0f766e; }
.tile-icon.block { background: linear-gradient(135deg, #e4ecff 0%, #d0deff 100%); color: #1d4ed8; }
.tile-icon.subject, .tile-icon.testlab { background: linear-gradient(135deg, #e6eeff 0%, #d4e3fc 100%); color: #1e40af; }
.tile-icon.link, .tile-icon.attachments { background: linear-gradient(135deg, #daf6fa 0%, #bcecf5 100%); color: #0e7490; }
.tile-icon.contact, .tile-icon.correction { background: linear-gradient(135deg, #fef3e2 0%, #fde4c0 100%); color: #b45309; }
.tile-icon.draft { background: linear-gradient(135deg, #ddf2ff 0%, #b9e5ff 100%); color: #0369a1; }
.tile-icon.sequence, .tile-icon.outofoffice { background: linear-gradient(135deg, #e6f0ff 0%, #cfe4ff 100%); color: #0369a1; }

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-width: 0;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.94);
}
.card-head {
  padding: 18px 22px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-head h2 { font-size: 19px; font-weight: 520; margin: 0; }
.card-head a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  text-decoration: none;
  font-weight: 550;
  color: #0284c7;
  min-height: 24px;
}
.card-head a:hover svg { transform: translateX(2px); }
.card-head a svg { transition: transform 0.16s var(--ease); }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}
.home-side { display: grid; gap: 18px; }

/* Segmented Tabs inside Cards & Filters */
.seg-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(10, 38, 71, 0.055);
  border: 1px solid rgba(10, 38, 71, 0.05);
}
.seg-tabs button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 5px 12px;
  min-height: 28px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 520;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.seg-tabs button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.seg-tabs button[aria-pressed="true"] {
  background: #ffffff;
  color: #034a8c;
  font-weight: 580;
  box-shadow: 0 1px 4px rgba(6, 24, 43, 0.10);
}
.card-tabs-bar {
  padding: 0 22px 13px;
  border-bottom: 1px solid var(--line);
}

/* ===================== LIST ROWS ===================== */
.list-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(10, 38, 71, 0.055);
  min-width: 0;
  transition: background-color 0.15s ease;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: rgba(13, 196, 242, 0.05); }
.list-row.active {
  background: linear-gradient(90deg, rgba(13, 196, 242, 0.12) 0%, rgba(0, 102, 230, 0.04) 100%);
}
.list-row.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--aqua) 0%, #0284c7 100%);
}
.list-row .tile-icon { width: 36px; height: 36px; border-radius: 10px; }
.list-row .tile-icon svg { width: 17px; height: 17px; }

.row-main {
  min-width: 0;
  flex: 1;
  background: none;
  border: 0;
  text-align: left;
  padding: 2px 0;
  color: inherit;
}
.row-main strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 540;
  font-size: 14.5px;
  letter-spacing: -0.015em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.14s ease;
}
.row-main:hover strong, .list-row.active .row-main strong { color: #0263b8; }

.row-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row-excerpt {
  color: var(--muted-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shortcut-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(13, 196, 242, 0.13);
  color: #036091;
  flex: none;
}
.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  border: 1px solid rgba(6, 24, 43, 0.16);
}
.row-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.row-icon {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-soft);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.16s var(--ease-spring), opacity 0.15s ease;
}
.row-icon:hover { color: #0284c7; background: rgba(13, 196, 242, 0.13); }
.row-icon[aria-pressed="true"] { color: #d97706; background: #fef3c7; }
.row-icon[aria-pressed="true"] svg { fill: #f59e0b; stroke: #d97706; }
.row-icon.star-pop svg { animation: starPop 0.32s var(--ease-spring); }
.row-quick-copy { opacity: 0.45; }
.list-row:hover .row-quick-copy,
.list-row.active .row-quick-copy,
.row-quick-copy:focus-visible { opacity: 1; }

.tag {
  border-radius: 99px;
  background: rgba(13, 196, 242, 0.12);
  color: #035a8c;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 580;
  white-space: nowrap;
}
.tag.cyan { background: rgba(13, 196, 242, 0.15); color: #036091; }
.tag.neutral { background: rgba(10, 38, 71, 0.06); color: var(--text); }
.tag.locked { background: var(--danger-bg); color: var(--danger); }
.tag.warn { background: #fdf1e3; color: #8a5a12; }

/* Overview Side Cards */
.shortcuts { padding: 4px 22px 20px; }
.shortcut-info {
  padding: 11px 0;
  border-bottom: 1px solid rgba(10, 38, 71, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 480;
}
.shortcut-info:last-of-type { border-bottom: 0; margin-bottom: 14px; }

.sig-spotlight { padding: 0 22px 20px; display: grid; gap: 12px; }
.sig-spotlight-box {
  padding: 14px 16px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #ffffff;
}

/* ===================== MASTER–DETAIL SPLIT WORKSPACE (ZERO POPUPS!) ===================== */
.workspace-split {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.master-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: calc(var(--topbar) + 20px);
  max-height: calc(100dvh - var(--topbar) - 44px);
}
.master-controls {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
  display: grid;
  gap: 10px;
}
.search-field { position: relative; }
.search-field svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-soft);
  pointer-events: none;
}
.search-field input { padding-left: 34px !important; }
.master-search-row { display: flex; align-items: center; gap: 8px; }
.master-search-row .search-field { flex: 1; min-width: 0; }
.master-extra-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.master-extra-filters select {
  flex: 1 1 110px;
  min-height: 34px;
  padding: 5px 10px;
  font-size: 12px;
}
.filter-row { display: flex; align-items: center; gap: 8px; }
.filter-row .seg-tabs {
  width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}
.filter-row .seg-tabs button { justify-content: center; padding: 5px 6px; }
.master-list {
  overflow-y: auto;
  flex: 1;
  min-height: 180px;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 38, 71, 0.14) transparent;
}

/* Detail Stage */
.detail-stage { min-width: 0; overflow: hidden; animation: stageIn 0.24s var(--ease) both; }
.stage-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.stage-title-wrap { display: flex; align-items: center; gap: 13px; min-width: 0; flex: 1; }
.stage-title-wrap h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 520;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.stage-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.stage-body { padding: 22px 24px 24px; display: grid; gap: 16px; }
.stage-back { display: none; }

/* Realistic Preview Frame */
.preview-frame {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.preview-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 15px;
  background: linear-gradient(180deg, #f8fcff 0%, #f0f7fd 100%);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.preview-dots { display: flex; gap: 5px; }
.preview-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(10, 38, 71, 0.14); }
.preview-headers {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(10, 38, 71, 0.06);
  background: #fbfdff;
  display: grid;
  gap: 5px;
  font-size: 13px;
}
.preview-header-line { display: flex; gap: 10px; align-items: baseline; }
.preview-header-line span:first-child { color: var(--muted-soft); font-weight: 560; min-width: 56px; font-size: 12px; }
.preview-subject { font-family: var(--font-display); font-weight: 560; color: var(--abyss); font-size: 15px; }
.preview {
  padding: 18px 20px;
  min-height: 96px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.62;
  background: #ffffff;
  transition: max-width 0.25s var(--ease);
}
.preview p { margin: 0; white-space: pre-wrap; }
.preview.mobile {
  max-width: 340px;
  margin: 14px auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.preview img { max-width: 100%; }

.token-missing {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
}

.fields-panel {
  padding: 15px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3fbff 0%, #ebf7fe 100%);
  border: 1px solid rgba(13, 196, 242, 0.20);
  display: grid;
  gap: 12px;
}
.fields-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.fields-panel-head strong {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 560;
  color: var(--ocean);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Inline Field Insertion Helper (no prompt() popup!) */
.field-insert {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.field-insert select, .field-insert input { flex: 1 1 150px; max-width: 210px; min-height: 33px; padding: 5px 10px; font-size: 12.5px; }

/* Repeaters & Collapsible More Options */
.repeater-row {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 13px;
  display: grid;
  gap: 10px;
  background: var(--surface-soft);
}
.advanced {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 14px;
  background: var(--surface-soft);
}
.advanced > summary { cursor: pointer; font-family: var(--font-display); font-size: 13px; font-weight: 560; color: var(--ocean); }
.advanced[open] > summary { margin-bottom: 12px; }
.advanced .form { gap: 12px; }

/* Swatches */
.swatch-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(10, 38, 71, 0.18);
  padding: 0;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 2px var(--cyan); transform: scale(1.08); }

/* Version Timeline & Proposal Diff */
.timeline { display: grid; gap: 8px; }
.timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
.timeline-item.current {
  background: linear-gradient(90deg, rgba(13, 196, 242, 0.08) 0%, #f8fcff 100%);
  border-color: var(--line-cyan);
}
.timeline-item strong { display: block; font-size: 13.5px; font-weight: 560; color: var(--ink); }
.timeline-item small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.diff {
  display: grid;
  gap: 2px;
  font: 12.5px/1.55 var(--font-mono);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  overflow: auto;
  max-height: 280px;
  white-space: pre-wrap;
}
.diff .add { background: #e8f8ef; color: #0c5c3a; padding: 1px 6px; border-radius: 4px; }
.diff .remove { background: #fdecef; color: #8c2036; text-decoration: line-through; padding: 1px 6px; border-radius: 4px; }
.diff .same { color: var(--muted); padding: 1px 6px; }

/* ===================== FORMS & INPUTS ===================== */
.field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 540; color: var(--text); min-width: 0; }
.field small { font-size: 11.5px; font-weight: 420; color: var(--muted); line-height: 1.4; }
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  padding: 3px 0;
  cursor: pointer;
}
.check input { width: 16px; height: 16px; accent-color: #0284c7; flex: none; }

input:not([type="checkbox"]):not([type="color"]), textarea, select {
  width: 100%;
  padding: 9px 12px;
  min-height: 39px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13.5px;
  box-shadow: inset 0 1px 2px rgba(6, 24, 43, 0.025);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
input:not([type="checkbox"]):not([type="color"]):hover, textarea:hover, select:hover { border-color: rgba(13, 196, 242, 0.45); }
input:not([type="checkbox"]):not([type="color"]):focus, textarea:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(13, 196, 242, 0.18);
  outline: none;
}
input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 112px; line-height: 1.6; }

.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.actions .spacer { flex: 1; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
}
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 1 1 220px; min-width: 160px; }
.toolbar select { flex: 0 1 auto; width: auto; max-width: 190px; }
.toolbar .spacer { flex: 1; }

/* Toggle Switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  cursor: pointer;
}
.switch-row span strong { display: block; font-size: 13.5px; font-weight: 550; color: var(--ink); }
.switch-row span small { display: block; font-size: 12px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: rgba(10, 38, 71, 0.18);
  transition: background-color 0.2s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(6, 24, 43, 0.2);
  transition: transform 0.22s var(--ease-spring);
}
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--aqua) 0%, #0284c7 100%); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }

/* ===================== ATTACHMENTS, TEST LAB, SETTINGS, INTEGRATIONS ===================== */
.dropzone {
  display: grid;
  place-items: center;
  gap: 6px;
  margin: 0 0 16px;
  padding: 28px 18px;
  border: 1.5px dashed rgba(13, 196, 242, 0.45);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(244, 251, 255, 0.85) 0%, rgba(255, 255, 255, 0.9) 100%);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.dropzone:hover, .dropzone.over {
  border-color: #0284c7;
  background: rgba(13, 196, 242, 0.09);
  box-shadow: 0 0 0 4px rgba(13, 196, 242, 0.10);
}
.dropzone strong { font-family: var(--font-display); font-size: 15px; font-weight: 550; color: var(--abyss); }
.dropzone span { color: var(--muted); font-size: 12.5px; }

.progress { height: 7px; border-radius: 999px; background: rgba(10, 38, 71, 0.08); overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #0077eb, #38e4ff); transition: width 0.2s ease; }

.inline-drawer {
  padding: 16px 18px;
  margin-bottom: 14px;
  border-radius: 15px;
  border: 1px solid var(--line-cyan);
  background: linear-gradient(180deg, #f5fbff 0%, #ffffff 100%);
  box-shadow: var(--shadow-sm);
  animation: menuIn 0.2s var(--ease);
}
.inline-rename-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.inline-rename-row input { flex: 1 1 180px; min-height: 34px; padding: 6px 10px; font-size: 13px; }

.dual-preview { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 16px; }
.settings-grid, .composer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.integration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.box { padding: 22px 24px; }
.box p { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }

.integration-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s ease;
}
.integration-card:hover { transform: translateY(-2px); border-color: var(--line-cyan); box-shadow: var(--shadow-md); }
.integration-card h2 { margin: 16px 0 6px; font-size: 19px; font-weight: 520; }
.integration-card .integration-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 8px; }

.pair-studio { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.pair-code-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 13px;
  background: linear-gradient(135deg, #effaff 0%, #e4f5ff 100%);
  border: 1px solid rgba(13, 196, 242, 0.26);
  margin-top: 14px;
  flex-wrap: wrap;
}
.pair-code { font-family: var(--font-mono); font-size: 15px; font-weight: 650; letter-spacing: 0.06em; color: var(--abyss); word-break: break-all; margin: 0; }

.hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9px;
  background: #fffbeb;
  border: 1px solid rgba(217, 119, 6, 0.22);
  color: #92400e;
  font-size: 12.5px;
  font-weight: 520;
  width: max-content;
  max-width: 100%;
}
.notice {
  padding: 10px 14px;
  border-radius: 11px;
  background: rgba(13, 196, 242, 0.09);
  border: 1px solid rgba(13, 196, 242, 0.20);
  color: var(--ocean);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.note { font-size: 12px; color: var(--muted); margin: 0; }
.error { color: var(--danger); font-size: 12.5px; font-weight: 540; margin: 0; min-height: 0; }
.error:empty { display: none; }

.empty {
  padding: 36px 20px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: rgba(13, 196, 242, 0.10);
  color: #0284c7;
  display: grid;
  place-items: center;
}

.approvals { margin-bottom: 18px; border-color: rgba(13, 196, 242, 0.30); }
.approval-actions { display: flex; align-items: center; gap: 6px; flex: none; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  z-index: 60;
  bottom: 22px;
  right: 22px;
  max-width: min(380px, calc(100% - 36px));
  padding: 11px 16px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--abyss) 0%, var(--navy) 100%);
  border: 1px solid rgba(56, 228, 255, 0.28);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 16px 36px -8px rgba(4, 20, 42, 0.45);
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toastIn 0.24s var(--ease);
}
.toast svg { color: var(--aqua); flex: none; }

.loading-shell { display: grid; gap: 18px; }
.loading-pulse { height: 220px; border-radius: var(--radius-xl); background: linear-gradient(90deg, #e5eff8 25%, #f0f8fe 50%, #e5eff8 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.loading-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.loading-grid div { height: 140px; border-radius: var(--radius-lg); background: linear-gradient(90deg, #e9f2fa 25%, #f4f9fe 50%, #e9f2fa 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(6, 24, 43, 0.36);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

/* ===================== ANIMATIONS ===================== */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes stageIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes cardStagger { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chipFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes starPop { 0% { transform: scale(0.75); } 60% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes pulseWarn { 0% { transform: scale(0.96); } 100% { transform: scale(1); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1120px) {
  :root { --sidebar: 226px; }
  .toolgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: 1fr; }
  .integration-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-split { grid-template-columns: minmax(270px, 340px) minmax(0, 1fr); }
  .topbar-profile-meta { display: none; }
  .topbar-profile { padding: 4px; }
}
@media (max-width: 860px) {
  .workspace-split { grid-template-columns: 1fr; }
  .master-panel { position: static; max-height: none; }
  .workspace-split.has-detail .master-panel { display: none; }
  .workspace-split:not(.has-detail) .detail-stage { display: none; }
  .stage-back { display: inline-flex; }
  .composer-grid, .settings-grid, .dual-preview { grid-template-columns: 1fr; }
}
@media (max-width: 740px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(270px, 82vw);
    transform: translateX(-105%);
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 14px 0 42px rgba(4, 24, 48, 0.28); }
  .menu-toggle { display: inline-flex; }
  .crumb-root, .crumb .slash, .global-kbd { display: none; }
  .global-search-wrap { width: 150px; }
  .global-search-wrap:focus-within { width: 200px; }
  .global-search-wrap input[type="search"] { padding-right: 10px; }
  .search-dropdown { left: auto; right: 0; width: min(340px, calc(100vw - 28px)); }
  .topbar { height: 58px; }
  .content { padding-top: 18px; }
  .hero { padding: 24px; min-height: 204px; }
  .hero-art { opacity: 0.34; left: 52%; }
  .hero-chip { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .integration-grid { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .global-search-wrap { width: 120px; }
  .row-quick-copy { opacity: 1; }
  .list-row > .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===================== SIGNATURE STUDIO V2 ===================== */
.sig-templates { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }
.sig-assets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sig-asset { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface-soft); display: grid; gap: 6px; }
.sig-asset-label { font-size: 11.5px; font-weight: 650; color: var(--text); }
.sig-asset-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sig-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.sig-preview-tools { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.sig-preview-tools button { min-height: 26px; padding: 0 8px; font-size: 11px; border: 1px solid transparent; background: transparent; border-radius: 7px; color: var(--muted); font-weight: 600; cursor: pointer; }
.sig-preview-tools button.active { background: rgba(13, 196, 242, 0.14); color: #036091; border-color: rgba(13, 196, 242, 0.3); }
.preview.preview-dark { background: #0f172a; }
@media (max-width: 740px) { .sig-assets { grid-template-columns: 1fr; } }

/* ===================== SIGNATURE TEMPLATE GALLERY ===================== */
.sig-template-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 0; }
.sig-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.sig-gallery-card { border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 12px; display: grid; gap: 10px; align-content: start; box-shadow: var(--shadow-sm); }
.sig-gallery-preview { height: 210px; overflow: hidden; position: relative; border-radius: 10px; background: #f4f8fc; padding: 10px; }
.sig-gallery-preview > table { transform: scale(0.45); transform-origin: top left; }
.sig-gallery-meta strong { display: block; font-size: 13.5px; }
.sig-gallery-meta span { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-top: 2px; }
.sig-gallery-blank { place-items: center; text-align: center; border-style: dashed; min-height: 270px; align-content: center; }
.sig-gallery-blank-art { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-soft); display: grid; place-items: center; color: #0284c7; }

.sig-gallery { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.sig-gallery-preview { height: 160px; background: linear-gradient(180deg, #f7fbff 0%, #eef6fc 100%); }
.sig-gallery-preview.dark { background: #0f172a; }
.sig-gallery-preview > table { transform: scale(0.46); }

.sig-outline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface-soft); font-size: 12px; }
.sig-outline label { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.sig-outline select, .sig-outline input[type=number] { min-height: 30px; }
.sig-outline .note { flex-basis: 100%; color: var(--muted); font-weight: 400; }

/* ===================== GALLERY FULL-WIDTH + READABLE PREVIEWS ===================== */
.workspace-split.gallery-mode { grid-template-columns: minmax(0, 1fr); }
.workspace-split.gallery-mode .master-panel { display: none; }
.sig-gallery { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.sig-gallery-card { padding: 14px; }
.sig-gallery-preview { height: auto; min-height: 104px; padding: 12px; background: #f7fbff; overflow: hidden; position: relative; }
.sig-gallery-preview.dark { background: #0f172a; }
.sig-gallery-preview > table { transform-origin: top left; }
.sig-gallery-card .button { justify-self: end; width: auto; min-height: 32px; }
.sig-dark-switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.sig-dark-switch input { width: 15px; height: 15px; accent-color: #0ea5e9; }
.sig-preview-tools .sig-dark-switch { margin-left: auto; }
@media (max-width: 720px) {
  .sig-gallery { grid-template-columns: 1fr; }
  .sig-gallery-preview { min-height: 80px; }
}

@media (max-width: 720px) {
  .stage-head { flex-wrap: wrap; row-gap: 10px; }
  .stage-head .stage-title-wrap { flex: 1 1 100%; min-width: 0; }
  .stage-head .sig-dark-switch { margin-left: 0; }
  .stage-head [data-gallery-cancel] { margin-left: auto; }
}

.preview-toggle { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); }
.preview-toggle button { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 650; line-height: 1; cursor: pointer; }
.preview-toggle button.active { background: #ffffff; color: #0b5ed7; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14); }

.sig-gallery-preview { pointer-events: none; }

#signature-preview [data-sig-field] { cursor: text; border-radius: 3px; outline: 1px dashed transparent; outline-offset: 2px; }
#signature-preview [data-sig-field]:hover { outline-color: rgba(14, 165, 233, 0.4); }
#signature-preview [data-sig-field]:focus { outline: 2px solid #0ea5e9; background: rgba(14, 165, 233, 0.07); }


/* ===================== BLOCK BUILDER ===================== */
.builder-add { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.builder-block { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); margin-bottom: 8px; overflow: hidden; }
.builder-block.dragging { opacity: 0.5; }
.builder-block-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #fff; border-bottom: 1px solid var(--line); }
.builder-block-head strong { font-size: 12px; }
.builder-grip { cursor: grab; color: var(--muted); font-size: 13px; letter-spacing: -2px; }
.builder-block-actions { margin-left: auto; display: flex; gap: 4px; }
.builder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.builder-field { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; color: var(--muted); min-width: 0; }
.builder-field > span { font-weight: 650; }
.builder-field select, .builder-field input, .builder-field textarea { min-height: 30px; font-size: 12px; width: 100%; }
.builder-field textarea { min-height: 54px; resize: vertical; grid-column: 1 / -1; }
.builder-field-wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .builder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Keep the live preview visible while arranging blocks */
#detail-stage .preview-frame { position: sticky; top: 10px; z-index: 6; background: var(--surface); }
@media (max-width: 720px) { #detail-stage .preview-frame { position: static; } }

.detail-stage { overflow: visible; }
#detail-stage .preview-frame { top: 86px; }
@media (max-width: 720px) { .detail-stage { overflow: hidden; } }

/* Visual block cards */
.builder-block { background: #fff; }
.builder-block-preview { min-height: 46px; padding: 9px 11px; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; pointer-events: none; }
.builder-block-preview .sig-name { font-size: 15px; }
.builder-block-preview img { max-width: 100%; }
.builder-empty { color: var(--muted); font-size: 11px; font-style: italic; }
.builder-align { display: flex; gap: 2px; margin-left: 4px; }
.builder-icon-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.builder-icon-btn:hover { background: var(--surface-soft); color: #0284c7; }
.builder-icon-btn.active { background: #e0f2fe; border-color: #bae6fd; color: #0369a1; }
.builder-icon-btn.danger:hover { background: #fee2e2; color: #b91c1c; }
.builder-block-actions { gap: 2px; }
.builder-block-settings { background: #fbfdff; border-top: 1px solid var(--line); }
.builder-block-settings[hidden] { display: none; }
.builder-block-head { gap: 6px; }
.builder-block-head strong { margin-right: auto; }

.builder-add { align-items: center; }
.builder-add strong { font-size: 11px; color: var(--muted); margin-right: 2px; }

/* ===================== SIGNATURE STUDIO (Paperwork-style) ===================== */
.studio { display: flex; flex-direction: column; min-height: calc(100vh - 110px); background: #eaf3fa; }
.studio-head { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.studio-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.studio-title h2 { margin: 0; font-size: 18px; }
.studio-title p { margin: 2px 0 0; font-size: 11.5px; }
.studio-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.studio-body { display: grid; grid-template-columns: 206px minmax(0, 1fr) 304px; min-height: 0; flex: 1; }
.studio-palette-pane { background: #fff; border-right: 1px solid var(--line); padding: 14px; overflow: auto; }
.studio-palette-pane h3, .studio-inspector h3, .studio-inspector h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .02em; }
.studio-palette-pane > .note { margin: 4px 0 10px; font-size: 10.5px; line-height: 1.4; }
.studio-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding-bottom: 12px; }
.studio-palette-item { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font-size: 10.5px; font-weight: 650; text-align: left; cursor: grab; }
.studio-palette-item:hover { border-color: #7dd3fc; background: #f0f9ff; color: #0369a1; }
.studio-palette-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #e0f2fe; color: #0369a1; }
.studio-canvas-pane { overflow: auto; padding: 16px 20px 60px; }
.studio-canvas-head { display: flex; justify-content: space-between; max-width: 660px; margin: 0 auto 8px; color: var(--muted); font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.studio-page { width: 600px; max-width: 100%; min-height: 360px; margin: 0 auto; padding: 26px 28px; background: #fff; border-radius: 8px; box-shadow: 0 14px 40px rgba(10, 37, 69, .12); transition: background .2s ease; }
.studio-page.dark { background: #0f172a; }
.studio-empty { display: grid; place-items: center; gap: 4px; min-height: 260px; border: 2px dashed #bae6fd; border-radius: 10px; color: var(--muted); text-align: center; font-size: 12px; }
.studio-empty strong { color: #0369a1; }
.studio-block { position: relative; padding: 2px 0; }
.studio-block:hover { outline: 1px dashed #7dd3fc; outline-offset: 3px; }
.studio-block.selected { outline: 2px solid #0ea5e9; outline-offset: 3px; border-radius: 3px; }
.studio-block-inner { overflow: hidden; }
.studio-block-inner a { cursor: text; }
.studio-drag { position: absolute; left: -21px; top: 4px; display: grid; place-items: center; width: 17px; height: 24px; color: #7b94a9; cursor: grab; opacity: 0; }
.studio-block:hover .studio-drag, .studio-block.selected .studio-drag { opacity: 1; }
.studio-block-tools { position: absolute; right: -2px; top: -12px; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: var(--shadow-sm); opacity: 0; pointer-events: none; z-index: 3; }
.studio-block:hover .studio-block-tools, .studio-block.selected .studio-block-tools { opacity: 1; pointer-events: auto; }
.studio-block-tools button { display: grid; place-items: center; width: 23px; height: 23px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.studio-block-tools button:hover { background: #e0f2fe; color: #0369a1; }
.studio-block-tools button.danger:hover { background: #fee2e2; color: #b91c1c; }
.studio-block.drop-target { border-top: 3px solid #0ea5e9; }
.studio-drop-tail { height: 22px; }
.studio-empty-block { display: inline-block; padding: 6px 0; color: #7b94a9; font-size: 11px; font-style: italic; }
.studio-inspector { background: #fff; border-left: 1px solid var(--line); overflow: auto; }
.studio-tabs { display: flex; position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); }
.studio-tab { flex: 1; padding: 11px 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 11px; font-weight: 650; cursor: pointer; }
.studio-tab.active { color: #0369a1; border-bottom-color: #0ea5e9; }
.studio-inspector-body { padding: 14px; }
.studio-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.studio-panel-head strong { font-size: 13px; display: block; }
.studio-panel-head .note { display: block; font-size: 10px; }
.studio-panel-empty { padding: 20px 4px; color: var(--muted); font-size: 12px; }
.studio-mini-actions { display: flex; gap: 2px; }
.studio-mini-actions button { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); cursor: pointer; }
.studio-mini-actions button.danger:hover { background: #fee2e2; color: #b91c1c; }
.studio-align-row { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); margin-bottom: 10px; }
.studio-align-row button { flex: 1; display: grid; place-items: center; height: 27px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.studio-align-row button.active { background: #fff; color: #0369a1; box-shadow: var(--shadow-sm); }
.studio-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.studio-field { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; color: var(--muted); min-width: 0; }
.studio-field > span { font-weight: 650; }
.studio-field input, .studio-field select, .studio-field textarea { width: 100%; min-height: 30px; font-size: 11.5px; }
.studio-field textarea { min-height: 56px; resize: vertical; }
.studio-field-wide { grid-column: 1 / -1; }
.studio-theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.studio-theme { display: flex; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 10.5px; font-weight: 600; color: var(--text); text-align: left; cursor: pointer; }
.studio-theme span { width: 16px; height: 16px; border-radius: 5px; flex: 0 0 auto; }
.studio-theme.active { border-color: #0ea5e9; box-shadow: 0 0 0 2px #bae6fd; }
.studio-socials { margin-top: 12px; }
.studio-socials-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.studio-social-row { display: grid; grid-template-columns: 82px 1fr 26px; gap: 4px; margin-bottom: 4px; }
.studio-social-row select, .studio-social-row input { min-height: 29px; font-size: 10.5px; width: 100%; }
.studio-social-row button { border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); cursor: pointer; }
.studio-upload-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.studio-upload-thumb { width: 38px; height: 38px; object-fit: contain; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
@media (max-width: 1100px) { .studio-body { grid-template-columns: 168px minmax(0, 1fr) 270px; } .studio-palette { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .studio-body { grid-template-columns: 1fr; } .studio-palette-pane { border-right: 0; border-bottom: 1px solid var(--line); } .studio-palette { grid-template-columns: 1fr 1fr; } .studio-inspector { border-left: 0; border-top: 1px solid var(--line); } .studio-page { width: 100%; } }

/* ===================== STUDIO POLISH ===================== */
.studio-palette-pane h3 { font-size: 12.5px; font-weight: 700; letter-spacing: .01em; margin-bottom: 4px; }
.studio-palette-pane > .note { font-size: 11px; line-height: 1.45; margin: 4px 0 12px; }
.studio-palette { gap: 8px; }
.studio-palette-item { min-height: 84px; justify-content: center; align-items: center; text-align: center; gap: 8px; padding: 10px 8px; font-size: 11px; line-height: 1.25; letter-spacing: 0; }
.studio-palette-icon { width: 30px; height: 30px; border-radius: 9px; }
.studio-palette-item > span:last-child { min-height: 27px; display: flex; align-items: center; justify-content: center; }
.studio-tabs .studio-tab { padding: 12px 8px; font-size: 12px; letter-spacing: 0; }
.studio-inspector-body { padding: 16px; }
.studio-panel-head { margin-bottom: 12px; align-items: center; }
.studio-panel-head strong { font-size: 13px; }
.studio-panel-head .note { margin-top: 1px; font-size: 10.5px; }
.studio-mini-actions button { width: 28px; height: 28px; }
.studio-align-row { margin-bottom: 12px; }
.studio-align-row button { height: 30px; }
.studio-field-grid { gap: 10px 8px; }
.studio-field { gap: 5px; font-size: 11px; }
.studio-field > span { font-size: 10.5px; font-weight: 650; line-height: 1.25; }
.studio-field input, .studio-field select { height: 34px; padding: 7px 9px; border-radius: 8px; font-size: 12px; }
.studio-field textarea { min-height: 68px; padding: 8px 9px; border-radius: 8px; font-size: 12px; line-height: 1.45; }
.studio-details-grid { grid-template-columns: 1fr; gap: 11px; }
.studio-details-grid > .studio-field, .studio-details-grid > .studio-field-wide { grid-column: 1 / -1; }
.studio-divider { border-top: 1px solid var(--line); margin: 16px 0; }
.studio-inspector h4 { margin: 18px 0 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.studio-theme-grid { gap: 8px; margin-bottom: 12px; }
.studio-theme { padding: 8px; font-size: 11px; gap: 8px; }
.studio-social-row { grid-template-columns: 88px minmax(0, 1fr) 30px; gap: 6px; margin-bottom: 6px; }
.studio-social-row select, .studio-social-row input { height: 32px; font-size: 11px; padding: 6px 7px; }
.studio-social-row button { height: 32px; }
.studio-upload-row { min-height: 36px; margin: 8px 0; gap: 10px; }
.studio-upload-thumb { width: 36px; height: 36px; }
.studio-field-wide { grid-column: 1 / -1; }

.studio-palette-item { height: 88px; min-height: 88px; }

/* Studio card layout: separate header and three panes, scroll inside inspector */
.detail-stage.studio-mode { height: calc(100dvh - 64px); min-height: 560px; overflow: hidden; }
.studio { height: 100%; min-height: 0; padding: 12px; gap: 12px; overflow: hidden; background: #eaf3fa; }
.studio-head { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: #fff; box-shadow: var(--shadow-sm); }
.studio-body { flex: 1; min-height: 0; gap: 12px; }
.studio-palette-pane, .studio-inspector, .studio-canvas-pane { min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.studio-palette-pane { border-right: 1px solid var(--line); }
.studio-inspector { border-left: 1px solid var(--line); }
.studio-canvas-pane { background: #e3eef7; border-color: #d4e5f2; padding: 16px 18px 40px; }
.studio-canvas-head { margin-bottom: 10px; }
@media (max-width: 860px) {
  .detail-stage.studio-mode { height: auto; min-height: 0; overflow: visible; }
  .studio { height: auto; overflow: visible; padding: 8px; }
  .studio-body { grid-template-columns: 1fr; gap: 10px; }
  .studio-inspector { max-height: 70vh; }
  .studio-palette-pane, .studio-canvas-pane { border-radius: 12px; }
}

body.studio-open { overflow: hidden; }

/* Studio hover: inset states, single toolbar, always-visible centred drag handle */
.studio-block { padding: 2px 0; }
.studio-block:hover { outline: 0; box-shadow: inset 0 0 0 1px #bae6fd; background: rgba(14, 165, 233, 0.035); border-radius: 4px; }
.studio-block.selected { outline: 0; box-shadow: inset 0 0 0 2px #0ea5e9; background: rgba(14, 165, 233, 0.04); border-radius: 4px; z-index: 2; }
.studio-block-tools { top: -14px; right: -4px; z-index: 6; }
.studio-block:hover .studio-block-tools { opacity: 0; pointer-events: none; }
.studio-block.selected .studio-block-tools { opacity: 1; pointer-events: auto; }
.studio-drag { left: -25px; top: 50%; transform: translateY(-50%); width: 18px; height: 30px; opacity: 0.45; background: #f0f9ff; border: 1px solid #dbeafe; border-radius: 6px; color: #7b94a9; }
.studio-block:hover .studio-drag, .studio-block.selected .studio-drag { opacity: 1; color: #0369a1; border-color: #bae6fd; }
.studio-drag[title] { cursor: grab; }

.sig-card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.sig-card-actions .button { width: auto; justify-self: auto; }

/* Studio icon + emoji pickers and identity media */
#studio-page [data-sig-icon] { cursor: pointer; }
#studio-page [data-sig-icon]:hover { outline: 2px solid rgba(14, 165, 233, 0.4); outline-offset: 1px; border-radius: 3px; }
.studio-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(6, 24, 43, 0.42); backdrop-filter: blur(2px); }
.studio-overlay[hidden] { display: none; }
.studio-modal { width: min(560px, 100%); max-height: min(80vh, 720px); display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(6, 24, 43, 0.3); }
.studio-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.studio-modal-head strong { display: block; font-size: 14px; }
.studio-modal-head .note { display: block; margin-top: 2px; font-size: 10.5px; }
.studio-modal-close { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); cursor: pointer; }
.studio-icon-tools { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfdff; }
.studio-icon-tools input[type=search] { flex: 1; height: 34px; padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.studio-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 14px; overflow: auto; }
.studio-icon-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 76px; padding: 9px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font-size: 10.5px; font-weight: 650; cursor: pointer; }
.studio-icon-choice:hover { border-color: #7dd3fc; background: #f0f9ff; color: #0369a1; }
.studio-icon-choice.active { border-color: #0ea5e9; box-shadow: 0 0 0 2px #bae6fd; }
.studio-icon-choice img { width: 26px; height: 26px; object-fit: contain; }
.studio-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; padding: 12px 14px; overflow: auto; }
.studio-emoji-choice { height: 42px; border: 0; border-radius: 8px; background: transparent; font-size: 23px; cursor: pointer; }
.studio-emoji-choice:hover { background: #e0f2fe; }
.studio-modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.studio-inline-action { display: flex; justify-content: flex-start; margin-top: 10px; }

.studio-history { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.studio-history button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.studio-history button:hover:not(:disabled) { background: #e0f2fe; color: #0369a1; }
.studio-history button:disabled { opacity: 0.3; cursor: not-allowed; }
@media (max-width: 860px) { body.studio-open { overflow: auto; } }

.studio-columns-config { display: grid; gap: 7px; border: 1px dashed var(--line); border-radius: 10px; padding: 9px; margin-top: 2px; }
.studio-column-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 7px; align-items: center; }
.studio-column-row strong { font-size: 10.5px; color: var(--muted); }
.studio-column-row input { grid-column: 2; height: 32px; font-size: 11.5px; }
.studio-column-row select { height: 32px; font-size: 11.5px; }

@media (max-width: 860px) {
  .studio-palette-pane { padding: 10px; }
  .studio-palette { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
  .studio-palette-item { width: 88px; min-width: 88px; height: 72px; min-height: 72px; padding: 6px; gap: 4px; }
  .studio-palette-icon { width: 26px; height: 26px; }
  .studio-palette-item > span:last-child { min-height: 20px; font-size: 10px; }
  .studio-body { display: flex; flex-direction: column; gap: 10px; }
  .studio-palette-pane { order: 0; }
  .studio-canvas-pane { order: 1; padding: 10px 10px 24px; }
  .studio-inspector { order: 2; max-height: none; }
  .studio-page { padding: 16px; }
}

@media (max-width: 860px) {
  .studio-page { width: 600px; max-width: none; zoom: 0.55; }
}
