/* Self-hosted Latin subsets (SIL OFL, see /fonts/OFL-*.txt). Plex Sans and Space Grotesk are variable. */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-600.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans.woff2") format("woff2");
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/fonts/space-grotesk.woff2") format("woff2");
}

:root {
  --arpp-ink: #09090b;
  --arpp-paper: #f2f3f7;
  --arpp-blue: #60a5fa;
  --arpp-link-on-paper: #1d4ed8;

  --bg: var(--arpp-paper);
  --surface: #ffffff;
  --border: rgba(9, 9, 11, 0.12);
  --border-strong: rgba(9, 9, 11, 0.28);
  --text: var(--arpp-ink);
  --muted: #5d616d;
  --accent: var(--arpp-link-on-paper);
  --digit: #6b6f7b;
  --rail-bg: var(--arpp-ink);
  --rail-text: var(--arpp-paper);
  --rail-muted: #8d919e;
  --rail-line: rgba(242, 243, 247, 0.12);
  --radius: 14px;
  --font-ui: "IBM Plex Sans", Segoe UI, Helvetica Neue, Arial, sans-serif;
  --font-display: "Space Grotesk", Segoe UI, Helvetica Neue, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --rail-w: 7.5rem;
  --drawer-w: 22rem;
  --puller-h: 3.6rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #15151b;
    --border: rgba(242, 243, 247, 0.1);
    --border-strong: rgba(242, 243, 247, 0.28);
    --text: var(--arpp-paper);
    --muted: #a2a6b3;
    --accent: var(--arpp-blue);
    --digit: #8d919e;
    --rail-bg: #050506;
  }
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

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

button,
a,
.dial {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: center;
}

:focus-visible {
  outline: 2px solid var(--arpp-blue);
  outline-offset: 2px;
}

.tab:focus-visible,
.puller:focus-visible,
.toggle:focus-visible,
.dial-step:focus-visible {
  outline-offset: -2px;
  border-radius: 8px;
}

/* Shell */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--drawer-w);
  height: 100vh;
  height: 100dvh;
}

.app.drawer-hidden {
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 0;
}

/* Rail */

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 1.1rem 0.6rem;
  background: var(--rail-bg);
  color: var(--rail-text);
  overflow-y: auto;
  scrollbar-width: none;
}

.rail-mark img {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
}

.dials {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
}

.dial {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  justify-items: center;
  padding: 0.2rem 0;
  border: 1px solid var(--rail-line);
  border-radius: 12px;
  cursor: ns-resize;
  user-select: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.dial:hover,
.dial:focus-visible {
  border-color: var(--arpp-blue);
  background: rgba(96, 165, 250, 0.08);
  outline: none;
}

.dial-step {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rail-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.3;
  cursor: pointer;
}

.dial-step:hover {
  color: var(--arpp-blue);
}

.dial-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.05;
}

.dial-name,
.rail-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.3;
  color: var(--rail-muted);
}

.dial.bump .dial-value {
  animation: bump 180ms ease;
}

@keyframes bump {
  50% { transform: scale(1.18); color: var(--arpp-blue); }
}

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
  justify-items: stretch;
}

.toggles .rail-label {
  grid-column: 1 / -1;
  text-align: center;
  margin-bottom: 0.15rem;
}

.toggle {
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--rail-line);
  border-radius: 8px;
  background: none;
  color: var(--rail-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.toggle:hover {
  border-color: var(--arpp-blue);
  color: var(--rail-text);
}

.toggle[aria-pressed="true"] {
  background: var(--arpp-blue);
  border-color: var(--arpp-blue);
  color: var(--arpp-ink);
  font-weight: 600;
}

/* Stage */

.stage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  padding: 1.4rem clamp(1.2rem, 4vw, 3.5rem);
}

.stage-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.stage-crumb {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.stage-crumb a {
  color: var(--text);
}

.stage-crumb span {
  margin: 0 0.4rem;
  color: var(--muted);
  font-weight: 500;
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.stage-format {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.reset {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.reset:hover {
  border-color: var(--text);
  color: var(--text);
}

.feature {
  align-self: center;
  display: grid;
  gap: 1.8rem;
  justify-items: start;
  min-width: 0;
}

.feature-pw {
  margin: 0;
  max-width: 100%;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(1.8rem, 5.4vw, 4.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  cursor: copy;
}

.feature-pw.fresh .tok {
  animation: rise 260ms ease both;
}

.feature-pw.fresh .tok:nth-child(2) { animation-delay: 30ms; }
.feature-pw.fresh .tok:nth-child(3) { animation-delay: 60ms; }
.feature-pw.fresh .tok:nth-child(4) { animation-delay: 90ms; }
.feature-pw.fresh .tok:nth-child(5) { animation-delay: 120ms; }
.feature-pw.fresh .tok:nth-child(n + 6) { animation-delay: 150ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(0.25em); }
  to { opacity: 1; transform: none; }
}

.tok {
  display: inline-block;
}

.tok-sep {
  color: var(--accent);
}

.tok-digit {
  color: var(--digit);
}

.feature-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.feature-pw,
.batch {
  transition: opacity 180ms ease;
}

.is-stale .feature-pw,
.is-stale .batch {
  opacity: 0.4;
}

.stale-hint {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1.4rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.btn:active {
  transform: none;
}

.btn-solid {
  background: var(--text);
  color: var(--bg);
}

.btn-line {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-line:hover {
  border-color: var(--text);
}

.btn-wide {
  width: 100%;
}

.btn.done {
  background: var(--arpp-blue);
  border-color: var(--arpp-blue);
  color: var(--arpp-ink);
}

.meter {
  width: min(28rem, 100%);
}

.meter-track {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--arpp-blue);
  transition: width 300ms ease;
}

.meter-text {
  margin: 0.55rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.meter-text strong {
  color: var(--text);
  font-weight: 600;
}

.tips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.tips-lead {
  margin-bottom: 0.1rem;
}

.tip {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.tip:hover {
  border-color: var(--arpp-blue);
  background: rgba(96, 165, 250, 0.1);
}

.tip-gain {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.meter-pool::before {
  content: " · ";
}

.meter-pool:empty::before {
  content: "";
}

.stage-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.stage-note {
  margin-left: auto;
}

/* Drawer */

.drawer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.drawer-hidden .drawer {
  border-left: 0;
}

.puller {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem 0.6rem;
}

.tabs {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg);
}

.tab-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(9, 9, 11, 0.12);
}

.tabs.ready .tab-indicator {
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), width 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tab {
  position: relative;
  z-index: 1;
  padding: 0.35rem 0.95rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 200ms ease;
}

.tab.is-on {
  color: var(--text);
}

.drawer-close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover {
  background: var(--bg);
  color: var(--text);
}

.pane {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
  padding: 0.2rem 1rem 1rem;
}

.pane.is-on {
  display: flex;
}

.batch {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  counter-reset: row;
}

.batch li {
  counter-increment: row;
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  cursor: copy;
  overflow-wrap: anywhere;
}

.batch li::before {
  content: counter(row, decimal-leading-zero);
  flex: none;
  font-size: 0.72rem;
  color: var(--muted);
}

.batch li:hover {
  background: var(--bg);
}

.batch li.copied {
  background: rgba(96, 165, 250, 0.18);
}

.history {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.history li {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  cursor: copy;
}

.history li:hover {
  background: var(--bg);
}

.history li.copied {
  background: rgba(96, 165, 250, 0.18);
}

.history-pw {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-time {
  flex: none;
  font-size: 0.72rem;
  color: var(--muted);
}

.batch,
.history,
.words {
  padding-right: 0.35rem;
}

.batch::-webkit-scrollbar,
.history::-webkit-scrollbar,
.words::-webkit-scrollbar {
  width: 10px;
}

.batch::-webkit-scrollbar-track,
.history::-webkit-scrollbar-track,
.words::-webkit-scrollbar-track {
  background: transparent;
}

.batch::-webkit-scrollbar-thumb,
.history::-webkit-scrollbar-thumb,
.words::-webkit-scrollbar-thumb {
  border: 3px solid var(--surface);
  border-radius: 99px;
  background: var(--border-strong);
}

.batch::-webkit-scrollbar-thumb:hover,
.history::-webkit-scrollbar-thumb:hover,
.words::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Chrome drops the ::-webkit-scrollbar styling above if these are set, so only Firefox gets them. */
@supports not selector(::-webkit-scrollbar) {
  .batch,
  .history,
  .words {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
}

.search {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.word-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.words {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.words li {
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.words li.long {
  color: var(--muted);
  border-style: dashed;
}

.drawer-open {
  display: none;
  position: fixed;
  right: 1rem;
  top: 1rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.drawer-hidden .drawer-open {
  display: block;
}

.drawer-hidden .stage-top {
  padding-right: 5.5rem;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  background: var(--arpp-ink);
  color: var(--arpp-paper);
  font-size: 0.88rem;
  opacity: 0;
  transform: translate(-50%, 0.6rem);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: var(--arpp-paper);
    color: var(--arpp-ink);
  }
}

/* Error */

.error-page {
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 0.6rem;
  min-height: 100vh;
  padding: 2rem;
}

.error-page h1 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.error-page p {
  margin: 0 0 0.8rem;
  color: var(--muted);
}

.error-code {
  font-family: var(--font-mono);
  color: var(--accent) !important;
}

/* Small screens: rail becomes a top strip, drawer a bottom sheet */

@media (max-width: 860px) {
  .app,
  .app.drawer-hidden {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
    min-height: 100dvh;
  }

  .rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.7rem;
  }

  .rail-mark {
    align-self: center;
  }

  .dials {
    flex: 1;
    flex-direction: row;
    width: auto;
  }

  .dial {
    flex: 1;
    min-width: 0;
  }

  .toggles {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    width: 100%;
  }

  .toggle {
    height: 2.2rem;
  }

  .dial-name {
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  .toggles .rail-label {
    display: none;
  }

  .stage {
    min-height: calc(100dvh - var(--rail-h, 9rem));
    padding: 1.2rem 1.2rem calc(var(--puller-h) + 1.2rem);
    gap: 1.5rem;
  }

  .stage-note {
    margin-left: 0;
  }

  .drawer,
  .drawer-hidden .drawer {
    position: fixed;
    z-index: 30;
    top: var(--rail-h, 9rem);
    right: 0;
    bottom: 0;
    left: 0;
    border-left: 0;
    border-top: 1px solid var(--border-strong);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(9, 9, 11, 0.16);
    transform: translateY(calc(100% - var(--puller-h)));
    transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .sheet-open .drawer {
    transform: none;
  }

  .sheet-dragging .drawer {
    transition: none;
  }

  .sheet-open,
  .sheet-open body {
    overflow: hidden;
  }

  .puller {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    height: var(--puller-h);
    padding: 0;
    border: 0;
    background: none;
    cursor: grab;
    touch-action: none;
    user-select: none;
    transition: height 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .sheet-open .puller {
    height: 1.6rem;
  }

  .sheet-dragging .puller {
    cursor: grabbing;
  }

  .puller-bar {
    width: 2.6rem;
    height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
  }

  .puller-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-height: 1.4rem;
    overflow: hidden;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    transition: opacity 180ms ease, max-height 240ms ease, transform 240ms ease;
  }

  .sheet-open .puller-label {
    opacity: 0;
    max-height: 0;
    transform: translateY(0.4rem);
  }

  .drawer-head {
    padding-top: 0;
    opacity: 0;
    transform: translateY(-0.6rem) scale(0.96);
    transition: opacity 220ms ease 60ms, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1) 40ms;
  }

  .sheet-open .drawer-head {
    opacity: 1;
    transform: none;
  }

  .tabs {
    display: flex;
    flex: 1;
    max-width: 32rem;
    margin-inline: auto;
  }

  .tab {
    flex: 1;
    padding-block: 0.5rem;
  }

  .drawer-open,
  .drawer-hidden .drawer-open,
  .drawer-close {
    display: none;
  }

  .drawer-hidden .stage-top {
    padding-right: 0;
  }

  .toast {
    z-index: 40;
    bottom: calc(var(--puller-h) + 0.8rem);
  }
}

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