:root {
  color-scheme: dark;
  --background: oklch(0.16 0 0);
  --foreground: oklch(0.985 0 0);
  --sidebar: oklch(0.11 0 0);
  --description: oklch(0.78 0 0);
  --danger: oklch(0.72 0.19 22.216);
  --popover: oklch(0.225 0 0);
  --ring: oklch(0.78 0 0);
  --font: "Geist", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow: hidden; }
body {
  margin: 0;
  background: var(--sidebar);
  color: var(--foreground);
  font: 14px/1.428571 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { appearance: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: oklch(1 0 0 / 20%); }
::placeholder { color: oklch(1 0 0 / 45%); }

.app { display: flex; height: 100dvh; overflow: hidden; background: var(--sidebar); }
.sidebar {
  width: 236px;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-inner {
  display: flex;
  width: 236px;
  height: 100%;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 20px;
}
.brand-link { display: flex; min-width: 0; align-items: center; gap: 10px; border-radius: 10px; }
.mark { flex-shrink: 0; color: white; }
.brand-name { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: white; }
.brand-tag { display: block; color: oklch(1 0 0 / 50%); font-size: 11px; }
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 10px;
}
.nav-label, .section-label, .name-label {
  margin: 0 0 6px;
  color: oklch(1 0 0 / 45%);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.section-label { margin-bottom: 12px; color: oklch(1 0 0 / 50%); }
.name-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--description);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 8px 10px;
  color: oklch(1 0 0 / 75%);
}
.nav-link svg { flex-shrink: 0; }
.nav-text { min-width: 0; flex: 1; }
.nav-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.25; }
.nav-desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: oklch(1 0 0 / 50%); font-size: 11px; }
.nav-link:hover { background: oklch(1 0 0 / 7%); color: white; }
.nav-link[aria-current="page"] { background: oklch(1 0 0 / 13%); color: white; }

.stage { display: flex; min-width: 0; flex: 1; padding: 10px; }
.island {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid oklch(1 0 0 / 12%);
  border-radius: 18px;
  background: var(--background);
}

.page { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.page-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
}
.page-header h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.page-header p { margin: 2px 0 0; color: oklch(1 0 0 / 60%); font-size: 12px; }
.page-body { min-height: 0; flex: 1; overflow: auto; padding: 8px 20px 32px; }
.home { width: 100%; max-width: 48rem; margin: 0 auto; }

.tool-list {
  overflow: hidden;
  border: 1px solid oklch(1 0 0 / 12%);
  border-radius: 14px;
  background: oklch(1 0 0 / 3%);
}
.tool-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid oklch(1 0 0 / 10%);
}
.tool-list a:first-child { border-top: 0; }
.tool-list a:hover { background: oklch(1 0 0 / 7%); }
.tool-list a svg { flex-shrink: 0; color: oklch(1 0 0 / 80%); }
.tool-list a span { min-width: 0; flex: 1; }
.tool-list strong { display: block; font-size: 14px; font-weight: 500; }
.tool-list span span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: oklch(1 0 0 / 55%); font-size: 11px; }
.tool-list .chevron { color: oklch(1 0 0 / 35%); }
.tool-list a:hover .chevron { color: white; }

.tool-page {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow: auto;
  padding: 24px;
}
.tool-card { display: flex; width: 100%; max-width: 56rem; flex-direction: column; gap: 24px; }
.tool-card.wide { max-width: 64rem; }
.tool-heading { margin-bottom: 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.title-row { display: flex; align-items: center; gap: 8px; }
.title-row h1 { line-height: 36px; margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.04em; }
.tool-heading p { margin: 4px 0 0; color: var(--description); font-size: 14px; }
.heading-actions { display: flex; align-items: center; gap: 16px; }
.heading-clear { margin-left: auto; }

.btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.btn.sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn.md { height: 40px; padding: 0 16px; font-size: 14px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn.icon { width: 40px; height: 40px; padding: 0; }
.btn.icon-sm, .btn.ghost.icon-sm { width: 32px; height: 32px; padding: 0; }
.btn.wide { width: 100%; }
.btn.primary { border: 0; background: var(--foreground); color: var(--background); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: oklch(1 0 0 / 85%); }
.btn.secondary { border: 1px solid oklch(1 0 0 / 15%); background: oklch(1 0 0 / 5%); }
.btn.secondary:hover:not(:disabled) { border-color: oklch(1 0 0 / 30%); background: oklch(1 0 0 / 11%); }
.btn.ghost { border: 0; background: transparent; color: oklch(1 0 0 / 70%); }
.btn.ghost:hover { background: oklch(1 0 0 / 9%); color: var(--foreground); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn.is-copied { background: var(--foreground); color: var(--background); border-color: transparent; }
.btn .icon-check { display: none; }
.btn.is-copied .icon-copy { display: none; }
.btn.is-copied .icon-check { display: block; }

.clean {
  display: flex;
  width: 100%;
  max-width: 64rem;
  flex-direction: column;
  gap: 16px;
}
.clean-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 8px;
}
.clean-heading p { margin: 4px 0 0; color: var(--description); font-size: 14px; }
.clean-form { width: 100%; }
.clean-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 24rem;
  width: 100%;
  overflow: hidden;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 18px;
}
.clean-split:focus-within { border-color: oklch(1 0 0 / 30%); }
.clean-out,
.clean-in-wrap {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.clean-out {
  position: relative;
  display: flex;
  flex-direction: column;
}
.clean-rule {
  display: block;
  width: 1px;
  height: 100%;
  background: oklch(1 0 0 / 15%);
}
.clean-in,
#clean-output textarea {
  display: block;
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  background: transparent;
  padding: 16px;
  font-size: 14px;
  line-height: 1.428571;
  outline: none;
}
#clean-output,
#clean-output textarea {
  min-height: 0;
  flex: 1;
}
#clean-output {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
}
.empty {
  display: flex;
  width: 100%;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--description);
  font-size: 14px;
}
.pane-busy {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--background);
}
form.htmx-request .pane-busy, .htmx-request.pane-busy { display: flex; }
.spinner {
  color: var(--description);
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
}
.shimmer {
  background: linear-gradient(90deg, transparent 20%, var(--foreground) 50%, transparent 80%) var(--description);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer {
  from { background-position: 180% 0; }
  to { background-position: -80% 0; }
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.ts-input {
  height: 10rem;
  resize: none;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 18px;
  background: transparent;
  padding: 16px;
  outline: none;
}
.ts-input:focus { border-color: oklch(1 0 0 / 30%); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row.end { justify-content: flex-end; }
.copy-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }
.stat { display: flex; align-items: center; gap: 6px; }
.stat svg { color: var(--description); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hint, .muted { color: var(--description); font-size: 14px; }
.xs { font-size: 12px; }
.rule { width: 1px; height: 20px; background: oklch(1 0 0 / 20%); }
.error {
  margin: 0;
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
  border-radius: 14px;
  background: color-mix(in oklab, var(--danger) 10%, transparent);
  padding: 12px 16px;
  color: var(--danger);
  font-size: 14px;
}

.list {
  max-height: 32rem;
  overflow: auto;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 18px;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid oklch(1 0 0 / 10%);
}
.list-row:first-child { border-top: 0; }
.list-row:hover { background: oklch(1 0 0 / 6%); }
.list-row.total { background: oklch(1 0 0 / 6%); font-weight: 600; }
.empty-row { margin: 0; padding: 24px 16px; text-align: center; color: var(--description); }
.end-col { display: flex; flex-shrink: 0; flex-direction: column; align-items: flex-end; gap: 2px; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  display: flex;
  width: 10rem;
  flex-direction: column;
  gap: 2px;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 10px;
  background: var(--popover);
  padding: 4px;
  box-shadow: 0 16px 40px oklch(0 0 0 / 50%);
}
.menu-pop button {
  display: flex;
  width: 100%;
  align-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 6px 10px;
  color: oklch(1 0 0 / 70%);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.menu-pop button:hover, .menu-pop button.on { background: oklch(1 0 0 / 10%); color: var(--foreground); }

.converter-grid { display: flex; gap: 24px; }
.converter-grid > .drop { min-width: 0; flex: 1.2; }
.converter-grid > .session { min-width: 0; flex: 0.8; }
.drop {
  display: flex;
  min-height: 26rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  border: 1px dashed oklch(1 0 0 / 20%);
  border-radius: 18px;
  background: oklch(1 0 0 / 4%);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, background-color 120ms;
}
.drop:hover, .drop.drag { border-color: oklch(1 0 0 / 35%); background: oklch(1 0 0 / 7%); }
.drop.drag { border-color: var(--foreground); background: oklch(1 0 0 / 10%); }
.drop input { display: none; }
.drop-icon {
  display: flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border: 1px solid oklch(1 0 0 / 20%);
  border-radius: 14px;
  background: oklch(1 0 0 / 6%);
}
.drop strong { font-size: 18px; font-weight: 500; }
.drop span { color: var(--description); font-size: 14px; }
.session {
  display: flex;
  min-height: 26rem;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 18px;
  padding: 24px;
}
.session-cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  border: 1px solid oklch(1 0 0 / 12%);
  border-radius: 14px;
  background: oklch(1 0 0 / 3%);
  padding: 12px;
}
.card span {
  display: block;
  color: var(--description);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.card strong { display: block; margin-top: 8px; font-size: 14px; font-weight: 400; word-break: break-word; }
.pair { display: flex; flex-direction: column; gap: 12px; }
.pair .card { flex: 1; }
.name-block {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 12px;
  max-width: 48rem;
  margin: 0 auto;
}
.name-row { display: flex; width: 100%; gap: 12px; }
.name-row input {
  height: 44px;
  min-width: 0;
  flex: 1;
  border: 1px solid oklch(1 0 0 / 15%);
  border-radius: 14px;
  background: transparent;
  padding: 0 12px;
  outline: none;
}
.name-row input:focus { border-color: oklch(1 0 0 / 35%); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
.htmx-indicator { opacity: 0; }
.htmx-request.htmx-indicator, form.htmx-request .htmx-indicator { opacity: 1; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-open { display: none; position: absolute; top: 12px; left: 12px; z-index: 2; }
.nav-close, .nav-scrim { display: none; }

@media (max-width: 1023px) {
  .clean-split {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 18rem;
    height: 24rem;
  }
  .clean-rule { display: none; }
  .converter-grid { display: flex; flex-direction: column; }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(280px, 88vw);
    transform: translateX(-100%);
    border-right: 1px solid oklch(1 0 0 / 12%);
    background: var(--sidebar);
  }
  .sidebar-inner { width: 100%; }
  .nav-open, .nav-close { display: inline-flex; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: oklch(0 0 0 / 55%);
  }
  .page-header { padding-left: 52px; }
  .stage { padding: 8px; }
  .page-header { padding-right: 16px; }
  .page-body { padding-right: 16px; padding-left: 16px; }
  .nav-collapse { display: none; }
}

.prism-scrollbar { scrollbar-width: thin; scrollbar-color: oklch(1 0 0 / 16%) transparent; }
textarea { scrollbar-width: thin; scrollbar-color: oklch(1 0 0 / 16%) transparent; }

@media (prefers-reduced-motion: reduce) {
  .spinner, .shimmer { animation: none; }
  .shimmer { background: none; color: var(--description); }
}

/* Match the source app's type scale and responsive shell. */
.brand-name { line-height: 22.5px; letter-spacing: -0.025em; }
.brand-tag, .nav-desc, .tool-list span span { line-height: 16.5px; }
.brand-link > span { min-width: 0; }
.brand-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-label { padding-left: 10px; line-height: 15px; margin-bottom: 6px; }
.nav-pending { width: 6px; height: 6px; flex-shrink: 0; }
.nav-expand { display: none; position: absolute; top: 12px; left: 12px; z-index: 2; }
.nav-scrim { border: 0; }
.sidebar { transition: width 260ms ease; }
@media (min-width: 768px) {
  html.sidebar-collapsed .sidebar { width: 0; overflow: hidden; }
  html.sidebar-collapsed .nav-expand { display: inline-flex; }
  html.sidebar-collapsed .page-header { padding-left: 56px; }
}
.section-label { line-height: 15px; }
.tool-list strong { font-weight: 400; color: white; }
.page-header p, .xs, .btn.sm { line-height: 16px; }
.page-header h1 { letter-spacing: -0.025em; }
.tool-heading > div { width: 100%; }
#clean-footer:empty, #ts-result:not(:has(*)) { display: none; }
#clean-footer > .error { margin-top: 12px; }
.tool-page:has(#clean-form.htmx-request) #clean-footer .copy-row { visibility: hidden; }
.ts-results { gap: 8px; }
.menu-pop button { gap: 8px; }
.menu-pop button .filter-check { visibility: hidden; }
.menu-pop button.on .filter-check { visibility: visible; }
.menu-pop button.on { background: transparent; }
.menu-pop button:hover { background: oklch(1 0 0 / 10%); }
.menu[open] summary > svg:last-child { transform: rotate(180deg); }
.name-label { font-size: 12px; line-height: 16px; letter-spacing: 0.2em; }
.name-block .name-label { margin: 0; }
.name-block .hint { margin: 0; font-size: 12px; line-height: 16px; }
.name-block .error { padding: 0; border: 0; background: none; font-size: 12px; line-height: 16px; }
.name-row input { background: var(--background); }
.name-row input[aria-invalid="true"] { border-color: color-mix(in oklab, var(--danger) 60%, transparent); }
.session .name-label { margin: 0 0 20px; }
.card span { line-height: 16.5px; }
.drop-copy strong { display: block; line-height: 28px; }
.drop-copy > span { display: block; margin-top: 8px; }
.drop .drop-icon { color: var(--foreground); }
@media (min-width: 640px) and (max-width: 1023px) { .pair { flex-direction: row; } }
@media (max-width: 639px) {
  .name-row { flex-direction: column; }
  .name-row input { flex: auto; }
  .session { padding: 20px; }
}
.prism-scrollbar::-webkit-scrollbar { width: 10px; height: 10px; }
.prism-scrollbar::-webkit-scrollbar-track { background: transparent; }
.prism-scrollbar::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: oklch(1 0 0 / 16%); background-clip: content-box; }
.prism-scrollbar:hover { scrollbar-color: oklch(1 0 0 / 30%) transparent; }
.prism-scrollbar:hover::-webkit-scrollbar-thumb { background: oklch(1 0 0 / 30%); background-clip: content-box; }
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

.list-row strong { font-weight: 600; }
