:root {
  --canvas: #f4f4ef;
  --paper: #fffef9;
  --ink: #18221d;
  --muted: #68736d;
  --line: #dfe3dc;
  --line-strong: #bdc6be;
  --green: #16784a;
  --green-dark: #0f5d39;
  --green-soft: #e4f2e9;
  --red: #b84539;
  --red-soft: #fff0ed;
  --amber: #946c1d;
  --amber-soft: #fff6dc;
  --blue-soft: #edf4f5;
  --shadow: 0 18px 50px rgba(30, 46, 37, .08);
  --radius: 22px;
  --radius-sm: 12px;
  --sans: "DM Sans", "Segoe UI", sans-serif;
  --mono: "DM Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(22, 120, 74, .09), transparent 28rem),
    var(--canvas);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 34px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 2rem; line-height: 1.08; letter-spacing: -.045em; }
.auth-card > p { color: var(--muted); }
.auth-form { display: grid; gap: 16px; margin-top: 8px; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: .7rem 1rem;
  color: white;
  background: var(--green);
  border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px 13px 13px 4px;
  background: var(--green);
  color: white;
  font-weight: 700;
  letter-spacing: -.04em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; line-height: 1.2; }
.brand small { color: var(--muted); font-size: .78rem; }
.topbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: .84rem;
}
.text-btn {
  border: 0;
  padding: 5px 0;
  background: transparent;
  color: var(--green);
  font-weight: 600;
}
.text-btn:hover { text-decoration: underline; }
.text-btn--danger { color: var(--red); }

.connection {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(380px, 1.2fr);
  align-items: center;
  gap: 24px;
  padding: 20px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(30, 46, 37, .045);
}
.connection__summary {
  display: flex;
  align-items: center;
  gap: 13px;
}
.connection__summary h2 { font-size: .92rem; font-weight: 700; }
.connection__summary p { color: var(--muted); font-size: .86rem; }
.status-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green-soft);
}
.dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #89938d;
}
.dot--ok { background: var(--green); }
.dot--warn { background: #c08a20; }
.dot--err { background: var(--red); }
.dot--pulse::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid currentColor;
  border-radius: 50%;
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse { to { transform: scale(2); opacity: 0; } }

.connect-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
}
.field { display: grid; gap: 6px; min-width: 0; }
.label {
  color: #435048;
  font-size: .78rem;
  font-weight: 700;
}
.label span { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .75rem; }
.input, .select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--ink);
  background: #fafbf7;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:hover, .select:hover { border-color: #849189; }
.input:focus, .select:focus {
  background: white;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 120, 74, .12);
}
.select {
  appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, #5f6a63 50%),
    linear-gradient(135deg, #5f6a63 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}
.search-select {
  position: relative;
  min-width: 0;
}
.search-select__trigger {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 15px;
  color: var(--muted);
  background: #fafbf7;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  text-align: left;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.search-select__trigger:hover { border-color: #849189; background: white; }
.search-select__trigger.has-value { color: var(--ink); font-weight: 600; }
.search-select.is-open .search-select__trigger {
  background: white;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 120, 74, .12);
}
.search-select__chevron {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s;
}
.search-select.is-open .search-select__chevron { transform: rotate(225deg) translate(-2px, -2px); }
.search-select__popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  overflow: hidden;
  padding: 7px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(30, 46, 37, .17);
  transform-origin: top center;
  animation: dropdown-in .16s ease-out;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-5px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.search-select__search {
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
}
.search-select__search input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px 0 36px;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 44%, var(--muted) 45%, var(--muted) 55%, transparent 56%) 17px 22px / 6px 6px no-repeat,
    radial-gradient(circle, transparent 52%, var(--muted) 54%, var(--muted) 65%, transparent 67%) 10px 9px / 13px 13px no-repeat,
    #f6f7f3;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
}
.search-select__search input:focus {
  background-color: white;
  border-color: var(--green);
}
.search-select__options {
  max-height: 270px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px 0 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.search-select__option {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
}
.search-select__option:hover,
.search-select__option:focus-visible { background: var(--green-soft); outline: none; }
.search-select__option[aria-selected="true"] { color: var(--green-dark); background: var(--green-soft); }
.search-select__option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .86rem;
  font-weight: 600;
}
.search-select__option small { color: var(--muted); font-size: .7rem; }
.search-select__empty { padding: 24px 12px; color: var(--muted); font-size: .8rem; text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  transition: transform .18s, background .18s, box-shadow .18s;
}
.btn--primary {
  color: white;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(22, 120, 74, .16);
}
.btn--secondary {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: #bdd9c8;
}
.btn--secondary:hover { background: #d5eadc; }
.btn--primary:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn--primary:active { transform: translateY(1px); }
.btn:disabled {
  color: #89928d;
  background: #e7e9e5;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn--ghost {
  min-height: 38px;
  padding: 0 12px;
  color: var(--green-dark);
  background: white;
  border-color: var(--line-strong);
}
.btn--wide { width: 100%; }

.qr-stage {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 34px;
  align-items: center;
  padding: 24px;
  background: var(--green-soft);
  border-radius: 14px;
}
.qr-stage__visual {
  display: grid;
  place-items: center;
  min-height: 280px;
  background: white;
  border-radius: 12px;
}
.qr-stage__visual img { display: block; width: 260px; height: 260px; }
.qr-stage__placeholder { color: var(--muted); font-family: var(--mono); font-size: .8rem; }
.qr-stage__text { display: grid; gap: 12px; }
.qr-stage__text h3 { font-size: 1.65rem; letter-spacing: -.035em; }
.steps { margin: 0; padding-left: 1.3rem; color: #3f4d45; }
.steps li { padding: 4px 0; }
.pair-code {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 500 1.6rem var(--mono);
  letter-spacing: .12em;
}

.intro {
  max-width: 690px;
  padding: 64px 6px 28px;
}
.eyebrow {
  color: var(--green);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.intro h1 {
  margin-top: 7px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -.055em;
  text-wrap: balance;
}
.intro p {
  max-width: 58ch;
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.05rem;
  text-wrap: pretty;
}

.tool-grid {
  display: grid;
  grid-template-columns: .88fr 1.12fr;
  gap: 20px;
  align-items: start;
  min-width: 0;
}
.tool {
  position: relative;
  display: grid;
  gap: 24px;
  overflow: visible;
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.tool__number {
  position: absolute;
  right: 18px;
  top: 8px;
  color: rgba(24, 34, 29, .045);
  font: 700 5.5rem/1 var(--mono);
  pointer-events: none;
}
.tool__head {
  position: relative;
  display: flex;
  gap: 15px;
  align-items: flex-start;
}
.tool__icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 1.3rem;
  font-weight: 700;
}
.tool__head h2 { font-size: 1.28rem; letter-spacing: -.025em; }
.tool__head p { margin-top: 3px; color: var(--muted); font-size: .9rem; }
.tool__form { display: grid; gap: 17px; }
.tool__footnote { color: var(--muted); font-size: .76rem; text-align: center; }

.file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 13px;
  color: var(--muted);
  background: #fafbf7;
  border: 1px dashed var(--line-strong);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.file:hover { border-color: var(--green); background: var(--green-soft); }
.file--has-file { color: var(--ink); border-style: solid; border-color: var(--green); background: var(--green-soft); }
.file__icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  color: white;
  background: var(--green);
  border-radius: 10px;
  font-size: 1.35rem;
}
.file__copy { min-width: 0; }
.file__copy strong, .file__copy small { display: block; }
.file__copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.file__copy small { margin-top: 2px; font-size: .72rem; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.advanced {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.advanced summary {
  padding: 11px 2px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.advanced__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 4px 2px 14px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #46534c;
  font-size: .82rem;
}
.checkbox input { width: 17px; height: 17px; accent-color: var(--green); }
.action-status { min-height: 18px; color: var(--muted); font-size: .78rem; text-align: center; }

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: .82rem;
  overflow-wrap: anywhere;
}
.banner--err { grid-column: 1 / -1; color: #8d3028; background: var(--red-soft); border: 1px solid #f0c1bb; }
.banner--warn { color: #71500e; background: var(--amber-soft); border: 1px solid #ead59e; }
.banner--info { color: #345359; background: var(--blue-soft); border: 1px solid #cadaDC; }

.result { display: grid; gap: 17px; padding-top: 20px; border-top: 1px solid var(--line); }
.counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { padding: 12px; background: #f6f7f3; border-radius: 10px; }
.stat__n { font: 700 1.35rem/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.stat__l { margin-top: 3px; color: var(--muted); font-size: .69rem; }
.stat--present .stat__n { color: var(--green); }
.stat--missing .stat__n { color: var(--red); }
.stat--invalid .stat__n, .stat--dup .stat__n { color: var(--amber); }
.download-label { margin-bottom: 8px; }
.downloads { display: flex; flex-wrap: wrap; gap: 7px; }

.footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 46px;
  padding-top: 22px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .72rem;
}
.footer span::before { content: "✓"; margin-right: 6px; color: var(--green); }
.is-hidden { display: none !important; }

:focus-visible { outline: 3px solid rgba(22, 120, 74, .35); outline-offset: 2px; }
::selection { color: white; background: var(--green); }

@media (max-width: 840px) {
  .connection { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool--export { order: 1; }
  .tool--compare { order: 2; }
}
@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 16px; }
  .topbar__meta #session-name { display: none; }
  .connection { padding: 17px; }
  .connect-form { grid-template-columns: 1fr; }
  .qr-stage { grid-template-columns: 1fr; padding: 15px; }
  .qr-stage__visual { min-height: 240px; }
  .qr-stage__visual img { width: 225px; height: 225px; }
  .intro { padding: 48px 3px 22px; }
  .tool { padding: 21px; border-radius: 17px; }
  .tool__number { font-size: 4.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
