:root {
  --paper: #f2f0e9;
  --paper-strong: #faf9f5;
  --ink: #171917;
  --muted: #696b66;
  --line: #c9c8bf;
  --line-strong: #96978f;
  --signal: #d8ff3e;
  --signal-dark: #1b540e;
  --orange: #d45c32;
  --error: #a62e23;
  --shadow: 8px 8px 0 rgba(23, 25, 23, 0.11);
  --display: "DIN Condensed", "Avenir Next Condensed", "Noto Sans SC", sans-serif;
  --body: "Avenir Next", "Noto Sans SC", "PingFang SC", sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 25, 23, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 23, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: var(--body);
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button,
label[for="file-input"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
label[for="file-input"]:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(108deg, transparent 0 72%, rgba(212, 92, 50, 0.06) 72% 72.5%, transparent 72.5%);
}

.topbar {
  width: min(1440px, calc(100% - 48px));
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--signal);
  background: var(--ink);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-name b {
  color: var(--orange);
}

.local-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--signal-dark);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(27, 84, 14, 0.1);
}

main {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
}

.intro {
  min-height: 245px;
  padding: 48px 0 36px;
  position: relative;
}

.sequence {
  position: absolute;
  top: 55px;
  right: 0;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
}

.intro h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(48px, 8vw, 104px);
  font-stretch: condensed;
  font-weight: 800;
  line-height: 0.78;
  text-transform: uppercase;
}

.intro h1 span {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
}

.intro p {
  margin: 34px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
  min-height: 530px;
  background: var(--paper-strong);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
}

.input-panel,
.result-panel {
  min-width: 0;
  padding: 28px;
}

.input-panel {
  border-right: 1px solid var(--ink);
}

.panel-heading {
  min-height: 45px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.panel-index,
.connection-label,
.password-block label,
.metadata dt {
  color: var(--orange);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}

.panel-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 25px;
  line-height: 1;
}

.toolbar,
.password-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 var(--ink);
}

.button:active,
.icon-button:active {
  transform: translate(0, 0);
  box-shadow: none;
}

.button {
  min-height: 38px;
  gap: 8px;
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.button svg {
  width: 16px;
  height: 16px;
}

.button-secondary {
  color: var(--ink);
  background: transparent;
}

.button-primary {
  min-width: 136px;
  color: var(--ink);
  background: var(--signal);
}

.button-primary:disabled {
  cursor: wait;
  opacity: 0.55;
}

.icon-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.drop-prompt {
  min-height: 76px;
  margin-bottom: 12px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  background: rgba(216, 255, 62, 0.15);
  border: 1px dashed var(--line-strong);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.drop-prompt:hover {
  background: rgba(216, 255, 62, 0.32);
  border-color: var(--ink);
  transform: translateY(-1px);
}

.drop-prompt-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--signal);
  background: var(--ink);
}

.drop-prompt-icon svg {
  width: 19px;
  height: 19px;
}

.drop-prompt-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.drop-prompt-copy strong {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
}

.drop-prompt-copy small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.45;
}

.drop-prompt-type {
  padding: 5px 7px;
  color: var(--muted);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}

.drop-prompt:has(+ .editor-shell.dragging) {
  color: var(--ink);
  background: var(--signal);
  border-color: var(--ink);
  border-style: solid;
}

.editor-shell {
  min-height: 360px;
  position: relative;
  overflow: hidden;
  background: #20231f;
  border: 1px solid var(--ink);
}

.editor-shell::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 43px;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.editor-bar {
  height: 38px;
  padding: 0 12px 0 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #aaaea6;
  background: #171917;
  border-bottom: 1px solid #3c4039;
  font-family: var(--mono);
  font-size: 10px;
}

.input-state {
  color: #8e9289;
}

.input-state.valid {
  color: var(--signal);
}

.input-state.invalid {
  color: #ff8c6d;
}

#json-input {
  width: 100%;
  min-height: 321px;
  margin: 0;
  padding: 20px 18px 20px 62px;
  display: block;
  resize: vertical;
  color: #e8ebdf;
  caret-color: var(--signal);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
}

#json-input::placeholder {
  color: #696e66;
}

.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink);
  background: rgba(216, 255, 62, 0.94);
  border: 1px dashed var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  transition: opacity 150ms ease, transform 150ms ease;
}

.editor-shell.dragging .drop-overlay {
  opacity: 1;
  transform: scale(1);
}

.action-row {
  min-height: 62px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.parse-summary {
  padding-bottom: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
}

.parse-summary.error {
  color: var(--error);
}

.result-count {
  padding-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}

.result-empty {
  min-height: 390px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 28px;
  color: var(--muted);
}

.result-empty.hidden {
  display: none;
}

.result-empty p {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.vault-visual {
  width: 180px;
  height: 180px;
  position: relative;
  display: grid;
  place-items: center;
}

.vault-ring,
.vault-core {
  position: absolute;
  border-radius: 50%;
}

.vault-ring {
  border: 1px solid var(--line);
}

.ring-one {
  inset: 0;
  background: repeating-conic-gradient(from 10deg, transparent 0 14deg, rgba(23, 25, 23, 0.14) 14deg 15deg);
  animation: slow-spin 28s linear infinite;
}

.ring-two {
  inset: 31px;
  border-style: dashed;
  animation: slow-spin 20s linear infinite reverse;
}

.vault-core {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  color: var(--signal);
  background: var(--ink);
  border: 7px solid var(--paper-strong);
  box-shadow: 0 0 0 1px var(--ink);
}

.vault-core svg {
  width: 25px;
  height: 25px;
}

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

.results {
  display: grid;
  gap: 16px;
}

.result-item {
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--ink);
  animation: result-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.connection-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.connection-name {
  max-width: 320px;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-family: var(--display);
  font-size: 25px;
  line-height: 1.1;
}

.success-mark {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--signal-dark);
  background: var(--signal);
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.success-mark svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.metadata {
  margin: 22px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metadata > div {
  min-width: 0;
  padding: 13px 0;
}

.metadata > div + div {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.metadata dd {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-block label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.password-control {
  gap: 6px;
}

.password-output {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper-strong);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 14px;
}

.password-control .icon-button {
  flex-basis: 42px;
  width: 42px;
  height: 42px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 48px));
  padding: 13px 17px;
  color: var(--paper-strong);
  background: var(--ink);
  border-left: 4px solid var(--signal);
  box-shadow: 5px 5px 0 rgba(23, 25, 23, 0.2);
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: #ff7452;
}

footer {
  width: min(1440px, calc(100% - 48px));
  min-height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .intro {
    min-height: 220px;
  }

  .result-empty {
    min-height: 320px;
  }
}

@media (max-width: 600px) {
  .topbar,
  main,
  footer {
    width: calc(100% - 28px);
  }

  .topbar {
    height: 62px;
  }

  .brand-name {
    font-size: 11px;
  }

  .local-status {
    font-size: 9px;
  }

  .intro {
    min-height: 188px;
    padding: 42px 0 28px;
  }

  .intro h1 {
    font-size: 52px;
  }

  .intro p {
    margin-top: 27px;
    font-size: 9px;
  }

  .sequence {
    top: 27px;
  }

  .input-panel,
  .result-panel {
    padding: 19px;
  }

  .panel-heading {
    align-items: center;
  }

  .panel-heading h2 {
    font-size: 21px;
  }

  .button-secondary {
    width: 38px;
    padding: 0;
    font-size: 0;
  }

  .editor-shell {
    min-height: 330px;
  }

  .drop-prompt {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .drop-prompt-type {
    display: none;
  }

  #json-input {
    min-height: 291px;
    padding-left: 50px;
    font-size: 12px;
  }

  .editor-shell::after {
    left: 35px;
  }

  .editor-bar {
    padding-left: 43px;
  }

  .action-row {
    padding-top: 14px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .parse-summary {
    padding-bottom: 0;
  }

  .button-primary {
    width: 100%;
  }

  .metadata {
    grid-template-columns: 1fr;
  }

  .metadata > div + div {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .connection-name {
    font-size: 22px;
  }

  footer {
    min-height: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
