/* ── Tokens ── */
:root {
  --bg: #0b0e14;
  --bg2: #111620;
  --surface: #161b26;
  --border: #262d3a;
  --fg: #e6edf3;
  --fg2: #8b949e;
  --accent: #f7931a;
  --accent-dim: rgba(247, 147, 26, .15);
  --green: #3fb950;
  --red: #f85149;
  --radius: 12px;
  --max-w: 640px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -.02em;
}
.logo-mark { color: var(--accent); margin-right: 2px; }
.accent { color: var(--accent); }

/* ── Main layout ── */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Cards / steps ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-bottom: 24px;
}
.step { display: none; }
.step.visible { display: block; }

/* ── Step 1: Email ── */
h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}
.subtitle { color: var(--fg2); margin-bottom: 16px; }
.privacy-pill {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--green);
  font-size: .85rem;
  margin-bottom: 24px;
}
form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: .9rem; font-weight: 600; color: var(--fg2); }
input[type="email"],
input[type="text"],
input[type="search"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
input:focus { border-color: var(--accent); }
.fine-print { margin-top: 16px; font-size: .8rem; color: var(--fg2); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg2); border-color: var(--fg2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn.primary:hover { background: #e8851a; }
.btn.ghost { background: transparent; }
.btn.small { font-size: .8rem; padding: 6px 12px; }

/* ── Step 2: Converter ── */
.converter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.session-info { font-size: .85rem; color: var(--fg2); }
.progress {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
}

.word-input-area { position: relative; margin-bottom: 20px; }
.word-input-area label { display: block; margin-bottom: 6px; }

/* ── Autocomplete suggestions ── */
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  list-style: none;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}
.suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95rem;
  display: flex;
  justify-content: space-between;
}
.suggestions li:hover, .suggestions li.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.suggestions li .idx { color: var(--fg2); font-size: .8rem; }

.error {
  color: var(--red);
  font-size: .85rem;
  margin-top: 6px;
}

.nav-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.nav-buttons .small { margin-left: auto; }

/* ── History ── */
.history h3 {
  font-size: .9rem;
  color: var(--fg2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
#historyList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding-left: 0;
  list-style: none;
}
#historyList li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95rem;
  white-space: nowrap;
}
#historyList li .hpos {
  color: var(--fg2);
  font-size: .8rem;
  min-width: 2ch;
  text-align: right;
}
#historyList li .hw {
  flex: 1;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
}
#historyList li .hn { color: var(--accent); font-weight: 700; }
#historyList li .blurred {
  filter: blur(6px);
  user-select: none;
}
#historyList li .toggle-blur {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg2);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
#historyList li .toggle-blur:hover {
  color: var(--accent);
  border-color: var(--accent);
}
#historyList li .toggle-blur svg { width: 18px; height: 18px; display: block; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  position: relative;
}
.modal-label {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg2);
  margin-bottom: 8px;
}
.modal-number {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 8px;
}
.modal-word {
  font-size: 1.1rem;
  color: var(--fg2);
  margin-bottom: 4px;
}
.modal-binary {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  color: var(--fg2);
  margin-bottom: 24px;
}
.modal-actions { display: flex; gap: 8px; justify-content: center; }
.copy-feedback {
  color: var(--green);
  font-size: .85rem;
  margin-top: 12px;
}

/* ── About / Privacy ── */
.about p { margin-bottom: 12px; color: var(--fg2); }
.about p strong { color: var(--fg); }
.warning {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-dim);
  font-size: .9rem;
  color: var(--fg);
}

/* ── Footer ── */
.footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 20px 16px;
  font-size: .8rem;
  color: var(--fg2);
  border-top: 1px solid var(--border);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .card { padding: 24px 16px; }
  .modal { padding: 32px 20px; }
  .modal-number { font-size: 2.5rem; }
  #historyList { grid-template-columns: 1fr; }
}

.save-status { margin-left: 6px; font-size: .8rem; color: var(--fg2); }
.save-status.pending { color: var(--accent); }
