/* ==========================================================================
   Link Creating Tool — dark green rail, warm paper canvas, serif headlines.
   ========================================================================== */

:root {
  --rail: #123a2c;
  --rail-hover: rgba(255, 255, 255, .08);
  --rail-active: rgba(255, 255, 255, .13);

  --hero: #164534;
  --accent: #146b45;
  --accent-soft: #d5ecdd;
  --accent-ink: #0f5133;

  --paper: #f4f4ef;
  --card: #ffffff;
  --line: #e6e4dc;
  --line-soft: #efede6;

  --ink: #1b1c1a;
  --ink-2: #43473f;
  --muted: #767a70;

  --ok-bg: #ddf0e4;   --ok-ink: #106b45;
  --warn-bg: #fbeed4; --warn-ink: #8a5b09;
  --bad-bg: #fbe2df;  --bad-ink: #93302a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 8px 24px rgba(20, 30, 25, .05);
}

* { box-sizing: border-box; }

/* Several components set an explicit display, which would otherwise beat the
   hidden attribute's UA rule and leave "hidden" panels on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

code, pre { font-family: var(--mono); font-size: 12.5px; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* --- Shell ------------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; }

.rail {
  width: 258px;
  flex: 0 0 258px;
  background: var(--rail);
  color: #eaf1ec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 26px;
  color: #fff;
}
.rail-brand:hover { text-decoration: none; }

.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 11px;
  background: var(--accent-soft);
  color: #10422f;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
}
.brand-text { font-size: 15px; line-height: 1.2; }
.brand-text strong { display: block; font-weight: 600; }
.brand-text span { display: block; font-weight: 400; color: #a9c4b5; }

.rail-nav { padding: 0 14px; display: flex; flex-direction: column; gap: 2px; }

.rail-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 11px;
  color: #cadbd0;
  font-size: 14.5px;
  font-weight: 500;
}
.rail-nav a:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail-nav a.active { background: var(--rail-active); color: #fff; font-weight: 600; }
.rail-nav .ico { width: 17px; text-align: center; opacity: .85; font-size: 14px; }

.rail-foot { margin-top: auto; padding: 14px; }
.rail-sep { height: 1px; background: rgba(255, 255, 255, .09); margin: 8px 14px 12px; }

.rail-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
}
.avatar {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #10422f;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
}
.rail-user-meta { min-width: 0; line-height: 1.25; }
.rail-user-meta strong { display: block; font-size: 13.5px; color: #fff; font-weight: 600; }
.rail-user-meta span { font-size: 11.5px; color: #9fbcab; text-transform: capitalize; }
.rail-out {
  margin-left: auto;
  color: #9fbcab;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 7px;
}
.rail-out:hover { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 38px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 27px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 28px 38px 60px; flex: 1; }
.content > * + * { margin-top: 20px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: #faf9f5; border-color: #d8d5cb; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--hero); border-color: var(--hero); color: #fff; }
.btn-primary:hover { background: #1b5642; border-color: #1b5642; color: #fff; }

.btn-mint { background: var(--accent-soft); border-color: var(--accent-soft); color: #10422f; }
.btn-mint:hover { background: #c6e3d1; border-color: #c6e3d1; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0, 0, 0, .04); border-color: transparent; }

.btn-danger { color: var(--bad-ink); border-color: #f0d3cf; background: #fdf5f4; }
.btn-danger:hover { background: #fbe9e6; border-color: #e7bcb6; }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.btn-icon {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.btn-icon:hover { background: #f1efe8; color: var(--bad-ink); }

/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card > h2 + p { margin-top: 4px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head .spacer { margin-left: auto; }
.card-note { background: #fbfaf6; color: var(--ink-2); font-size: 14px; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Hero band ---------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--hero);
  color: #fff;
  border-radius: var(--radius);
  padding: 34px 38px 38px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -70px; top: -90px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, .11), rgba(255, 255, 255, .02) 65%);
  pointer-events: none;
}
.hero .eyebrow { color: #9fc3ae; }
.hero h2 {
  font-size: 40px;
  line-height: 1.12;
  margin: 14px 0 12px;
  max-width: 17ch;
}
.hero p { margin: 0; color: #c3d8cb; max-width: 52ch; font-size: 14.5px; }
.hero-row { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-row > div:first-child { flex: 1; min-width: 280px; }

/* --- Stat cards --------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-num { display: block; font-family: var(--serif); font-size: 38px; line-height: 1.15; margin: 6px 0 8px; }
.stat-foot { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.dot-warn { background: #d79a16; }
.dot-idle { background: #b9b6ac; }

/* --- Tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #fcfbf8;
}
.table td { padding: 15px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbfaf6; }
.cell-name { font-weight: 600; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.cell-nowrap { white-space: nowrap; }
.cell-trunc { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ok-bg);
  color: var(--ok-ink);
  white-space: nowrap;
}
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill-neutral { background: #eeece5; color: var(--ink-2); }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 7px;
  background: #eeece5;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); }

.link-code {
  background: #f3f1ea;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 8px;
  color: var(--ink-2);
}
.btn-copy {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  margin-left: 7px;
}
.btn-copy:hover { background: #f6f4ee; }
.btn-copy.copied { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok-ink); }

/* --- Forms -------------------------------------------------------------- */

label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }

input[type="text"], input[type="password"], input[type="search"],
input[type="file"], select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfdfb;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 107, 69, .12);
  background: #fff;
}
select { cursor: pointer; }
textarea { resize: vertical; }

.hint { display: block; margin-top: 5px; font-size: 12px; font-weight: 400; color: var(--muted); }
.hint-warn { color: var(--warn-ink); }

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .grow { flex: 1; min-width: 190px; }

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.filters input, .filters select { margin-top: 0; width: auto; min-width: 165px; }
.filters input[type="search"] { flex: 1; min-width: 230px; }

.tracking-preview {
  background: #f7f6f1;
  border: 1px dashed #d9d6cb;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.tracking-preview code { display: block; white-space: nowrap; color: var(--ink-2); margin-top: 5px; }
.tracking-preview em { color: var(--accent-ink); font-style: normal; font-weight: 700; }

/* Field states driven by the live subdomain check. */
.field-ok   { border-color: #9dcdb2 !important; background: #fbfefc !important; }
.field-warn { border-color: #e2c176 !important; background: #fffdf7 !important; }
.field-bad  { border-color: #e3a49c !important; background: #fffbfa !important; }
.hint-ok  { color: var(--ok-ink); }
.hint-bad { color: var(--bad-ink); }

/* --- Combobox (searchable select) --------------------------------------- */

.cbx { position: relative; margin-top: 6px; }
.cbx-native { position: absolute; opacity: 0; pointer-events: none; height: 0; margin: 0; padding: 0; }

.cbx-input { margin-top: 0 !important; padding-right: 32px !important; }
.cbx-caret {
  position: absolute;
  right: 11px; top: 50%;
  transform: translateY(-60%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: auto;
  cursor: pointer;
}
.cbx.is-open .cbx-caret { transform: translateY(-40%) rotate(180deg); }

.cbx-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 5px);
  left: 0; right: 0;
  max-height: 288px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 34px rgba(20, 30, 25, .16);
  padding: 5px;
}
.cbx-group {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 10px 5px;
}
.cbx-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
}
.cbx-item.is-active { background: #f1efe8; }
.cbx-item.is-current { font-weight: 600; color: var(--accent-ink); }
.cbx-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-note { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cbx-empty { padding: 14px 12px; font-size: 13px; color: var(--muted); font-weight: 400; }

/* --- Toolbar (library filters) ------------------------------------------ */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.toolbar input[type="search"] { margin-top: 0; flex: 1; min-width: 230px; width: auto; }
.toolbar select { margin-top: 0; width: auto; min-width: 150px; font-size: 13.5px; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.segmented button {
  border: 0;
  background: var(--card);
  padding: 8px 13px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button:hover { background: #f7f5ef; color: var(--ink); }
.segmented button.on { background: var(--hero); color: #fff; }

.result-line { display: flex; align-items: center; gap: 12px; padding: 0 2px; }
.result-line .btn { margin-left: auto; }

/* --- Flashes ------------------------------------------------------------ */

.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg); color: var(--ok-ink); border-color: #c2e2ce; }
.flash-error { background: var(--bad-bg); color: var(--bad-ink); border-color: #f0cbc6; }

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

.empty {
  background: var(--card);
  border: 1px dashed #d9d6cb;
  border-radius: var(--radius);
  padding: 54px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 0 16px; }

/* --- Split (form + preview / progress) ---------------------------------- */

.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1080px) { .split { grid-template-columns: 1fr; } }

/* --- Pipeline steps ----------------------------------------------------- */

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; gap: 13px; padding: 11px 4px; align-items: flex-start; }
.step + .step { border-top: 1px solid var(--line-soft); }
.step-icon {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  margin-top: 1px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.step-body { min-width: 0; }
.step-title { display: block; font-size: 14px; font-weight: 600; }
.step-msg { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }

.step-running .step-icon { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.step-ok .step-icon { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok-ink); }
.step-ok .step-icon::after { content: "✓"; }
.step-fail .step-icon { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad-ink); }
.step-fail .step-icon::after { content: "!"; }
.step-fail .step-msg { color: var(--bad-ink); }

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

.result-ok, .result-fail { border-top: 1px solid var(--line-soft); margin-top: 16px; padding-top: 18px; }
.result-ok h3, .result-fail h3 { margin-bottom: 6px; }
.final-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #f7f6f1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0 14px;
}
.final-link code { flex: 1; min-width: 220px; word-break: break-all; color: var(--ink-2); }
.final-link-meta { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.final-link-meta .eyebrow { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.final-link.filter-final {
  background: var(--accent-soft);
  border-color: #b9dcc8;
}
.fail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* --- Traffic filtering option ------------------------------------------ */

.filter-option {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 4px 0 14px;
  background: #fbfaf7;
}
.filter-option-ready { border-color: #c5ddcf; background: #f3faf6; }
.filter-option-off { opacity: .92; }
.filter-option-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.filter-option-body { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

.switch-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin: 0;
}
.switch-label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c9c6bc;
  position: relative;
  transition: background .15s ease;
  margin-top: 2px;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
.switch-label input:checked + .switch-ui { background: var(--accent); }
.switch-label input:checked + .switch-ui::after { transform: translateX(18px); }
.switch-label input:disabled + .switch-ui { opacity: .45; }
.switch-compact { align-items: center; gap: 8px; }
.switch-compact .switch-ui { width: 36px; height: 20px; margin-top: 0; }
.switch-compact .switch-ui::after { width: 14px; height: 14px; }
.switch-compact input:checked + .switch-ui::after { transform: translateX(16px); }

.tag-warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.tf-cell { min-width: 220px; }
.tf-row { margin-bottom: 6px; }
.tf-state { font-size: 12px; color: var(--ink-2); }
.tf-link { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.tf-countries { margin-top: 8px; }
.tf-continue { display: block; margin-top: 8px; }
.tf-progress {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 20, 0.45);
  padding: 24px;
}
.tf-progress[hidden] { display: none !important; }
.tf-progress-card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}
.tf-progress-card h3 { margin: 0 0 6px; }
.tf-progress-steps {
  margin: 14px 0;
  padding-left: 1.2em;
  max-height: 240px;
  overflow: auto;
  font-size: 13px;
  color: var(--ink-2);
}
.tf-progress-steps li { margin: 4px 0; }
.tf-progress-steps li.ok { color: var(--accent-ink); }
.tf-progress-steps li.bad { color: var(--bad-ink); }
.tag-code {
  font-size: 11.5px;
  background: #eef3ef;
  color: var(--accent-ink);
  padding: 1px 6px;
  border-radius: 6px;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.tag-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 107, 69, .12);
}
.tag-chips { display: contents; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.tag-chip:hover { filter: brightness(0.97); }
#tag-draft {
  flex: 1 1 120px;
  border: 0 !important;
  box-shadow: none !important;
  padding: 4px 2px !important;
  min-width: 120px;
  background: transparent !important;
}
.user-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}
.user-tag {
  display: inline-block;
  background: #eef3ef;
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11.5px;
  text-decoration: none;
}
.user-tag:hover { text-decoration: none; background: var(--accent-soft); }

/* --- Preview frames ----------------------------------------------------- */

.preview-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fbfaf7;
}
.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: #f7f6f1;
}
.preview-dots { display: flex; gap: 5px; }
.preview-dots i { width: 9px; height: 9px; border-radius: 50%; background: #d8d5cb; display: block; }
.preview-url {
  flex: 1;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-frame { width: 100%; height: 460px; border: 0; display: block; background: #fff; }
.preview-empty { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Scaled-down thumbnail: renders the real lander, then shrinks it. The frame is
   sized to a phone viewport because these landers are built mobile-first — a
   desktop-width frame would letterbox them into a sliver. */
.thumb {
  height: 215px;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}
/* Inner box is the *scaled* size (430 x .7), so it centres in the card while the
   iframe inside keeps its real layout width. */
.thumb-inner {
  position: relative;
  width: 301px;
  height: 215px;
  margin: 0 auto;
  overflow: hidden;
}
.thumb-inner iframe {
  position: absolute;
  top: 0; left: 0;
  width: 430px;
  height: 1000px;
  border: 0;
  transform: scale(.7);
  transform-origin: 0 0;
  pointer-events: none;
}
.thumb-veil { position: absolute; inset: 0; cursor: pointer; }
.thumb-none {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
  background: #f7f6f1;
}

/* --- Library ------------------------------------------------------------ */

.product-group { margin-top: 22px; }
.product-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.product-head h2 { font-size: 22px; }
.product-head .count { font-size: 12.5px; color: var(--muted); }

.country-shelf { padding: 16px 0 4px; }
.country-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.country-head .flag { font-size: 17px; }
.country-head .code {
  font-size: 11px;
  letter-spacing: .06em;
  background: #eeece5;
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--muted);
}

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

.tpl-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: border-color .12s, transform .12s;
}
.tpl-card:hover { border-color: #cfcbbf; transform: translateY(-2px); }
.tpl-body { padding: 14px 16px; flex: 1; }
.tpl-body h3 { font-size: 16px; margin-bottom: 2px; }
.tpl-body h3 a { color: inherit; }
.tpl-product { font-size: 12.5px; color: var(--accent-ink); font-weight: 600; margin-bottom: 6px; }

.thumb { position: relative; }
.thumb-badge {
  position: absolute;
  top: 9px; right: 9px;
  background: rgba(18, 34, 27, .82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.tpl-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.tpl-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-soft);
  background: #fcfbf8;
}
.tpl-foot .spacer { margin-left: auto; }

/* --- Template detail ---------------------------------------------------- */

.detail-grid { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.file-list { list-style: none; margin: 0; padding: 6px; max-height: 470px; overflow-y: auto; }
.file-list li { margin: 0; }
.file-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-family: var(--mono);
}
.file-list a:hover { background: #f5f3ec; text-decoration: none; }
.file-list a.active { background: var(--accent-soft); color: #10422f; font-weight: 600; }
.file-list .size { margin-left: auto; font-size: 11px; color: var(--muted); font-family: var(--sans); }
.file-list span.locked { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; font-size: 13px; font-family: var(--mono); color: var(--muted); opacity: .7; }

.editor {
  width: 100%;
  min-height: 440px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
  background: #fbfaf7;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab {
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab-panel { padding: 20px 24px; }
.tab-panel[hidden] { display: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink-2); word-break: break-word; }

/* --- Activity ----------------------------------------------------------- */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex;
  gap: 13px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
}
.feed li:last-child { border-bottom: none; }
.feed-ico {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  background: #eeece5;
  color: var(--ink-2);
}
.feed-auth { background: #e4ecf7; color: #2a4f7c; }
.feed-campaign { background: var(--ok-bg); color: var(--ok-ink); }
.feed-template { background: var(--warn-bg); color: var(--warn-ink); }
.feed-other { background: #eeece5; color: var(--ink-2); }
.feed-body { min-width: 0; flex: 1; }
.feed-line { font-size: 14px; }
.feed-line strong { font-weight: 600; }
.feed-detail { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.feed-when { font-size: 12px; color: var(--muted); white-space: nowrap; margin-left: auto; padding-left: 12px; }

/* --- Checks (settings) -------------------------------------------------- */

.checks { list-style: none; margin: 0; padding: 0; }
.check { display: flex; gap: 13px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.check:last-child { border-bottom: none; }
.check-icon { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.check-ok .check-icon { background: var(--ok-bg); color: var(--ok-ink); }
.check-ok .check-icon::after { content: "✓"; }
.check-fail .check-icon { background: var(--bad-bg); color: var(--bad-ink); }
.check-fail .check-icon::after { content: "!"; }
.check strong { display: block; font-size: 14px; }
.check .muted { font-size: 13px; word-break: break-word; }

/* --- Login -------------------------------------------------------------- */

.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--rail); padding: 24px; }
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--card);
  border-radius: 20px;
  padding: 34px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
}
.login-mark {
  width: 44px; height: 44px;
  border-radius: 13px;
  background: var(--hero);
  color: var(--accent-soft);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}
.login-card h1 { font-size: 26px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }

/* --- Misc --------------------------------------------------------------- */

.section-head { display: flex; align-items: baseline; gap: 14px; }
.section-head .spacer { margin-left: auto; }

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

.error-page { text-align: center; padding: 90px 20px; }
.error-page h1 { font-size: 64px; color: var(--muted); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .rail-brand { padding: 14px 18px; }
  .rail-nav { flex-direction: row; flex-wrap: wrap; padding: 0 12px 12px; }
  .rail-foot { margin-left: auto; padding: 12px 18px; }
  .rail-sep { display: none; }
  .topbar, .content { padding-left: 20px; padding-right: 20px; }
}
