:root {
  color-scheme: light;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f4f6f8;

  --ink: #14181f;
  --ink-2: #3d4757;
  --ink-3: #6b7686;

  --line: #e3e7ec;
  --line-2: #d3d9e0;

  --accent: #1f6feb;
  --accent-soft: #eef4ff;
  --accent-line: #b9d1fb;

  --ok: #0f7a3d;
  --ok-soft: #eaf7ef;
  --ok-line: #b4e0c6;

  --warn: #9a6100;
  --warn-soft: #fdf5e6;
  --warn-line: #f0dcae;

  --bad: #b3261e;
  --bad-soft: #fdeeed;
  --bad-line: #f3c4c0;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 2px 8px rgba(16, 24, 40, .07);
  --sh-3: 0 10px 30px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-3);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
}

::placeholder { color: #9aa4b2; }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- layout ---------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1440px;
  margin: 0 auto;
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  flex: none;
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text h1 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.brand-text p { margin: 0; font-size: 12px; color: var(--ink-3); }

.privacy {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: 12px; font-weight: 600;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
  padding: .25rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.privacy svg { width: 13px; height: 13px; }

.main { max-width: 1440px; width: 100%; margin: 0 auto; padding: 1.25rem; flex: 1; }

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

.steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.step {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: 12.5px; font-weight: 550;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .75rem .3rem .35rem;
}
.step .n {
  width: 20px; height: 20px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: var(--surface-3);
  color: var(--ink-3);
}
.step.active { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.step.active .n { background: var(--accent); color: #fff; }
.step.done { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.step.done .n { background: var(--ok); color: #fff; }

/* ---------- dropzone ---------- */

.drop {
  position: relative;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 1.6rem 1.25rem;
  text-align: center;
  transition: border-color .15s, background .15s, transform .15s;
  box-shadow: var(--sh-1);
}
.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}
.drop.compact { padding: .9rem 1rem; text-align: left; display: flex; align-items: center; gap: .9rem; }
.drop.compact .drop-icon { margin: 0; width: 34px; height: 34px; }
.drop.compact .drop-copy { flex: 1; min-width: 0; }
.drop.compact h2 { font-size: 13.5px; }
.drop.compact .hint { margin: .1rem 0 0; }
.drop.compact .drop-actions { margin: 0; }

.drop-icon {
  width: 42px; height: 42px;
  margin: 0 auto .6rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.drop-icon svg { width: 21px; height: 21px; }
.drop h2 { margin: 0 0 .15rem; font-size: 16px; font-weight: 650; }
.hint { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.drop-actions { margin-top: .8rem; display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

.add-menu-wrap { position: relative; }
#addBtn .caret { margin-left: .1rem; }

.add-menu {
  position: absolute;
  top: calc(100% + .35rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 310px;
  max-width: min(310px, calc(100vw - 2rem));
  background: #ffffff;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--sh-2, 0 8px 24px rgba(16, 24, 40, .14));
  padding: .25rem;
  text-align: left;
}

.add-menu-item {
  display: flex; align-items: flex-start; gap: .55rem;
  width: 100%;
  border: 0;
  background: #ffffff;
  border-radius: var(--r-sm);
  padding: .5rem .55rem;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.add-menu-item:hover { background: var(--surface-2); }
.add-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.add-menu-item svg { width: 15px; height: 15px; flex: none; margin-top: .1rem; color: var(--ink-3); }
.add-menu-text { display: block; min-width: 0; }
.add-menu-text strong { display: block; font-size: 13px; font-weight: 600; }
.add-menu-text small { display: block; margin-top: .1rem; font-size: 11.5px; line-height: 1.35; color: var(--ink-3); }
.add-menu-text code { font-size: 11px; }

.foot .build { margin-left: .4rem; opacity: .7; }

.alert-action { display: inline-flex; margin-left: .5rem; vertical-align: baseline; background: #ffffff; }

.chips { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; margin-top: .7rem; }
.chip {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-3);
  border-radius: 5px;
  padding: .12rem .4rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: .42rem .8rem;
  font-size: 13px; font-weight: 570;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #bcc4cf; color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; flex: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--sh-1);
}
.btn.primary:hover:not(:disabled) { background: #1a5fd0; border-color: #1a5fd0; color: #fff; }

.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }

.btn.sm { padding: .25rem .55rem; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- alerts ---------- */

.alert {
  display: flex; gap: .6rem;
  border-radius: var(--r);
  padding: .65rem .85rem;
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
}
.alert svg { width: 15px; height: 15px; flex: none; margin-top: .12rem; }
.alert.info { background: var(--accent-soft); border-color: var(--accent-line); color: #123f8a; }
.alert.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.alert strong { font-weight: 650; }

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}
@media (max-width: 1180px) { .workspace { grid-template-columns: 270px minmax(0, 1fr); } .col-right { grid-column: 1 / -1; } }
@media (max-width: 860px) { .workspace { grid-template-columns: 1fr; } .col-right { grid-column: auto; } }

.col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.card-head h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .01em; }
.card-head .count {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  color: var(--ink-3);
  background: var(--surface-3);
  border-radius: 999px;
  padding: .1rem .45rem;
}
.card-body { padding: .9rem; }
.card-body.flush { padding: 0; }

/* ---------- lists ---------- */

.list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.list li + li { border-top: 1px solid var(--line); }
.list button {
  width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: .6rem .9rem;
  cursor: pointer;
  display: flex; gap: .55rem; align-items: flex-start;
  transition: background .12s;
}
.list button:hover { background: var(--surface-2); }
.list button.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.list button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.list .ico { color: var(--ink-3); flex: none; margin-top: .15rem; }
.list .ico svg { width: 15px; height: 15px; display: block; }
.list button.active .ico { color: var(--accent); }
.list .txt { min-width: 0; flex: 1; }
.list .t1 {
  font-size: 13px; font-weight: 570;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list .t2 {
  font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: .05rem;
}

.empty { padding: 1.4rem .9rem; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.empty svg { width: 24px; height: 24px; opacity: .4; display: block; margin: 0 auto .4rem; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: 11.5px; font-weight: 650;
  border-radius: 999px;
  padding: .13rem .5rem;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink-3);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.pill.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.pill.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.pill.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.pill svg { width: 11px; height: 11px; }
.pill-row { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- form ---------- */

.field-group + .field-group { margin-top: .8rem; }
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .3rem;
}
label.lbl {
  display: flex; align-items: center; gap: .35rem;
  font-size: 11.5px; font-weight: 650;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .3rem;
}
.field-label-row label.lbl { margin-bottom: 0; }
.copy-field {
  border: 0;
  background: #ffffff;
  color: var(--accent);
  padding: .1rem .2rem;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
}
.copy-field:hover { text-decoration: underline; }
.copy-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.inp, textarea.inp {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: .45rem .6rem;
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.inp:focus, textarea.inp:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .13);
}
textarea.inp { resize: vertical; min-height: 74px; }

.search { display: flex; gap: .4rem; }
.search .inp { flex: 1; }

/* ---------- result readout ---------- */

.readout {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin-top: .8rem;
}
.readout-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .7rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 650; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.readout-body { padding: .6rem .7rem; }
.sample {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .5rem .6rem;
  max-height: 130px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.sample.is-empty { color: var(--ink-3); font-style: italic; }
.sample.is-long { border-color: var(--bad-line); background: var(--bad-soft); }
.list li.blocked { padding: .45rem .6rem; font-size: 12.5px; color: var(--warn); line-height: 1.35; }

.note { font-size: 12.5px; color: var(--ink-2); margin: .5rem 0 0; }
.note.risk { color: var(--bad); }

/* ---------- alternatives ---------- */

.alts { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; max-height: 250px; overflow-y: auto; }
.alts button {
  width: 100%; text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: .45rem .55rem;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.alts button:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.alts button.current { border-color: var(--accent); background: var(--accent-soft); }
.alts .alt-top { display: flex; align-items: center; gap: .35rem; margin-bottom: .2rem; }
.alts .alt-path { word-break: break-all; color: var(--ink-2); }

/* ---------- saved rules ---------- */

.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rules li { padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.rules .r-top { display: flex; align-items: center; gap: .4rem; }
.rules .r-key { font-size: 13px; font-weight: 650; word-break: break-all; }
.rules .r-url { font-size: 11.5px; color: var(--ink-3); margin-top: .1rem; word-break: break-all; }
.rules .r-path { font-size: 11.5px; color: var(--ink-2); margin-top: .25rem; word-break: break-all; background: var(--surface-2); border-radius: 4px; padding: .25rem .35rem; }
.rules .copy-rule { margin-left: auto; }
.rules .rm { margin-left: auto; }
.rules .copy-rule + .rm { margin-left: 0; }

/* ---------- misc ---------- */

.statusbar {
  display: flex; align-items: center; gap: .5rem;
  min-height: 1.5rem;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: .7rem;
}
.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid var(--accent-line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stack { display: flex; gap: .4rem; flex-wrap: wrap; }
.hidden { display: none !important; }

pre.block {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .6rem;
  max-height: 210px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
}

.tests { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; max-height: 260px; overflow-y: auto; }
.tests li { font-size: 12.5px; padding: .25rem .5rem; border-radius: 5px; display: flex; gap: .4rem; }
.tests li.pass { color: var(--ok); background: var(--ok-soft); }
.tests li.fail { color: var(--bad); background: var(--bad-soft); }

.foot {
  max-width: 1440px; margin: 0 auto; width: 100%;
  padding: 1rem 1.25rem 2rem;
  color: var(--ink-3);
  font-size: 12px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfd6de; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #b9c2cd; }
::-webkit-scrollbar-track { background: transparent; }
