:root {
  --bg:            oklch(0.10  0.010 200);
  --surface:       oklch(0.135 0.010 200);
  --surface-2:     oklch(0.165 0.010 200);
  --surface-3:     oklch(0.20  0.009 200);
  --border:        oklch(0.28  0.008 200 / 0.65);
  --border-h:      oklch(0.36  0.008 200 / 0.85);
  --ink:           oklch(0.93  0.005  75);
  --muted:         oklch(0.56  0.008 200);
  --accent:        oklch(0.72  0.14  162);
  --accent-dim:    oklch(0.72  0.14  162 / 0.10);
  --accent-strong: oklch(0.62  0.14  162);
  --danger:        oklch(0.64  0.19   25);
  --danger-dim:    oklch(0.64  0.19   25 / 0.12);
  --ok:            oklch(0.72  0.14  162);
  --nav-bg:        oklch(0.135 0.010 200 / 0.88);
  --mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 60px;
  --radius: 8px;
  --radius-sm: 5px;
  --radius-xs: 4px;
  --shadow: 0 1px 3px oklch(0 0 0 / 0.50), 0 4px 16px oklch(0 0 0 / 0.40);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:            oklch(0.975 0.007  75);
    --surface:       oklch(1.0   0       0);
    --surface-2:     oklch(0.955 0.007  75);
    --surface-3:     oklch(0.930 0.008  75);
    --border:        oklch(0.875 0.006  75);
    --border-h:      oklch(0.820 0.008  75);
    --ink:           oklch(0.14  0.012 250);
    --muted:         oklch(0.52  0.010 250);
    --accent:        oklch(0.38  0.10  162);
    --accent-dim:    oklch(0.38  0.10  162 / 0.09);
    --accent-strong: oklch(0.30  0.10  162);
    --danger:        oklch(0.48  0.20   25);
    --danger-dim:    oklch(0.48  0.20   25 / 0.10);
    --ok:            oklch(0.38  0.10  162);
    --nav-bg:        oklch(0.995 0.003  75 / 0.92);
    --shadow: 0 1px 3px oklch(0 0 0 / 0.08), 0 4px 12px oklch(0 0 0 / 0.06);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

::selection { background: var(--accent); color: var(--bg); }

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-h); border-radius: 2px; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.nav-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.97rem;
  letter-spacing: -0.01em;
}

.brand-icon {
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Lang Picker ── */
.lang-picker {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 120ms, color 120ms;
}

.lang-btn:hover {
  border-color: var(--border-h);
  color: var(--ink);
}

.lang-chevron {
  transition: transform 150ms ease;
}

.lang-btn[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border-h);
  border-radius: var(--radius);
  padding: 5px;
  min-width: 170px;
  box-shadow: var(--shadow);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lang-dropdown.hidden {
  display: none;
}

.lang-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.lang-opt:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.lang-opt.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Main ── */
.main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Hero ── */
.hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  padding: 3px 10px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent);
}

.hero-title {
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--ink);
}

.hero-desc {
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.65;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.feature-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.feature-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
}

.feature-item strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.feature-item span {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Workspace ── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

.sidebar {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: calc(var(--nav-h) + 16px);
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-info {
  gap: 14px;
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
}

.warn-text {
  color: var(--ink);
}

/* ── Fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

textarea,
input[type="text"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  transition: border-color 120ms, box-shadow 120ms;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
}

#decryptedOutput {
  min-height: 120px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── TTL chips ── */
.ttl-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ttl-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.84rem;
  transition: border-color 120ms;
  user-select: none;
}

.ttl-chip:hover {
  border-color: var(--border-h);
}

.ttl-chip input {
  margin: 0;
  accent-color: var(--accent);
}

.ttl-chip input:checked + span {
  color: var(--accent);
  font-weight: 700;
}

/* ── Privacy notice ── */
.pp-notice {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.pp-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 120ms;
}

.pp-link:hover {
  text-decoration-color: var(--accent);
}

/* ── Buttons ── */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 16px;
  transition: opacity 120ms, filter 120ms, transform 100ms;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--border-h);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-dim);
  border: 1px solid rgba(240, 107, 107, 0.22);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  border-color: var(--border-h);
  color: var(--ink);
}

/* ── URL row ── */
.url-row {
  display: flex;
  gap: 6px;
}

.url-input {
  font-family: var(--mono);
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
}

/* ── Status ── */
.status {
  min-height: 20px;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--muted);
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--danger);
}

/* ── Result block ── */
.result-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Info box ── */
.info-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Disclosure ── */
.disclosure {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.disclosure-sum {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.disclosure-sum::-webkit-details-marker {
  display: none;
}

.disclosure-sum::before {
  content: "▸";
  font-size: 0.65rem;
  transition: transform 150ms;
}

details[open] .disclosure-sum::before {
  transform: rotate(90deg);
}

.disclosure-list {
  margin-top: 10px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.disclosure-list li {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── How it works ── */
.how-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
  counter-reset: how;
}

.how-list li {
  list-style: none;
  counter-increment: how;
  position: relative;
  padding-left: 4px;
}

.trust-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trust-box p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  transition: border-color 120ms, color 120ms;
  align-self: flex-start;
}

.dl-btn:hover {
  border-color: var(--border-h);
  color: var(--ink);
}

/* ── QR block ── */
.qr-block {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

.qr-block svg {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-sm);
  display: block;
}

/* ── API card ── */
.api-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-h);
  flex-shrink: 0;
}

.api-dot-ok  { background: var(--ok); }
.api-dot-err { background: var(--danger); }

.api-current-url {
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
  min-height: 1.2em;
}

.api-details {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 2px;
}

.api-details-sum {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.api-details-sum::-webkit-details-marker { display: none; }

.api-details-sum::before {
  content: "▸";
  font-size: 0.65rem;
  transition: transform 150ms;
}

details[open] .api-details-sum::before { transform: rotate(90deg); }

.api-input-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.api-url-input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.mt-10 { margin-top: 10px; }

/* ── Mono ── */
.mono {
  font-family: var(--mono);
  font-size: 0.85em;
}

/* ── Hidden ── */
.hidden {
  display: none !important;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 20px;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border-h);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-head h2 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms, background 120ms;
}

.modal-close:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}

.modal-body h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 6px;
}

.modal-body p {
  line-height: 1.65;
}

.modal-body ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

.pp-date {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
}

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

  .sidebar {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }

  .feature-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .main {
    padding: 20px 14px 48px;
  }

  .card {
    padding: 16px;
  }

  .actions {
    flex-direction: column;
  }

  .actions button {
    width: 100%;
  }

  .feature-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .feature-item {
    padding: 10px 12px;
  }
}

@media (max-width: 420px) {
  .feature-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
