@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

:root {
  color-scheme: light;
  --font-ui: "Inter", system-ui, sans-serif;
  --brand-navy: #0F1A3A;
  --brand-blue: #0B71FE;
  --brand-cyan: #00AFCE;
  --surface-page: #F5F7FA;
  --surface-primary: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --surface-secondary: #F0F3F7;
  --surface-selected: #EAF3FF;
  --surface-related: #ECFAFC;
  --text-primary: #0F1A3A;
  --text-secondary: #46536A;
  --text-muted: #6D788B;
  --text-inverse: #FFFFFF;
  --text-emphasis: var(--brand-navy);
  --math-text: var(--brand-navy);
  --border-default: #CBD3DE;
  --border-strong: #9CA9BA;
  --border-active: #0B71FE;
  --interaction-primary: #0B71FE;
  --interaction-hover: #075FCC;
  --interaction-pressed: #064FA8;
  --focus-ring: color-mix(in srgb, var(--brand-blue) 28%, transparent);
  --favorite-background: #FFFFFF;
  --favorite-border: #9CA9BA;
  --related-background: #ECFAFC;
  --related-border: #75C8D7;
  --output-border: var(--brand-navy);
  --status-success: #2F7D5A;
  --status-success-background: #EAF5EF;
  --status-warning: #966515;
  --status-warning-background: #FFF6E6;
  --status-error: #A53F3F;
  --status-error-background: #FFF0F0;
  --status-error-border: #D7A4A4;
  --mobile-text-soft: #526870;
  --mobile-text-faint: #6F8188;
  --overlay-backdrop: rgba(15, 26, 58, 0.42);
  --dialog-shadow: 0 22px 60px rgba(23, 38, 45, 0.24);
  --font-size-body: 0.9375rem;
  --font-size-control: 0.875rem;
  --font-size-label: 0.8125rem;
  --font-size-meta: 0.75rem;
  --font-size-heading: 1.0625rem;
  --font-size-value: clamp(1.375rem, 2vw, 1.5rem);
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --border-width: 1px;
  --border-width-active: 2px;
  --control-height: 2.5rem;
  --touch-target: 2.75rem;
  --color-background: var(--surface-page);
  --color-surface: var(--surface-primary);
  --color-surface-muted: var(--surface-secondary);
  --color-surface-accent: var(--surface-selected);
  --color-text: var(--text-primary);
  --color-text-soft: var(--text-secondary);
  --color-text-faint: var(--text-muted);
  --color-border: var(--border-default);
  --color-border-strong: var(--border-strong);
  --color-primary: var(--interaction-primary);
  --color-primary-dark: var(--interaction-hover);
  --color-primary-soft: var(--surface-selected);
  --color-primary-ink: var(--text-emphasis);
  --color-focus: var(--brand-blue);
  --result-commit-bg: var(--status-success-background);
  --keypad-background: color-mix(in srgb, var(--color-surface) 96%, var(--color-primary-soft));
  --keypad-key-background: var(--color-surface-muted);
  --keypad-action-background: var(--color-primary-soft);
  --ad-placeholder-background: color-mix(in srgb, var(--color-surface-muted) 82%, var(--color-background));
  --ad-placeholder-border: var(--color-border-strong);
  --radius-small: 6px;
  --radius-medium: 10px;
  --radius-large: 14px;
  --shadow-soft: 0 2px 8px rgba(15, 26, 58, 0.06);
  --shadow-elevated: 0 18px 46px rgba(15, 26, 58, 0.18);
  --shell-width: 1280px;
  font-family: var(--font-ui);
  font-synthesis: none;
}

.pwa-status {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: 0.55rem;
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.pwa-install {
  min-height: 2.75rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-default);
  border-radius: 0.55rem;
  background: var(--surface-primary);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-page: #080D1C;
  --surface-primary: #0F172A;
  --surface-elevated: #1B2740;
  --surface-secondary: #151F35;
  --surface-selected: #18335C;
  --surface-related: #0B2832;
  --text-primary: #F3F6FC;
  --text-secondary: #C3CCDA;
  --text-muted: #929EB0;
  --text-inverse: #080D1C;
  --text-emphasis: #F3F6FC;
  --math-text: #E9EEF7;
  --border-default: #39465D;
  --border-strong: #53627A;
  --border-active: #438FFF;
  --interaction-primary: #438FFF;
  --interaction-hover: #6AA6FF;
  --interaction-pressed: #2878E6;
  --focus-ring: color-mix(in srgb, #438FFF 42%, transparent);
  --favorite-background: #0F172A;
  --favorite-border: #53627A;
  --related-background: #0B2832;
  --related-border: #397A8A;
  --output-border: #53627A;
  --status-success: #6FD5A5;
  --status-success-background: #102D24;
  --status-warning: #F2C56B;
  --status-warning-background: #332811;
  --status-error: #FF9B9B;
  --status-error-background: #341D24;
  --status-error-border: #8B4A58;
  --mobile-text-soft: #C3CCDA;
  --mobile-text-faint: #929EB0;
  --overlay-backdrop: rgba(2, 6, 18, 0.72);
  --dialog-shadow: 0 22px 60px rgba(0, 0, 0, 0.44);
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-elevated: 0 18px 46px rgba(0, 0, 0, 0.48);
  --result-commit-bg: var(--status-success-background);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--color-background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--color-text);
  background: var(--color-background);
  font-family: var(--font-ui);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: 1.4;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.shell {
  width: min(100% - 1rem, var(--shell-width));
  margin-inline: auto;
}

.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;
}

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid rgba(183, 199, 204, 0.8);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: none;
}

.header-inner {
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-lockup {
  min-width: 0;
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
}

.brand-lockup picture {
  display: flex;
  align-items: center;
}

.brand-logo {
  width: auto;
  height: 1.75rem;
  max-width: min(56vw, 12.75rem);
  display: block;
  object-fit: contain;
}

.saved-trigger {
  margin-left: auto;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.42rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-primary-dark);
  background: var(--color-surface-muted);
  font-size: 0.68rem;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
}

.saved-trigger:hover {
  border-color: var(--color-primary);
  background: var(--color-surface-accent);
}

.bookmark-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.saved-count {
  min-width: 1.25rem;
  padding: 0.08rem 0.3rem;
  border-radius: 999px;
  color: #fff;
  background: var(--color-primary);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.app-main {
  display: grid;
  gap: 0.6rem;
  padding-block: 0.55rem 0.75rem;
}

.public-route-context {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
  padding: 0.05rem 0.1rem 0;
}

.public-route-context h1 {
  margin: 0;
  color: var(--text-emphasis);
  font-size: var(--font-size-heading);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.public-measurement-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
  line-height: 1.25;
}

.public-conversion-content {
  width: min(100%, 52rem);
  min-width: 0;
  margin-inline: auto;
  color: var(--text-primary);
}

.public-content-section {
  padding-block: 0.8rem;
  border-top: 1px solid var(--border-default);
}

.public-content-section h2 {
  margin: 0 0 0.35rem;
  color: var(--text-emphasis);
  font-size: var(--font-size-heading);
  line-height: 1.3;
}

.public-content-section p {
  max-width: 72ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--font-size-body);
  line-height: 1.55;
}

.public-reference-line {
  display: flex;
  max-width: 100%;
  align-items: baseline;
  gap: 0.35rem;
  overflow-x: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  scrollbar-width: thin;
}

.public-reference-line output {
  color: var(--text-emphasis);
  font-weight: var(--font-weight-semibold);
}

.public-reference-line[data-reference-state="loading"] output,
.public-reference-line[data-reference-state="error"] output {
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
}

.public-related-links {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.public-related-links a {
  display: inline-block;
  min-height: var(--control-height);
  padding-block: 0.35rem;
  color: var(--interaction-primary);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  text-underline-offset: 0.18em;
}

.public-related-links a:hover {
  color: var(--interaction-hover);
}

.unit-toolbar {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.toolbar-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.4rem;
}

.toolbar-row + .toolbar-row {
  border-top: 1px solid var(--color-border);
}

.toolbar-label {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-inline: 0.4rem;
  border-right: 1px solid var(--color-border);
  color: var(--color-text-soft);
  font-size: 0.65rem;
  white-space: nowrap;
}

.toolbar-label strong {
  color: var(--color-primary-dark);
  font-size: 0.69rem;
  letter-spacing: 0.025em;
}

.target-dot {
  width: 0.52rem;
  height: 0.52rem;
  flex: 0 0 auto;
  border: 2px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.related-label {
  min-width: 5.8rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
}

.related-label strong {
  color: var(--text-secondary);
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.toolbar-track {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  padding: 0.05rem 0.2rem 0.2rem 0.05rem;
}

.unit-scroll-frame {
  min-width: 0;
  position: relative;
  display: flex;
  flex: 1 1 auto;
}

.unit-scroll-frame::before,
.unit-scroll-frame::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset-block: 0;
  width: 1.375rem;
  opacity: 0;
  pointer-events: none;
}

.unit-scroll-frame::before {
  left: 0;
  background: transparent;
}

.unit-scroll-frame::after {
  right: 0;
  background: transparent;
}

.unit-scroll-frame.has-overflow-left::before,
.unit-scroll-frame.has-overflow-right::after {
  opacity: 1;
}

.unit-scroll {
  min-width: 0;
  width: 100%;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}

.unit-scroll::-webkit-scrollbar,
.category-list::-webkit-scrollbar {
  display: none;
}

.quick-unit-buttons {
  min-width: max-content;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.toolbar-button {
  width: auto;
  min-width: 2.55rem;
  min-height: 2.4rem;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  font-size: 0.78rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.toolbar-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: var(--color-surface-accent);
}

.add-unit-trigger {
  flex: 0 0 auto;
  gap: 0.25rem;
  min-width: auto;
  border-color: var(--color-primary);
  color: #fff;
  background: var(--color-primary);
}

.add-unit-trigger:hover {
  color: #fff;
  background: var(--color-primary-dark);
}

.related-track .toolbar-button {
  color: var(--text-secondary);
  background: #eef4f6;
}

.quick-unit-buttons > .toolbar-button,
.related-unit-scroll > .toolbar-button {
  flex: 0 0 auto;
}

.related-track .related-more {
  border-style: dashed;
  color: var(--color-primary-dark);
  background: var(--color-surface);
}

.related-empty {
  min-height: 2.4rem;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding-inline: 0.4rem;
  color: var(--color-text-faint);
  font-size: 0.7rem;
  white-space: nowrap;
}

.conversion-workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.converter-panel {
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.from-panel {
  border-top: 3px solid var(--color-primary);
}

.to-panel {
  border-top: 3px solid var(--output-border);
}

.panel-value-row {
  min-height: 2.8rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.panel-value-row h2 {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 0.75rem;
  letter-spacing: 0.09em;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.compact-expression-label {
  display: none;
}

.zone-clear-button {
  position: absolute;
  z-index: 4;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--color-text-soft);
  background: transparent;
  cursor: pointer;
}

.zone-clear-button:hover {
  border-color: var(--color-border);
  color: var(--color-primary-dark);
  background: var(--color-surface-accent);
}

.zone-clear-button:disabled {
  opacity: 0.32;
  cursor: default;
  pointer-events: none;
}

.source-value {
  min-width: 0;
  display: block;
}

.source-value input {
  width: 100%;
  padding: 0.05rem 0;
  border: 0;
  outline: 0;
  color: var(--color-text);
  background: transparent;
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1;
}

.source-value input::placeholder {
  color: var(--color-text-faint);
  font-weight: var(--font-weight-medium);
}

.mobile-numeric-keypad[hidden] {
  display: none;
}

.mobile-numeric-keypad {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 30rem);
  margin-inline: auto;
  padding: 0.2rem 0.5rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--color-border-strong);
  border-bottom: 0;
  border-radius: var(--radius-large) var(--radius-large) 0 0;
  background: var(--keypad-background);
  box-shadow: 0 -8px 28px rgba(23, 38, 45, 0.16);
}

.mobile-keypad-header {
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: 1fr 2.75rem 1fr;
  align-items: center;
}

.mobile-keypad-handle {
  grid-column: 2;
  width: 2.25rem;
  height: 0.24rem;
  justify-self: center;
  border-radius: 999px;
  background: var(--color-border-strong);
}

.mobile-keypad-close {
  grid-column: 3;
  width: 2.75rem;
  min-height: 2.75rem;
  justify-self: end;
  padding: 0;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--color-text-soft);
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-keypad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.38rem;
}

.mobile-keypad-grid button {
  min-width: 0;
  min-height: 3rem;
  padding: 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  color: var(--color-text);
  background: var(--keypad-key-background);
  box-shadow: 0 1px 2px rgba(23, 38, 45, 0.08);
  font-size: 1.3125rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.mobile-keypad-grid button.is-secondary {
  color: var(--color-primary-ink);
  background: var(--keypad-action-background);
}

.mobile-keypad-grid button.is-primary {
  border-color: var(--color-primary-dark);
  color: #ffffff;
  background: var(--color-primary);
}

@media (hover: hover) and (pointer: fine) {
  .mobile-keypad-close:hover,
  .mobile-keypad-grid button:hover {
    border-color: var(--color-primary);
  }
}

.mobile-keypad-grid button.is-pressed {
  border-color: var(--color-primary);
  transform: translateY(1px);
}

.result-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.15rem 0.75rem;
}

.result-value-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radius-small);
}

.result-summary output {
  overflow-wrap: anywhere;
  color: var(--color-primary-dark);
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  line-height: 1;
}

.result-copy-button,
.result-save-button {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--color-text-soft);
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
}

.result-copy-button:hover,
.result-save-button:hover:not(:disabled) {
  border-color: var(--color-border);
  color: var(--color-primary-dark);
  background: var(--color-surface-accent);
}

.result-copy-button[hidden],
.result-save-button[hidden] {
  display: none;
}

.result-save-button:disabled {
  color: var(--color-text-faint);
  cursor: not-allowed;
}

.result-save-button.is-saved {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.result-save-button.is-saved .bookmark-icon {
  fill: currentColor;
}

.result-save-feedback {
  flex: 0 0 auto;
  color: var(--color-primary-dark);
  font-size: 0.65rem;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.result-save-feedback.is-error {
  color: var(--status-error);
}

.result-save-feedback[hidden] {
  display: none;
}

.conversion-message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--status-error);
  font-size: 0.72rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1.25;
}

.conversion-message[hidden] {
  display: none;
}

.precision-toggle {
  grid-column: 2;
  grid-row: 1;
  min-height: 2.35rem;
  padding: 0.25rem 0;
  border: 0;
  color: var(--color-primary-dark);
  background: transparent;
  font-size: 0.7rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.precision-toggle[hidden] {
  display: none;
}

.precision-toggle span {
  display: inline-block;
  transition: transform 140ms ease;
}

.precision-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.precision-content {
  display: grid;
  gap: 0.3rem;
  margin: -0.05rem 0 0.45rem 3rem;
  padding: 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface-muted);
}

.precision-content[hidden] {
  display: none;
}

.precision-line {
  min-width: 0;
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.69rem;
}

.precision-line > span {
  color: var(--color-text-soft);
}

.precision-line code {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.precision-note {
  margin: 0;
  color: var(--color-text-faint);
  font-size: 0.75rem;
  line-height: 1.35;
}

.copy-button {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  color: var(--color-primary-dark);
  background: var(--color-surface);
  font-size: 0.66rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.builder {
  position: relative;
  display: grid;
  gap: 0.3rem;
}

.builder > .expression-zone {
  padding-right: 3.35rem;
}

.expression-zone {
  position: relative;
  width: 100%;
  min-height: 3.25rem;
  display: grid;
  grid-template-columns: 5.75rem minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  text-align: left;
  background: #fbfcfc;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.zone-hit-area {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}

.expression-zone:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-muted);
}

.expression-zone.is-active {
  border-color: var(--color-primary);
  background: var(--color-surface-accent);
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.zone-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  pointer-events: none;
}

.zone-label {
  font-size: 0.68rem;
  font-weight: var(--font-weight-semibold);
}

.zone-label-full {
  display: none;
}

.zone-state {
  color: var(--color-text-faint);
  font-size: 0.58rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.expression-zone.is-active .zone-state {
  color: var(--color-primary-dark);
}

.chip-list {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  pointer-events: none;
}

.unit-chip {
  min-height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  color: var(--color-text);
  background: var(--color-surface);
  font-size: 0.82rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  box-shadow: 0 1px 2px rgba(28, 48, 56, 0.05);
  cursor: pointer;
  pointer-events: auto;
}

.unit-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.empty-expression {
  align-self: center;
  color: var(--color-text-faint);
  font-size: 0.7rem;
  font-style: normal;
  pointer-events: none;
}

.unit-chip sup,
.search-results sup {
  position: relative;
  top: -0.2em;
  font-size: 0.68em;
  line-height: 0;
}

.swap-slot {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  place-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.45rem;
}

.swap-button {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-primary);
  border-radius: 50%;
  color: #fff;
  background: var(--color-primary);
  box-shadow: 0 5px 14px rgba(8, 127, 131, 0.2);
  font-size: 1.12rem;
  cursor: pointer;
}

.swap-button:hover {
  background: var(--color-primary-dark);
}

.swap-button:disabled {
  border-color: var(--color-border-strong);
  color: var(--color-text-soft);
  background: var(--color-surface-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.clear-all-button {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  color: var(--color-text-soft);
  background: var(--color-surface);
  font-size: 0.95rem;
  cursor: pointer;
}

.clear-all-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: var(--color-surface-accent);
}

.trash-icon {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.swap-horizontal {
  display: none;
}

.math-preview {
  min-width: 0;
  min-height: 4.8rem;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.7rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.math-preview h2 {
  margin: 0;
  color: var(--color-text-soft);
  font-size: 0.7rem;
  letter-spacing: 0.035em;
}

.math-equation {
  position: relative;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0;
  font-family: Cambria, "Times New Roman", serif;
  font-size: clamp(0.9rem, 2.6vw, 1.15rem);
  scrollbar-width: thin;
  text-align: center;
  white-space: nowrap;
}

.math-equation:not([data-math-state="ready"]) {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
}

.math-output {
  width: max-content;
  min-width: min-content;
  margin-inline: auto;
  padding-inline: 0.35rem;
}

.math-output mjx-container {
  margin: 0 !important;
}

.math-output-staging {
  position: absolute;
  inset: 0 auto auto 0;
  visibility: hidden;
  pointer-events: none;
}

.math-preview-spacer {
  display: none;
}

.post-converter-content {
  min-width: 0;
  display: grid;
  gap: 0.75rem;
}

.ad-placeholder {
  width: min(100%, 20rem);
  height: 6.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  margin-inline: auto;
  border: 1px dashed var(--ad-placeholder-border);
  border-radius: var(--radius-medium);
  color: var(--color-text-soft);
  background: var(--ad-placeholder-background);
  text-align: center;
}

.ad-placeholder span {
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
}

.ad-placeholder small {
  font-size: 0.75rem;
}

.ad-placeholder[hidden] {
  display: none;
}

.future-product-content {
  min-width: 0;
}

body.numeric-entry-mode .unit-toolbar,
body.numeric-entry-mode .converter-panel > .builder,
body.numeric-entry-mode .post-converter-content,
body.numeric-entry-mode .ad-placeholder {
  display: none;
}

body.numeric-entry-mode .app-main {
  gap: 0.4rem;
  padding-top: 0.35rem;
}

body.numeric-entry-mode .conversion-workspace {
  gap: 0.3rem;
}

body.numeric-entry-mode .converter-panel {
  padding-block: 0.5rem;
}

body.numeric-entry-mode .panel-value-row {
  min-height: 3rem;
  margin-bottom: 0;
  grid-template-columns: auto minmax(0, 1fr) minmax(3.5rem, auto);
  gap: 0.45rem;
}

body.numeric-entry-mode .compact-expression-label:not([hidden]) {
  grid-column: 3;
  display: block;
  max-width: min(34vw, 9rem);
  overflow-x: auto;
  color: var(--color-primary-ink);
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
  scrollbar-width: thin;
  text-align: right;
  white-space: nowrap;
}

body.numeric-entry-mode .math-preview {
  min-height: 4.75rem;
}

.term-editor {
  width: min(100%, 26rem);
  max-width: 100%;
  max-height: 88dvh;
  margin: auto 0 0;
  padding: 0.85rem;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 18px 18px 0 0;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: 0 -18px 50px rgba(23, 38, 45, 0.22);
}

.term-editor:not([open]) {
  display: none;
}

.term-editor::backdrop {
  background: rgba(12, 25, 31, 0.38);
  backdrop-filter: none;
}

.term-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.term-editor-header h2,
.term-editor-header p {
  margin: 0;
}

.term-editor-header h2 {
  font-size: 1.05rem;
}

.term-editor-symbol {
  color: var(--color-primary-dark);
  font-size: 1.35rem;
  font-weight: var(--font-weight-semibold);
}

.term-editor-name {
  margin-top: 0.1rem !important;
  color: var(--color-text-soft);
  font-size: 0.7rem;
}

.term-editor-close {
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.term-editor-section {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--color-border);
}

.term-editor-section h3 {
  margin: 0 0 0.45rem;
  color: var(--color-text-soft);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.si-prefix-editor[hidden],
.si-prefix-popup[hidden] {
  display: none;
}

.si-prefix-trigger {
  width: 100%;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  color: var(--color-text);
  background: var(--color-surface);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  text-align: left;
  cursor: pointer;
}

.si-prefix-trigger:disabled {
  color: var(--color-text-faint);
  background: var(--color-surface-muted);
  cursor: not-allowed;
}

.si-prefix-description {
  margin: 0.4rem 0 0;
  color: var(--color-text-soft);
  font-size: 0.75rem;
  line-height: 1.35;
}

.si-prefix-popup {
  margin-top: 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  box-shadow: var(--dialog-shadow);
}

.si-prefix-listbox {
  max-height: min(16.5rem, 44dvh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.si-prefix-option {
  width: 100%;
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.25rem 4.25rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  background: var(--color-surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.si-prefix-option:last-child {
  border-bottom: 0;
}

.si-prefix-option:hover,
.si-prefix-option[aria-selected="true"] {
  color: var(--color-primary-ink);
  background: var(--color-primary-soft);
}

.si-prefix-option:focus-visible,
.si-prefix-trigger:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.si-prefix-option:disabled {
  color: var(--color-text-faint);
  background: var(--color-surface-muted);
  cursor: not-allowed;
}

.si-prefix-option-name {
  min-width: 0;
  overflow: hidden;
  font-weight: var(--font-weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.si-prefix-option-symbol {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  text-align: center;
}

.si-prefix-option-power {
  color: var(--color-text-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.stepper,
.reorder-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stepper button,
.reorder-controls button {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  color: var(--color-primary-dark);
  background: var(--color-surface);
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.stepper button:disabled,
.reorder-controls button:disabled {
  color: var(--color-text-faint);
  background: var(--color-surface-muted);
  cursor: not-allowed;
}

.stepper output {
  min-width: 3.2rem;
  color: var(--color-text);
  font-size: 1.15rem;
  font-weight: var(--font-weight-semibold);
  text-align: center;
}

.term-action-button,
.remove-term-button {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  text-align: left;
  background: var(--color-surface);
  font-size: 0.76rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.term-action-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: var(--color-surface-accent);
}

.remove-term-button {
  margin-top: 0.85rem;
  border-color: var(--status-error-border);
  color: var(--status-error);
  text-align: center;
  background: var(--status-error-background);
}

.remove-term-button:hover {
  border-color: var(--status-error);
  background: var(--status-error-background);
}

.unit-picker {
  width: min(100%, 48rem);
  max-width: 100%;
  max-height: 88dvh;
  margin: auto 0 0;
  padding: 0.85rem;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 18px 18px 0 0;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: 0 -18px 50px rgba(23, 38, 45, 0.22);
}

.unit-picker:not([open]) {
  display: none;
}

.unit-picker::backdrop {
  background: rgba(12, 25, 31, 0.46);
  backdrop-filter: none;
}

.saved-dialog {
  width: min(100%, 36rem);
  max-width: 100%;
  max-height: 88dvh;
  margin: auto 0 0;
  padding: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 18px 18px 0 0;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: 0 -18px 50px rgba(23, 38, 45, 0.22);
}

.saved-dialog:not([open]) {
  display: none;
}

.saved-dialog::backdrop {
  background: rgba(12, 25, 31, 0.46);
  backdrop-filter: none;
}

.saved-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.saved-dialog-header h2,
.saved-dialog-header p {
  margin: 0;
}

.saved-dialog-header h2 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.saved-dialog-header p {
  margin-top: 0.1rem;
  color: var(--color-text-soft);
  font-size: 0.7rem;
}

.saved-dialog-close {
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.saved-auto-save-control {
  min-width: 0;
  min-height: 2.4rem;
  margin-top: 0.6rem;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface-muted);
  color: var(--color-text);
  font-size: 0.78rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.saved-auto-save-control input {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--color-primary);
}

.saved-auto-save-control span {
  min-width: 0;
}

.saved-panel-message {
  margin: 0.65rem 0 0;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-small);
  color: var(--status-error);
  background: var(--status-error-background);
  font-size: 0.72rem;
  font-weight: var(--font-weight-semibold);
}

.saved-panel-message[hidden] {
  display: none;
}

.saved-list {
  min-width: 0;
  max-height: min(58dvh, 28rem);
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.saved-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface-muted);
}

.saved-item-load {
  min-width: 0;
  padding: 0.65rem 0.7rem;
  border: 0;
  border-radius: var(--radius-medium) 0 0 var(--radius-medium);
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.saved-item-load:hover {
  background: var(--color-surface-accent);
}

.saved-item-summary {
  display: block;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: var(--font-weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-item-date {
  display: block;
  margin-top: 0.18rem;
  color: var(--color-text-soft);
  font-size: 0.64rem;
}

.saved-item-delete {
  width: 2.65rem;
  min-height: 3.8rem;
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--color-border);
  border-radius: 0 var(--radius-medium) var(--radius-medium) 0;
  color: var(--status-error);
  background: transparent;
  cursor: pointer;
}

.saved-item-delete:hover {
  background: var(--status-error-background);
}

.saved-item-delete .trash-icon {
  width: 1rem;
  height: 1rem;
}

.saved-empty {
  margin: 0;
  padding: 1.4rem 0.75rem;
  color: var(--color-text-soft);
  font-size: 0.78rem;
  text-align: center;
}

.saved-delete-confirmation {
  margin-top: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--status-error-border);
  border-radius: var(--radius-medium);
  background: var(--status-error-background);
}

.saved-delete-confirmation[hidden] {
  display: none;
}

.saved-delete-confirmation p {
  margin: 0;
  font-size: 0.76rem;
  font-weight: var(--font-weight-semibold);
}

.saved-delete-confirmation > div {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.saved-delete-confirmation button {
  min-height: 2.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-small);
  background: var(--color-surface);
  font-size: 0.72rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.saved-delete-confirmation .saved-delete-confirm {
  border-color: var(--status-error);
  color: #fff;
  background: var(--status-error);
}

.picker-handle {
  width: 2.75rem;
  height: 0.22rem;
  margin: -0.2rem auto 0.65rem;
  border-radius: 999px;
  background: var(--color-border-strong);
}

.picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.picker-header h2,
.picker-header p {
  margin: 0;
}

.picker-header h2 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.picker-header p {
  margin-top: 0.1rem;
  color: var(--color-text-soft);
  font-size: 0.72rem;
}

.picker-header strong {
  color: var(--color-primary-dark);
}

.picker-shortcuts {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.picker-shortcuts[hidden] {
  display: none;
}

.picker-shortcut-row {
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
}

.picker-shortcut-label {
  color: var(--color-text-soft);
  font-size: 0.65rem;
  font-weight: var(--font-weight-semibold);
}

.picker-shortcut-row .unit-scroll {
  padding-block: 0.05rem;
}

.picker-shortcut-row .related-empty {
  min-height: 2.4rem;
}

.picker-close {
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.search-field {
  min-height: 3rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-block: 0.65rem 0.8rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-medium);
  background: var(--color-surface-muted);
}

.search-field:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.search-icon {
  color: var(--color-text-soft);
  font-size: 1.15rem;
}

.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--color-text);
  background: transparent;
}

.search-field input::placeholder {
  color: var(--color-text-faint);
}

.search-field kbd {
  min-width: 1.55rem;
  padding: 0.08rem 0.3rem;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--color-text-faint);
  background: var(--color-surface);
  font: 0.65rem ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}

.picker-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}

.picker-group {
  min-width: 0;
}

.picker-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.picker-group-heading h3 {
  margin: 0;
  font-size: 0.82rem;
}

.picker-group-heading span {
  color: var(--color-text-faint);
  font-size: 0.63rem;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-bottom: 0.2rem;
}

.category-list button {
  min-height: 2.35rem;
  flex: 0 0 auto;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-soft);
  background: var(--color-surface);
  font-size: 0.72rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.category-list button.is-selected {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.search-results {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 0.4rem;
}

.unit-result-row {
  min-width: 0;
  min-height: 3.6rem;
  display: grid;
  grid-template-columns: minmax(0, min(24%, 7rem)) minmax(0, 1fr) 2.65rem;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  text-align: left;
  background: var(--color-surface);
  cursor: pointer;
  touch-action: manipulation;
}

.unit-result-row:hover,
.unit-result-row.is-pressed {
  border-color: var(--color-primary);
  background: var(--color-surface-accent);
}

.unit-result-symbol {
  overflow: visible;
  color: var(--color-primary-dark);
  font-size: 0.92rem;
  text-align: center;
  text-overflow: clip;
  white-space: normal;
  min-width: 0;
  overflow-wrap: anywhere;
}

.unit-result-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.15rem;
}

.search-results b {
  overflow: visible;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.search-results small {
  color: var(--color-text-faint);
  font-size: 0.64rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.unit-favorite-toggle {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-primary-dark);
  background: var(--color-surface);
  font-size: 1rem;
  cursor: pointer;
}

.unit-favorite-toggle[aria-pressed="true"] {
  border-color: var(--color-primary-soft);
  background: var(--color-primary-soft);
}

.unit-favorite-toggle:hover {
  border-color: var(--color-primary);
}

.picker-empty {
  min-height: 5rem;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-small);
  color: var(--color-text-faint);
  text-align: center;
  font-size: 0.72rem;
}

/* Dimversa Visual Design Pass 1: Light Mode component semantics */
.site-header {
  border-bottom-color: var(--border-default);
  background: var(--surface-primary);
  backdrop-filter: none;
}

.header-inner {
  min-height: 3.5rem;
}

.brand-logo {
  height: 1.9rem;
  max-width: min(58vw, 13rem);
}

.saved-trigger {
  min-height: var(--control-height);
  padding-inline: 0.65rem;
  border-color: var(--border-default);
  color: var(--text-emphasis);
  background: var(--surface-primary);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.saved-trigger:hover,
.zone-clear-button:hover,
.result-copy-button:hover,
.result-save-button:hover:not(:disabled),
.clear-all-button:hover,
.saved-item-load:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.saved-count {
  color: var(--text-inverse);
  background: var(--brand-blue);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
}

.unit-toolbar,
.converter-panel,
.math-preview {
  border-color: var(--border-default);
  box-shadow: var(--shadow-soft);
}

.toolbar-label {
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
}

.toolbar-label strong {
  color: var(--text-emphasis);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-semibold);
}

.related-label strong {
  color: var(--text-secondary);
}

.target-dot {
  border-color: var(--surface-primary);
  background: var(--brand-blue);
  box-shadow: 0 0 0 2px var(--surface-selected);
}

.unit-scroll-frame::before,
.unit-scroll-frame::after {
  width: 0.5rem;
  background: transparent;
}

.unit-scroll-frame::before {
  border-left: 2px solid color-mix(in srgb, var(--brand-blue) 34%, transparent);
}

.unit-scroll-frame::after {
  border-right: 2px solid color-mix(in srgb, var(--brand-blue) 34%, transparent);
}

.toolbar-button {
  min-height: var(--control-height);
  border-color: var(--border-strong);
  background: var(--surface-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-medium);
}

.toolbar-button.is-quick-unit,
.toolbar-button.is-user-favorite {
  border-color: var(--favorite-border);
  color: var(--text-primary);
  background: var(--favorite-background);
}

.toolbar-button.is-related-unit,
.related-track .toolbar-button.is-related-unit {
  border-color: var(--related-border);
  color: var(--text-emphasis);
  background: var(--related-background);
}

.toolbar-button:hover,
.toolbar-button.is-quick-unit:hover,
.toolbar-button.is-related-unit:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.toolbar-button:active,
.mobile-keypad-grid button.is-pressed {
  border-color: var(--border-active);
  background: color-mix(in srgb, var(--surface-selected) 76%, var(--surface-primary));
}

.add-unit-trigger,
.add-unit-trigger:hover {
  border-color: var(--interaction-primary);
  color: var(--text-inverse);
  background: var(--interaction-primary);
  font-weight: var(--font-weight-semibold);
}

.add-unit-trigger:hover {
  background: var(--interaction-hover);
}

.add-unit-trigger:active {
  background: var(--interaction-pressed);
}

.related-track .related-more {
  border-color: var(--related-border);
  color: var(--text-secondary);
  background: var(--surface-primary);
}

.related-empty {
  color: var(--text-muted);
  font-size: var(--font-size-meta);
}

.from-panel {
  border-top-color: var(--brand-blue);
}

.to-panel {
  border-top-color: var(--output-border);
}

.panel-value-row h2 {
  color: var(--text-emphasis);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.source-value input {
  min-height: 3rem;
  padding: 0.45rem 0.65rem;
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius-small);
  outline: none;
  color: var(--text-primary);
  background: var(--surface-primary);
  font-size: var(--font-size-value);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.025em;
  line-height: 1.15;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.source-value input::placeholder {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  opacity: 0.72;
}

.source-value input:hover {
  border-color: var(--border-active);
}

.source-value input:focus-visible {
  border-color: var(--border-active);
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--border-active);
}

.result-summary {
  min-height: 3rem;
  padding: 0.4rem 0.6rem;
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-small);
  background: var(--surface-secondary);
}

.result-summary output {
  color: var(--text-emphasis);
  font-size: var(--font-size-value);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.result-copy-button,
.result-save-button {
  width: var(--control-height);
  height: var(--control-height);
  color: var(--text-secondary);
}

.result-save-button.is-saved {
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.result-save-feedback {
  color: var(--status-success);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-semibold);
}

.result-save-feedback.is-error,
.conversion-message {
  color: var(--status-error);
}

.conversion-message {
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.precision-toggle {
  min-height: var(--control-height);
  color: var(--interaction-hover);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-medium);
}

.precision-content {
  border-color: var(--border-default);
  background: var(--surface-secondary);
}

.precision-line {
  grid-template-columns: 5rem minmax(0, 1fr) auto;
  font-size: var(--font-size-label);
}

.precision-line > span {
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.precision-line code {
  color: var(--text-primary);
  font-size: var(--font-size-control);
}

.copy-button {
  min-height: var(--control-height);
  padding-inline: 0.7rem;
  border-color: var(--border-strong);
  color: var(--interaction-hover);
  background: var(--surface-primary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-medium);
}

.expression-zone {
  border-color: var(--border-default);
  background: var(--surface-primary);
}

.expression-zone:hover {
  border-color: var(--border-strong);
  background: var(--surface-secondary);
}

.expression-zone.is-active {
  border-color: var(--border-active);
  background: var(--surface-selected);
  box-shadow: inset 3px 0 0 var(--border-active);
}

.zone-label {
  color: var(--text-primary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.zone-state,
.empty-expression {
  color: var(--text-muted);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.expression-zone.is-active .zone-state {
  color: var(--interaction-hover);
}

.unit-chip {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-medium);
  box-shadow: none;
}

.unit-chip:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
}

.swap-button {
  border-color: var(--interaction-primary);
  color: var(--text-inverse);
  background: var(--interaction-primary);
  box-shadow: 0 3px 9px rgba(11, 113, 254, 0.18);
}

.swap-button:hover {
  background: var(--interaction-hover);
}

.swap-button:active {
  background: var(--interaction-pressed);
}

.swap-button:disabled {
  border-color: var(--border-default);
  color: var(--text-muted);
  background: var(--surface-secondary);
}

.math-preview h2 {
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.math-equation {
  color: var(--math-text);
  font-size: 1.1875rem;
}

.math-equation:not([data-math-state="ready"]) {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: var(--font-size-meta);
}

.ad-placeholder span,
.saved-auto-save-control,
.saved-item-summary,
.picker-shortcut-label,
.category-list button,
.search-results b,
.term-action-button,
.remove-term-button {
  font-weight: var(--font-weight-medium);
}

body.numeric-entry-mode .compact-expression-label:not([hidden]) {
  color: var(--text-emphasis);
  font-weight: var(--font-weight-semibold);
}

.mobile-numeric-keypad {
  border-color: var(--border-strong);
  background: var(--surface-primary);
  box-shadow: 0 -8px 24px rgba(15, 26, 58, 0.14);
}

.mobile-keypad-grid button {
  border-color: var(--border-default);
  color: var(--text-primary);
  background: var(--surface-secondary);
  box-shadow: none;
  font-weight: var(--font-weight-semibold);
}

.mobile-keypad-grid button.is-secondary {
  color: var(--text-emphasis);
  background: var(--surface-selected);
}

.mobile-keypad-grid button.is-primary {
  border-color: var(--interaction-primary);
  color: var(--text-inverse);
  background: var(--interaction-primary);
}

.mobile-keypad-grid button.is-primary.is-pressed {
  background: var(--interaction-pressed);
}

.term-editor,
.unit-picker,
.saved-dialog {
  border-color: var(--border-default);
  background: var(--surface-primary);
  box-shadow: var(--shadow-elevated);
}

.term-editor::backdrop,
.unit-picker::backdrop,
.saved-dialog::backdrop {
  background: rgba(15, 26, 58, 0.42);
  backdrop-filter: none;
}

.term-editor-header h2,
.saved-dialog-header h2,
.picker-header h2 {
  color: var(--text-emphasis);
  font-size: var(--font-size-heading);
  font-weight: var(--font-weight-semibold);
}

.term-editor-symbol {
  color: var(--interaction-hover);
  font-weight: var(--font-weight-semibold);
}

.term-editor-name,
.saved-dialog-header p,
.picker-header p,
.picker-group-heading span,
.search-results small,
.saved-item-date {
  color: var(--text-muted);
  font-size: var(--font-size-meta);
}

.term-editor-section h3,
.picker-group-heading h3 {
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.stepper button,
.reorder-controls button,
.stepper output {
  font-weight: var(--font-weight-semibold);
}

.remove-term-button,
.saved-item-delete {
  border-color: var(--status-error-border);
  color: var(--status-error);
  background: var(--status-error-background);
}

.saved-panel-message,
.saved-delete-confirmation {
  border-color: var(--status-error-border);
  color: var(--status-error);
  background: var(--status-error-background);
}

.saved-item,
.saved-auto-save-control {
  background: var(--surface-secondary);
}

.saved-item-summary,
.saved-empty,
.saved-delete-confirmation p,
.saved-delete-confirmation button {
  font-size: var(--font-size-control);
}

.saved-delete-confirmation .saved-delete-confirm {
  border-color: var(--status-error);
  color: var(--text-inverse);
  background: var(--status-error);
}

.picker-header strong,
.unit-result-symbol {
  color: var(--text-emphasis);
}

.search-field {
  border-color: var(--border-strong);
  background: var(--surface-primary);
}

.search-field:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-field input {
  font-size: var(--font-size-control);
}

.category-list button {
  min-height: var(--control-height);
  color: var(--text-secondary);
  font-size: var(--font-size-control);
}

.category-list button.is-selected {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.unit-result-row {
  border-color: var(--border-default);
  background: var(--surface-primary);
}

.unit-result-row:hover,
.unit-result-row.is-pressed {
  border-color: var(--border-active);
  background: var(--surface-selected);
}

.unit-result-symbol {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
}

.search-results b {
  color: var(--text-primary);
  font-size: var(--font-size-control);
}

.unit-favorite-toggle {
  border-color: var(--border-default);
  color: var(--text-secondary);
  background: var(--favorite-background);
}

.unit-favorite-toggle[aria-pressed="true"] {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.unit-favorite-toggle:hover {
  border-color: var(--border-active);
}

button:disabled {
  opacity: 0.58;
}

/* Mobile result correction: shared Copy icon geometry */
.copy-button {
  width: var(--control-height);
  height: var(--control-height);
  min-height: var(--control-height);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
}

.copy-button:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

/* Dimversa Visual Design Pass 2: theme and application menu */
.brand-lockup .brand-picture-dark {
  display: none;
}

:root[data-theme="dark"] .brand-lockup .brand-picture-light {
  display: none;
}

:root[data-theme="dark"] .brand-lockup .brand-picture-dark {
  display: flex;
}

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}

.header-actions .saved-trigger {
  margin-left: 0;
}

.application-menu-shell {
  position: relative;
  flex: 0 0 auto;
}

.application-menu-trigger {
  width: var(--control-height);
  height: var(--control-height);
  min-height: var(--control-height);
  display: grid;
  place-items: center;
  padding: 0;
  border: var(--border-width) solid var(--border-default);
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--surface-primary);
  font-size: 1.35rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  cursor: pointer;
}

.application-menu-trigger:hover,
.application-menu-trigger[aria-expanded="true"] {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.application-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(19rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 4.75rem);
  max-height: calc(100dvh - 4.75rem);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0.75rem;
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-medium);
  color: var(--text-primary);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-elevated);
}

.application-menu[hidden] {
  display: none;
}

.application-menu-group,
.application-menu-footer {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: var(--border-width) solid var(--border-default);
}

.application-menu-row {
  display: grid;
  grid-template-columns: 1.125rem minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.65rem;
  width: 100%;
  min-height: var(--touch-target);
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-medium);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.application-menu-row:hover {
  background: var(--surface-selected);
}

.application-menu-row:focus-visible,
.application-menu-row input:focus-visible {
  outline: 2px solid var(--border-active);
  outline-offset: -2px;
}

.application-menu-row input:focus-visible {
  outline-offset: 2px;
}

.application-menu-row svg {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--text-secondary);
}

.application-menu-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--interaction-primary);
  cursor: inherit;
}

.application-menu-description {
  display: block;
  margin: 0 0.5rem 0.35rem 2.275rem;
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
  line-height: 1.45;
}

.application-menu-footer {
  display: grid;
  justify-items: center;
  row-gap: 0.1rem;
  padding-block: 0.6rem 0.1rem;
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
  text-align: center;
}

.application-menu-footer strong {
  font-weight: var(--font-weight-semibold);
}

.application-menu-heading {
  padding: 0 0.15rem 0.55rem;
  border-bottom: var(--border-width) solid var(--border-default);
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.appearance-control {
  min-width: 0;
  margin: 0;
  padding: 0.7rem 0 0;
  border: 0;
}

.appearance-control legend {
  padding: 0 0.15rem 0.45rem;
  color: var(--text-emphasis);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.appearance-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.appearance-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.appearance-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.appearance-option span {
  min-height: var(--control-height);
  display: grid;
  place-items: center;
  padding: 0.35rem 0.45rem;
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-small);
  color: var(--text-secondary);
  background: var(--surface-secondary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-medium);
  text-align: center;
}

.appearance-option:hover span {
  border-color: var(--border-active);
  color: var(--interaction-hover);
}

.appearance-option input:checked + span {
  border-color: var(--border-active);
  color: var(--text-inverse);
  background: var(--interaction-primary);
  font-weight: var(--font-weight-semibold);
}

.appearance-option input:focus-visible + span {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.math-equation {
  color: var(--math-text);
}

.math-equation[data-math-state="ready"][data-result-confirmation="provisional"] {
  color: var(--text-secondary);
}

.term-editor::backdrop,
.unit-picker::backdrop,
.saved-dialog::backdrop {
  background: var(--overlay-backdrop);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

}


/* Library Phase 4A */
.library-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.library-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.25rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  background: var(--surface-secondary);
}

.library-tabs button {
  min-height: var(--control-height);
  padding: 0.45rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: var(--text-secondary);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.library-tabs button[aria-selected="true"] {
  border-color: var(--border-active);
  color: var(--text-emphasis);
  background: var(--surface-primary);
  box-shadow: var(--shadow-card);
}

.library-panel {
  min-width: 0;
  margin-top: 0.75rem;
}

.library-panel[hidden] {
  display: none;
}

.library-presets-panel {
  max-height: min(66dvh, 34rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.library-search-field {
  display: block;
}

.library-search-field input {
  width: 100%;
  min-height: var(--control-height);
  border-color: var(--border-default);
  background: var(--surface-primary);
}

.public-preset-category-filter {
  min-width: 0;
  margin-top: 0.55rem;
  overflow: hidden;
}

.public-preset-category-list {
  min-width: 0;
  display: flex;
  gap: 0.35rem;
  padding: 0.1rem 0.05rem 0.35rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.public-preset-category-button {
  flex: 0 0 auto;
  min-height: var(--control-height);
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--surface-primary);
  font: inherit;
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  cursor: pointer;
}

.public-preset-category-button:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.public-preset-category-button[aria-pressed="true"] {
  border-color: var(--border-active);
  color: var(--text-emphasis);
  background: var(--surface-selected);
}

.public-preset-catalog-summary {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: var(--font-size-meta);
}

.public-preset-catalog {
  min-width: 0;
  display: grid;
  gap: 1rem;
  margin-top: 0.65rem;
}

.public-preset-category-group,
.public-preset-measurement-group {
  min-width: 0;
}

.public-preset-category-heading,
.public-preset-measurement-heading {
  margin: 0;
}

.public-preset-category-heading {
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.public-preset-measurement-group {
  margin-top: 0.6rem;
}

.public-preset-measurement-heading {
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.public-preset-measurement-list {
  margin-top: 0.35rem;
}

.library-section {
  margin-top: 0.9rem;
}

.library-section-heading,
.saved-tab-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.library-section-heading h3,
.library-section-heading span,
.saved-tab-toolbar p {
  margin: 0;
}

.library-section-heading h3 {
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.library-section-heading span,
.saved-tab-toolbar p {
  color: var(--text-muted);
  font-size: var(--font-size-meta);
}

.library-preset-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.library-preset-item {
  min-width: 0;
  min-height: 4.25rem;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  color: var(--text-emphasis);
  background: var(--surface-secondary);
  text-align: left;
  cursor: pointer;
}

.library-preset-item:hover {
  border-color: var(--border-active);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.library-preset-measurement {
  color: var(--text-muted);
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-medium);
}

.library-preset-expression {
  max-width: 100%;
  color: inherit;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.saved-tab-toolbar {
  min-height: var(--control-height);
}

.saved-delete-all-trigger {
  min-height: var(--control-height);
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--status-error-border);
  border-radius: var(--radius-small);
  color: var(--status-error);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-meta);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.saved-delete-all-trigger:hover {
  background: var(--status-error-background);
}

.saved-delete-all-trigger[hidden] {
  display: none;
}

.saved-delete-all-confirmation p + p {
  margin-top: 0.35rem;
  color: var(--text-secondary);
  font-weight: var(--font-weight-regular);
}
/* My Presets Phase 4B */
.result-summary {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.35rem;
}

.result-value-line {
  width: 100%;
  grid-column: 1 / -1;
}

.result-summary output {
  display: block;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  scrollbar-width: thin;
}

.result-actions-row {
  min-width: 0;
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
}

.result-copy-button,
.result-save-button,
.result-save-preset-button {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
}

.result-save-preset-button {
  width: auto;
  grid-auto-flow: column;
  gap: 0.35rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
}

.result-save-preset-label {
  white-space: nowrap;
}

.result-save-preset-button:hover,
.result-copy-button:hover,
.result-save-button:hover:not(:disabled) {
  border-color: var(--border-default);
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.result-copy-button[hidden],
.result-save-button[hidden] {
  display: none;
}

.preset-add-icon {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.result-actions-row .precision-toggle {
  grid-column: auto;
  grid-row: auto;
  min-height: 2.25rem;
  padding: 0.25rem 0.35rem;
}

.result-actions-row .result-save-feedback {
  min-width: 0;
}

.result-summary .conversion-message {
  grid-column: 1;
}

.library-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.library-my-presets-panel {
  max-height: min(66dvh, 34rem);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.user-preset-list {
  grid-template-columns: minmax(0, 1fr);
}

.library-preset-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  background: var(--surface-secondary);
}

.user-preset-card {
  grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
}

.library-preset-card:hover,
.library-preset-card:focus-within {
  border-color: var(--border-active);
}

.library-preset-card .library-preset-item {
  min-height: 4.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.library-preset-card .library-preset-item:hover {
  background: var(--surface-selected);
}

.preset-star-button,
.preset-actions-button {
  width: 2.5rem;
  min-height: 2.75rem;
  align-self: stretch;
  padding: 0;
  border: 0;
  color: var(--text-secondary);
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
}

.preset-star-button[aria-pressed="true"] {
  color: var(--interaction-active);
}

.preset-star-button:hover,
.preset-actions-button:hover {
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.preset-actions-button {
  font-size: 1.3rem;
}

.preset-actions-menu {
  position: fixed;
  z-index: 8;
  width: min(17rem, calc(100% - 1rem));
  overflow-y: auto;
  padding: 0.35rem;
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  background: var(--surface-primary);
  box-shadow: var(--shadow-elevated);
}

.workspace-shortcuts,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.workspace-install {
  color: var(--text-inverse);
  background: var(--interaction-primary);
  border-color: var(--interaction-primary);
  font-weight: var(--font-weight-semibold);
}

.launch-preview {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--font-size-meta);
  padding: 0.35rem 0.25rem;
  text-align: start;
  text-decoration: underline dotted;
  cursor: pointer;
}

.pro-badge {
  vertical-align: middle;
  display: inline-block;
  border: 1px solid var(--border-default);
  border-radius: 0.25rem;
  padding: 0.08rem 0.22rem;
  color: var(--text-secondary);
  font-size: 0.62rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}

.picker-in-use[hidden],
.history-actions[hidden],
.history-actions [hidden],
body.numeric-entry-mode .workspace-shortcuts,
body.numeric-entry-mode .workspace-auto-save,
body.numeric-entry-mode .workspace-history {
  display: none;
}

.picker-in-use h3,
.picker-all-categories {
  margin: 0 0 0.3rem;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
}

.picker-all-categories {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
}

.picker-all-categories select {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-small);
  background: var(--surface-primary);
  color: var(--text-primary);
  font: inherit;
}

.workspace-history {
  min-width: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-medium);
  padding: 0.6rem 0.75rem;
  background: var(--surface-primary);
}

.workspace-auto-save {
  margin: 0;
  min-height: var(--touch-target);
  padding: 0.35rem 0.65rem;
}

.workspace-history summary {
  cursor: pointer;
  font-weight: var(--font-weight-semibold);
}

.history-actions,
.history-list {
  margin-top: 0.45rem;
}

.history-meta,
.favorites-editor-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.3rem;
}

.history-item,
.favorites-editor-list > li {
  padding: 0.4rem 0;
  border-top: 1px solid var(--border-default);
}

.history-item {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
}

.history-meta time {
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
  overflow-wrap: anywhere;
}

.workspace-history button,
.favorites-editor-list button {
  min-height: var(--touch-target, 2.75rem);
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-small);
  background: var(--surface-secondary);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}

.workspace-history .history-restore {
  text-align: start;
  overflow-wrap: anywhere;
}

.workspace-history .history-icon {
  width: var(--touch-target, 2.75rem);
  display: grid;
  place-items: center;
}

.back-toast {
  position: fixed;
  z-index: 60;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-medium);
  background: var(--surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-soft);
  text-align: center;
  pointer-events: none;
}

.favorites-editor-list {
  margin: 0;
  padding: 0;
  max-height: 48vh;
  overflow-y: auto;
  list-style: none;
}

.favorites-editor-list > li {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  overflow-wrap: anywhere;
}

.favorites-editor-list button { min-width: var(--touch-target, 2.75rem); }
.favorites-editor-list button:disabled { opacity: 0.45; cursor: not-allowed; }

.preset-actions-menu[hidden] {
  display: none;
}

.preset-actions-menu button {
  min-height: var(--control-height);
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text-primary);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-control);
  text-align: left;
  cursor: pointer;
}

.preset-actions-menu button:hover:not(:disabled),
.preset-actions-menu button:focus-visible {
  color: var(--interaction-hover);
  background: var(--surface-selected);
}

.preset-actions-menu button:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.user-preset-confirmation {
  margin-top: 0.75rem;
}

.user-preset-confirmation p + p {
  margin-top: 0.35rem;
  color: var(--text-secondary);
  font-weight: var(--font-weight-regular);
}

.preset-dialog {
  width: min(calc(100% - 2rem), 30rem);
  max-width: 100%;
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-large);
  color: var(--text-primary);
  background: var(--surface-primary);
  box-shadow: var(--shadow-elevated);
}

.preset-dialog:not([open]) {
  display: none;
}

.preset-dialog::backdrop {
  background: var(--overlay-backdrop);
}

.preset-dialog-form {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
}

.preset-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.preset-dialog-header h2,
.preset-dialog-expression {
  margin: 0;
}

.preset-dialog-header h2 {
  font-size: var(--font-size-heading);
}

.preset-dialog-expression {
  display: block;
  max-width: 100%;
  margin-top: 0.3rem;
  color: var(--text-secondary);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-semibold);
  overflow-wrap: anywhere;
}

.preset-dialog-close {
  width: var(--control-height);
  height: var(--control-height);
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--surface-secondary);
  font-size: 1.25rem;
  cursor: pointer;
}

.preset-name-field {
  display: grid;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: var(--font-weight-semibold);
}

.preset-name-field input {
  width: 100%;
  min-height: var(--control-height);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-small);
  color: var(--text-primary);
  background: var(--surface-primary);
  font: inherit;
  font-size: var(--font-size-control);
}

.preset-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.preset-dialog-actions button {
  min-height: var(--control-height);
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-small);
  color: var(--text-primary);
  background: var(--surface-secondary);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.preset-dialog-actions .preset-primary-action {
  border-color: var(--interaction-primary);
  color: var(--text-inverse);
  background: var(--interaction-primary);
}

.preset-dialog-actions .preset-primary-action:hover:not(:disabled),
.preset-dialog-actions .preset-primary-action:focus-visible {
  border-color: var(--interaction-hover);
  background: var(--interaction-hover);
}

.preset-dialog-actions .preset-primary-action:active:not(:disabled) {
  border-color: var(--interaction-pressed);
  background: var(--interaction-pressed);
}

.preset-dialog-actions .preset-primary-action:disabled {
  border-color: var(--border-default);
  color: var(--text-muted);
  background: var(--surface-secondary);
  cursor: wait;
}
