:root {
  --black: #0a0a0f;
  --dark: #0d0d14;
  --darker-blue: #0f1729;
  --blue-dim: #1a2744;
  --blue: #2563eb;
  --blue-bright: #3b82f6;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--black);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--blue);
  color: #fff;
  padding: .5rem 1rem;
  z-index: 100;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { top: 0; }

.bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 20% -20%, rgba(37,99,235,.12) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

header {
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(37,99,235,.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10,10,15,.9);
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.logo a { color: inherit; text-decoration: none; }
.logo a:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 3px; border-radius: 4px; }
.logo-name { color: var(--blue-bright); }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(15,23,41,.6), rgba(13,13,20,.8));
  border: 1px solid rgba(37,99,235,.15);
  border-radius: 12px;
}
.hero h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.hero p { color: var(--text-dim); font-size: .95rem; }

.offline-card {
  background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(13,13,20,.8));
  border: 1px solid rgba(37,99,235,.3);
  margin-bottom: 1.5rem;
}
.offline-card .card-header h2 { color: var(--blue-bright); font-weight: 600; }
.offline-card .card-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}
.offline-card .hint {
  flex: 1 1 320px;
  margin: 0;
  max-width: 720px;
}
.offline-card .btn-primary { flex: 0 0 auto; white-space: nowrap; }
.file-size {
  color: rgba(255,255,255,.75);
  font-size: .8rem;
  margin-left: .5rem;
  font-weight: 400;
}
@media (max-width: 600px) {
  .offline-card .card-body { flex-direction: column; align-items: stretch; }
  .offline-card .btn-primary { width: 100%; justify-content: center; }
}

.security-notice {
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.security-notice .icon { font-size: 1.5rem; flex-shrink: 0; }
.security-notice h2 { color: var(--green); font-size: .95rem; margin-bottom: .25rem; }
.security-notice p { font-size: .85rem; color: var(--text-dim); line-height: 1.5; }
.security-notice a { color: var(--blue-bright); }

.how-it-works {
  background: rgba(37,99,235,.1);
  border: 1px solid rgba(37,99,235,.2);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 2rem;
}
.how-it-works h3 {
  font-size: .9rem;
  color: var(--blue-bright);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.step { display: flex; align-items: flex-start; gap: .75rem; }
.step-num {
  width: 24px;
  height: 24px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.step-text { font-size: .85rem; color: var(--text-dim); line-height: 1.4; }
.step-text strong { color: var(--text); font-weight: 600; }

.card {
  background: linear-gradient(135deg, rgba(15,23,41,.6), rgba(13,13,20,.8));
  border: 1px solid rgba(37,99,235,.15);
  border-radius: 12px;
  margin-bottom: 1.5rem;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(37,99,235,.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.card-header h2 { font-size: 1rem; font-weight: 500; }
.card-body { padding: 1.25rem; }

.btn {
  padding: .65rem 1.25rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: transparent;
  color: var(--text);
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-bright); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }
.btn-ghost { color: var(--text-dim); border: 1px solid var(--text-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }
.btn-danger { color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.1); }
.btn-sm { padding: .4rem .75rem; font-size: .8rem; }

.hint { font-size: .85rem; color: var(--text-dim); margin-top: .75rem; }
.hint-inline { font-size: .85rem; color: var(--text-dim); margin-left: .5rem; }

.action-row { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }

fieldset { border: none; }
legend { font-size: .85rem; color: var(--text-dim); margin-bottom: .75rem; }

.radio-label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
}
.radio-label input,
.checkbox-label input { accent-color: var(--blue); cursor: pointer; }

.style-fieldset {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

textarea {
  width: 100%;
  padding: 1rem;
  background: var(--black);
  border: 1px solid rgba(37,99,235,.2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .9rem;
  outline: none;
  resize: vertical;
  min-height: 150px;
  max-width: 100%;
}
textarea::placeholder { color: var(--text-dim); opacity: .7; }
textarea:focus-visible { border-color: var(--blue); outline: 2px solid var(--blue-bright); outline-offset: 2px; }
textarea[readonly] { background: var(--darker-blue); }

input[type="text"],
input[type="file"],
select {
  padding: .6rem;
  background: var(--black);
  border: 1px solid rgba(37,99,235,.2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  max-width: 100%;
}
input[type="text"]:focus-visible,
select:focus-visible { border-color: var(--blue); outline: 2px solid var(--blue-bright); outline-offset: 2px; }
select { background: var(--darker-blue); font-family: inherit; }

.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(37,99,235,.2);
  padding-bottom: .5rem;
  list-style: none;
}
.tab {
  padding: .75rem 1.5rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
}
.tab:hover { color: var(--text); background: rgba(37,99,235,.1); }
.tab.active { color: var(--blue-bright); background: rgba(37,99,235,.15); border-color: rgba(37,99,235,.3); }
.tab:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.config-section { margin-top: 1.25rem; }
.config-section h3 { font-size: .9rem; color: var(--text-dim); margin-bottom: .75rem; font-weight: 500; }
.preset-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.preset.active { background: rgba(37,99,235,.25); border-color: var(--blue); color: var(--text); }

.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .6rem;
  background: rgba(0,0,0,.2);
  border-radius: 6px;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.toggle-item.emphasised { border-left: 3px solid var(--green); }
.toggle-item.disabled { opacity: .6; }
.toggle-item label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; flex: 1; }
.toggle-item input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); cursor: pointer; }

.badge {
  font-size: .7rem;
  padding: .2rem .5rem;
  border-radius: 4px;
  margin-left: .4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
}
.badge-count { background: var(--green); color: #fff; }
.badge-count.empty { background: var(--text-muted); }
.badge-type { background: var(--blue-dim); color: var(--blue-bright); }

.list-add-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.list-add-row input { flex: 1; min-width: 160px; font-family: var(--font-mono); }

.term-list { list-style: none; margin-top: .75rem; }
.term-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 0;
  border-bottom: 1px solid rgba(37,99,235,.1);
  font-size: .85rem;
  flex-wrap: wrap;
}
.term-list li:last-child { border-bottom: none; }
.term-list .view,
.term-list .edit { display: flex; align-items: center; gap: .5rem; flex: 1; flex-wrap: wrap; }
.term-list .term-text { font-family: var(--font-mono); color: var(--text); word-break: break-word; }
.term-list .edit { display: none; }
.term-list .editing .view { display: none; }
.term-list .editing .edit { display: flex; }
.term-list .match-count { margin-left: auto; color: var(--text-dim); font-size: .75rem; }

.persist-section {
  margin-top: 1.25rem;
  padding: 1rem;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
}
.persist-section p { margin-top: .5rem; margin-left: 1.5rem; }

.detected-list {
  list-style: none;
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0,0,0,.3);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.detected-list li {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid rgba(37,99,235,.1);
  font-size: .85rem;
  flex-wrap: wrap;
}
.detected-list li:last-child { border-bottom: none; }
.detected-type { font-size: .7rem; padding: .2rem .5rem; background: var(--blue-dim); border-radius: 4px; color: var(--blue-bright); min-width: 50px; text-align: center; }
.detected-original { font-family: var(--font-mono); color: var(--red); text-decoration: line-through; opacity: .8; word-break: break-word; }
.detected-arrow { color: var(--text-muted); }
.detected-masked { font-family: var(--font-mono); color: var(--green); word-break: break-word; }
.detected-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: .25rem; margin-left: auto; font-size: 1rem; line-height: 1; }
.detected-delete:hover { color: var(--red); }
.detected-delete:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }

.arrow-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.status-region {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-top: 1rem;
  border: 1px solid transparent;
}
.status-region.hidden { display: none; }
.status-region.processing { background: rgba(234,179,8,.1); color: var(--yellow); border-color: rgba(234,179,8,.3); }
.status-region.success { background: rgba(34,197,94,.1); color: var(--green); border-color: rgba(34,197,94,.3); }
.status-region.error { background: rgba(239,68,68,.1); color: var(--red); border-color: rgba(239,68,68,.3); }
.status-region.info { background: rgba(37,99,235,.1); color: var(--blue-bright); border-color: rgba(37,99,235,.3); }
.status-region.warning { background: rgba(249,115,22,.1); color: var(--orange); border-color: rgba(249,115,22,.3); }

.drop-zone {
  border: 2px dashed rgba(37,99,235,.3);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  transition: all .2s;
  cursor: pointer;
  background: transparent;
}
.drop-zone:hover,
.drop-zone.dragover,
.drop-zone:focus-visible {
  border-color: var(--blue-bright);
  background: rgba(37,99,235,.05);
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}
.drop-zone.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.drop-zone-icon { font-size: 3rem; margin-bottom: 1rem; }
.drop-zone-text { color: var(--text-dim); margin-bottom: .5rem; }
.drop-zone-hint { font-size: .8rem; color: var(--text-dim); }

.pdf-results { margin-top: 1rem; }
.pdf-stat { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid rgba(37,99,235,.1); font-size: .9rem; }
.pdf-stat:last-child { border-bottom: none; }
.pdf-stat-label { color: var(--text-dim); }
.pdf-stat-value { font-family: var(--font-mono); }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.scanned-warning { display: flex; gap: .75rem; align-items: flex-start; margin-top: 1rem; padding: 1rem; border: 1px solid var(--orange); border-radius: .5rem; background: rgba(249,115,22,.12); color: var(--text); outline: none; }
.scanned-warning:focus-visible { box-shadow: 0 0 0 2px var(--orange); }
.scanned-warning.critical { border-color: var(--red); background: rgba(239,68,68,.12); }
.scanned-warning.critical:focus-visible { box-shadow: 0 0 0 2px var(--red); }
.scanned-warning .icon { font-size: 1.25rem; flex-shrink: 0; }
.scanned-warning strong { color: var(--orange); display: block; }
.scanned-warning.critical strong { color: var(--red); }
.scanned-warning p { margin: .25rem 0 0; color: var(--text-dim); }
.scanned-warning .hint { margin-top: .5rem; color: var(--text-muted); }

footer { text-align: center; padding: 2rem; color: var(--text-dim); font-size: .8rem; border-top: 1px solid rgba(37,99,235,.1); margin-top: 2rem; }
footer p { margin-bottom: .25rem; }
footer a { color: var(--blue-bright); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer a:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; border-radius: 2px; }

.hidden { display: none !important; }

.more { color: var(--text-muted); }

@media (max-width: 600px) {
  header { padding: 1rem; }
  main { padding: 1rem; }
  .tabs { flex-wrap: wrap; }
  .tab { padding: .5rem 1rem; font-size: .9rem; }
  .card-body { padding: 1rem; }
  .config-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .drop-zone { padding: 2rem 1rem; }
}
