.tools-page {
  --ambient-x: 50%;
  --ambient-y: 22%;
  padding-bottom: 2.2rem;
  overscroll-behavior-y: none;
}

.tools-page.settings-open {
  overflow: hidden;
}

.tools-page .page-shell {
  width: min(1700px, calc(100% - 1rem));
}

.tools-page.setting-large-text {
  font-size: 1.06rem;
}

.tools-page.setting-large-text .tool-card h3 {
  font-size: 1.22rem;
}

.tools-page.setting-compact-cards .tool-card {
  padding: 0.72rem;
}

.tools-page.setting-compact-cards .tool-description {
  margin-top: 0.3rem;
}

.tools-page.setting-compact-cards .tool-footer {
  padding-top: 0.54rem;
}

.tools-page.workspace-open {
  overflow: hidden;
}

.scroll-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  transform-origin: left center;
  transform: scaleX(0);
  z-index: 100;
  background: linear-gradient(90deg, var(--accent), var(--accent-cool), var(--accent-strong));
  box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.55);
}

.ambient-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle 320px at var(--ambient-x) var(--ambient-y),
      rgba(var(--accent-rgb), 0.2),
      rgba(var(--accent-rgb), 0.12) 32%,
      transparent 70%
    );
  mix-blend-mode: screen;
  opacity: 0.5;
  transition: opacity 0.24s ease;
}

.tools-header {
  position: relative;
  overflow: hidden;
  padding: 0.95rem;
  margin-bottom: 1.05rem;
}

.tools-header::after {
  content: "";
  position: absolute;
  inset: auto -12% -58% auto;
  width: 230px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--ui-header-orb), transparent 68%);
}

.hero-top {
  display: grid;
  gap: 0.08rem;
}

.header-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.17em;
  font-size: 0.66rem;
  color: var(--muted);
}

.tools-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3.2vw, 1.82rem);
  line-height: 1.08;
}

.hero-search {
  margin-top: 0.72rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
}

.hero-search input,
.hero-search select {
  min-height: 2.5rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  color: var(--text);
  padding: 0.54rem 0.66rem;
}

.favorites-toggle {
  min-width: 2.6rem;
  min-height: 2.5rem;
  border-radius: 12px;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.favorites-toggle[aria-pressed="true"] {
  background: linear-gradient(130deg, var(--accent), var(--accent-strong));
  border-color: rgba(var(--accent-rgb), 0.72);
  box-shadow: 0 10px 22px rgba(var(--accent-rgb), 0.36);
  color: #ffffff;
}

.header-metrics {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.52rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.header-metric-card {
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-panel-bg);
  padding: 0.5rem 0.58rem;
  min-height: 72px;
}

.header-metric-card p {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.header-metric-card strong {
  display: block;
  margin-top: 0.22rem;
  font-size: 1.15rem;
  font-weight: 760;
}

.main-menu {
  position: sticky;
  top: 0.55rem;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.56rem;
  margin-bottom: 0.95rem;
  backdrop-filter: blur(10px);
}

.menu-tab {
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-chip-bg);
  color: var(--text);
  padding: 0.58rem 0.38rem;
  border-radius: 999px;
  box-shadow: none;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.menu-tab.menu-tab-action {
  background: var(--ui-input-bg);
}

.menu-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.62);
  box-shadow:
    0 10px 18px rgba(2, 7, 20, 0.28),
    0 0 0 1px rgba(var(--accent-rgb), 0.22);
}

.menu-tab.is-active {
  background: linear-gradient(130deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  border-color: rgba(var(--accent-rgb), 0.72);
  box-shadow: 0 12px 24px rgba(var(--accent-rgb), 0.34);
  animation: tab-breathe 3.2s ease-in-out infinite;
}

.menu-tab:focus-visible {
  border-color: rgba(var(--accent-rgb), 0.76);
  box-shadow:
    0 0 0 2px rgba(var(--accent-rgb), 0.3),
    0 12px 24px rgba(var(--accent-rgb), 0.34);
}

.tools-main {
  display: grid;
  gap: 0.95rem;
}

.panel {
  padding: 1rem;
}

.panel-header h2 {
  margin: 0;
}

.panel-header p {
  margin: 0.38rem 0 0;
  color: var(--muted);
}

.tool-controls {
  margin-top: 0.88rem;
  padding: 0.74rem;
  border-radius: 14px;
  display: grid;
  gap: 0.65rem;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 68%),
    var(--ui-panel-bg);
}

.controls-inline {
  display: grid;
  gap: 0.56rem;
}

.field-row {
  display: grid;
  gap: 0.3rem;
}

.field-row label {
  font-size: 0.9rem;
  color: var(--ui-text-strong);
}

.field-row input,
.field-row select,
.field-row textarea {
  width: 100%;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-input-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 0.56rem 0.66rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.field-row input::placeholder {
  color: var(--muted);
}

.field-row textarea::placeholder {
  color: var(--muted);
}

.field-row input:hover,
.field-row select:hover,
.field-row textarea:hover {
  border-color: rgba(var(--accent-rgb), 0.56);
}

.field-row input:focus-visible,
.field-row select:focus-visible,
.field-row textarea:focus-visible {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.74);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.24);
}

.field-row textarea {
  min-height: 88px;
  resize: vertical;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-panel-bg);
  padding: 0.74rem 0.84rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    transform 0.2s ease;
}

.setting-item:hover {
  border-color: rgba(var(--accent-rgb), 0.54);
  box-shadow:
    0 10px 18px rgba(2, 7, 20, 0.24),
    0 0 0 1px rgba(var(--accent-rgb), 0.2);
}

.setting-item input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.toggle-favorites {
  min-height: 46px;
}

.category-filters {
  display: flex;
  gap: 0.46rem;
  overflow-x: auto;
  overflow-y: visible;
  margin-top: 0.82rem;
  padding: 0.14rem 0.12rem 0.38rem;
  margin-inline: -0.12rem;
  scroll-padding-inline: 0.12rem;
  scrollbar-width: thin;
}

.category-chip {
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-chip-bg);
  color: var(--text);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  white-space: nowrap;
  box-shadow: none;
  padding: 0.44rem 0.94rem;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.category-chip small {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.06rem 0.36rem;
  background: rgba(255, 255, 255, 0.08);
}

.category-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.64);
  box-shadow:
    0 12px 20px rgba(2, 7, 20, 0.28),
    0 0 0 1px rgba(var(--accent-rgb), 0.2);
}

.category-chip.is-active {
  background: linear-gradient(130deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  border-color: rgba(var(--accent-rgb), 0.76);
  box-shadow: 0 12px 24px rgba(var(--accent-rgb), 0.34);
}

.category-chip:focus-visible {
  border-color: rgba(var(--accent-rgb), 0.74);
  box-shadow:
    0 0 0 2px rgba(var(--accent-rgb), 0.3),
    0 12px 24px rgba(var(--accent-rgb), 0.34);
}

.tool-grid {
  margin-top: 0.76rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  align-items: stretch;
}

.tool-results-summary {
  border: 1px solid var(--ui-border-soft);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 70%),
    var(--ui-panel-bg);
  padding: 0.68rem 0.76rem;
}

.tool-results-title {
  margin: 0;
  font-weight: 680;
  color: var(--ui-text-strong);
}

.tool-results-filters {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

.tool-results-filter {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  background: var(--ui-chip-bg);
  color: var(--ui-text-soft);
  font-size: 0.74rem;
  padding: 0.16rem 0.52rem;
}

.tool-category-section {
  border: 1px solid var(--ui-border-soft);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), transparent 72%),
    var(--ui-panel-bg);
  padding: 0.68rem;
}

.tool-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.tool-category-header h3 {
  margin: 0;
  font-size: 1rem;
}

.tool-category-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 1.7rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background: var(--ui-chip-bg);
  color: var(--ui-text-soft);
  font-size: 0.76rem;
  font-weight: 680;
}

.tool-grid.tool-grid-group {
  margin-top: 0.62rem;
}

.tool-card {
  --card-accent: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--ui-border-soft);
  border-radius: 15px;
  overflow: hidden;
  padding: 0.9rem;
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.08), transparent 64%),
    var(--ui-card-bg);
  box-shadow: 0 14px 24px rgba(2, 7, 20, 0.36);
  transition:
    transform 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--card-accent), rgba(255, 255, 255, 0));
}

.tool-card::after {
  content: "";
  position: absolute;
  inset: -120% 40% auto -40%;
  height: 220%;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.16) 48%,
    rgba(255, 255, 255, 0) 82%
  );
  opacity: 0;
  transform: translateX(-30%) rotate(8deg);
  transition:
    opacity 0.32s ease,
    transform 0.4s ease;
  pointer-events: none;
}

.tool-card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow:
    0 22px 36px rgba(2, 7, 20, 0.46),
    0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.tool-card:hover::after {
  opacity: 1;
  transform: translateX(55%) rotate(8deg);
}

.tool-card:focus-within {
  border-color: rgba(var(--accent-rgb), 0.62);
  box-shadow:
    0 22px 36px rgba(2, 7, 20, 0.46),
    0 0 0 2px rgba(var(--accent-rgb), 0.24);
}

.tool-card.cat-rechner {
  --card-accent: var(--accent);
}

.tool-card.cat-mathe-rechner {
  --card-accent: var(--accent);
}

.tool-card.cat-spiele {
  --card-accent: var(--accent-cool);
}

.tool-card.cat-lernen {
  --card-accent: #8b5cf6;
}

.tool-card.cat-tools-text {
  --card-accent: #14b8a6;
}

.tool-card.cat-gesundheit-sport {
  --card-accent: #22c55e;
}

.tool-card.cat-finanzen-budget {
  --card-accent: #eab308;
}

.tool-card.cat-planung-alltag {
  --card-accent: #60a5fa;
}

.tool-card.cat-utilities {
  --card-accent: #14b8a6;
}

.tool-card.cat-gesundheit {
  --card-accent: #22c55e;
}

.tool-card.cat-finanzen {
  --card-accent: #eab308;
}

.tool-card.cat-planung {
  --card-accent: #60a5fa;
}

.tool-card.cat-bildung {
  --card-accent: #8b5cf6;
}

.tool-card.cat-sport {
  --card-accent: #f43f5e;
}

.tool-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.56rem;
}

.tool-card-top.tool-card-top-plain {
  justify-content: flex-end;
}

.tool-meta {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.tool-favorite {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-chip-bg);
  color: rgba(255, 255, 255, 0.84);
  box-shadow: none;
  padding: 0;
  line-height: 1;
  font-size: 0.98rem;
}

.tool-favorite:hover {
  transform: translateY(-1px) scale(1.05);
  border-color: rgba(255, 216, 111, 0.56);
  box-shadow: 0 10px 18px rgba(2, 7, 20, 0.28);
}

.tool-favorite.is-active {
  color: #ffdd72;
  border-color: rgba(255, 221, 114, 0.58);
  background: rgba(255, 179, 102, 0.22);
}

.tool-card h3 {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
}

.tool-card p {
  margin: 0.4rem 0 0;
  color: var(--ui-text-soft);
}

.tool-tags {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tool-tag {
  font-size: 0.71rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.tool-tag.is-favorite {
  color: #ffe4a1;
  border-color: rgba(255, 216, 111, 0.5);
}

.tool-tag.is-recent {
  color: #a8ebff;
  border-color: rgba(56, 189, 248, 0.46);
}

.tool-actions {
  margin-top: auto;
  padding-top: 0.72rem;
}

.tool-open {
  width: 100%;
  justify-content: center;
}

.workspace-hint {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace-hint p {
  margin: 0;
}

.recent-tools {
  margin-top: 0.75rem;
  padding: 0.72rem;
  border-radius: 14px;
}

.recent-title {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 650;
}

.recent-list {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.recent-chip {
  padding: 0.42rem 0.72rem;
}

.smart-strip {
  margin-top: 0.75rem;
}

.empty-state {
  margin: 0.74rem 0 0;
  color: var(--muted);
}

.section-block {
  margin-top: 1.1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--ui-divider);
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
}

.section-title-row h3 {
  margin: 0;
  font-size: 0.98rem;
}

.section-title-row p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.category-filters {
  margin-top: 0.62rem;
  gap: 0.54rem;
  padding: 0.2rem 0.16rem 0.38rem;
}

.category-chip {
  position: relative;
  min-height: 2.5rem;
  padding: 0.56rem 2.2rem 0.56rem 0.86rem;
  align-items: center;
}

.category-chip span {
  font-size: 0.86rem;
  font-weight: 640;
}

.category-chip small {
  position: absolute;
  right: 0.5rem;
  top: 0.32rem;
  margin: 0;
  min-width: 1.2rem;
  min-height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.66rem;
  font-weight: 760;
}

.category-chip.is-active small {
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(255, 255, 255, 0.22);
}

.tool-grid {
  margin-top: 0.62rem;
}

.tool-results-summary {
  border-radius: 12px;
  padding: 0.62rem 0.72rem;
}

.tool-results-title {
  font-size: 0.9rem;
}

.tool-grid.tool-grid-group {
  margin-top: 0.6rem;
  gap: 0.78rem;
  grid-template-columns: 1fr;
}

.tool-card {
  border-radius: 14px;
  padding: 0.74rem 0.78rem;
  min-height: 210px;
}

.tool-card::before {
  width: 3px;
}

.tool-card-top,
.tool-card-top.tool-card-top-plain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: start;
  justify-content: initial;
}

.tool-card h3 {
  margin: 0;
  font-size: 1.03rem;
  line-height: 1.25;
}

.tool-card p {
  margin: 0;
}

.tool-description {
  margin-top: 0.4rem;
  font-size: 0.87rem;
  color: var(--ui-text-soft);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-favorite {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 1rem;
}

.tool-footer {
  margin-top: auto;
  padding-top: 0.7rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.55rem;
}

.tool-usage {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.tool-open {
  width: auto;
  min-height: 2.2rem;
  border-radius: 10px;
  padding: 0.42rem 0.9rem;
}

.recent-tools {
  margin-top: 0.58rem;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.recent-list {
  margin-top: 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  padding-bottom: 0.2rem;
  gap: 0.5rem;
  scroll-snap-type: x proximity;
}

.recent-chip {
  min-width: 148px;
  max-width: 188px;
  border-radius: 12px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-panel-bg);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  padding: 0.52rem 0.58rem;
  scroll-snap-align: start;
}

.recent-chip:hover {
  box-shadow:
    0 10px 18px rgba(2, 7, 20, 0.28),
    0 0 0 1px rgba(var(--accent-rgb), 0.2);
}

.recent-chip-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 680;
  line-height: 1.35;
}

.recent-chip-meta {
  display: block;
  margin-top: 0.16rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.smart-strip {
  margin-top: 0.58rem;
  display: grid;
  gap: 0.62rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.smart-card {
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.07), transparent 68%),
    var(--ui-panel-bg);
  padding: 0.6rem 0.66rem;
  min-height: 104px;
  display: grid;
  gap: 0.14rem;
}

.smart-icon {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-chip-bg);
  font-size: 0.76rem;
  font-weight: 760;
}

.smart-kicker {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.smart-value {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 760;
}

.smart-value.smart-value-small {
  font-size: 0.9rem;
  line-height: 1.34;
}

.smart-note {
  margin: 0;
  font-size: 0.74rem;
  color: var(--ui-text-soft);
}

.workspace-hint {
  margin-top: 0.98rem;
}

.workspace-hint p {
  font-size: 0.84rem;
}

.changelog-list {
  position: relative;
  margin-top: 0.9rem;
  gap: 0.9rem;
}

.changelog-list::before {
  content: "";
  position: absolute;
  left: 0.54rem;
  top: 0.2rem;
  bottom: 0.2rem;
  width: 1px;
  background: var(--ui-divider);
}

.changelog-entry {
  position: relative;
  padding: 0.74rem 0.8rem 0.74rem 1.7rem;
}

.changelog-entry::before {
  content: "";
  position: absolute;
  left: 0.38rem;
  top: 0.95rem;
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}

.changelog-meta {
  font-weight: 760;
  color: var(--ui-text-strong);
}

.changelog-title {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
}

.changelog-details-wrap {
  margin-top: 0.3rem;
}

.changelog-details-wrap summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--accent-cool);
}

.changelog-details-wrap summary::-webkit-details-marker {
  display: none;
}

.changelog-details-wrap[open] summary {
  color: var(--accent);
}

.changelog-details {
  margin: 0.28rem 0 0;
  font-size: 0.84rem;
}

.changelog-more {
  margin-top: 0.72rem;
  display: flex;
  justify-content: flex-start;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 74;
  display: grid;
  place-items: center;
  padding: max(0.7rem, env(safe-area-inset-top))
    max(0.7rem, env(safe-area-inset-right))
    max(0.7rem, env(safe-area-inset-bottom))
    max(0.7rem, env(safe-area-inset-left));
}

.settings-overlay[hidden] {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 20, 0.62);
  backdrop-filter: blur(6px);
}

.settings-sheet {
  position: relative;
  width: min(900px, calc(100vw - 1.2rem));
  max-height: min(88vh, 920px);
  overflow: auto;
  border-radius: 16px;
  padding: 0.9rem;
}

.settings-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.settings-sheet-header h2 {
  margin: 0;
}

.settings-sheet-text {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.reveal-on-scroll {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.42s ease,
    transform 0.42s ease;
}

.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tools-page.setting-reduced-motion *,
.tools-page.setting-reduced-motion *::before,
.tools-page.setting-reduced-motion *::after {
  animation: none !important;
  transition-duration: 0.01ms !important;
}

.tools-page.setting-reduced-motion .ambient-glow {
  opacity: 0;
}

.tool-workspace {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: grid;
  align-items: center;
  justify-items: center;
  padding:
    max(0.52rem, env(safe-area-inset-top))
    max(0.52rem, env(safe-area-inset-right))
    max(0.52rem, env(safe-area-inset-bottom))
    max(0.52rem, env(safe-area-inset-left));
  background: rgba(2, 8, 20, 0.64);
  backdrop-filter: blur(8px);
  animation: overlay-in 0.22s ease both;
}

.tool-workspace[hidden] {
  display: none;
}

.tool-dialog {
  width: min(1360px, calc(100vw - 1rem));
  max-height: min(90vh, 960px);
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 34px 62px rgba(2, 7, 20, 0.66),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  animation: workspace-pop 0.28s cubic-bezier(0.22, 0.74, 0.24, 1.02) both;
}

.workspace-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: start;
  padding: 0.72rem 0.86rem;
  border-bottom: 1px solid var(--ui-divider);
  background:
    linear-gradient(130deg, rgba(255, 255, 255, 0.08), transparent 68%),
    var(--ui-panel-bg);
}

.window-controls {
  display: flex;
  align-items: center;
  padding-top: 0.16rem;
}

.window-close {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #de4942;
  padding: 0;
  background: linear-gradient(145deg, #ff6c63, #ff5f57);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 0 1px rgba(88, 21, 16, 0.08);
  position: relative;
}

.window-close::before,
.window-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 1.5px;
  border-radius: 2px;
  background: rgba(82, 18, 14, 0.88);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.window-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.window-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.window-close:hover,
.window-close:focus-visible {
  transform: none;
  filter: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 0 1px rgba(88, 21, 16, 0.08);
}

.window-close:hover::before,
.window-close:hover::after,
.window-close:focus-visible::before,
.window-close:focus-visible::after {
  opacity: 1;
}

.window-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.42);
  outline-offset: 1px;
}

.workspace-title-wrap h3 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.1;
}

.workspace-title-wrap p {
  margin: 0.24rem 0 0;
  color: var(--muted);
}

.workspace-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-chip-bg);
  color: var(--ui-text-soft);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.workspace-content {
  padding: 0.85rem 0.88rem 0.95rem;
  overflow: auto;
  overscroll-behavior: contain;
}

.workspace-form {
  display: grid;
  gap: 0.64rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.46rem;
  align-items: center;
}

.tool-output {
  margin: 0.7rem 0 0;
  min-height: 1.4rem;
  font-weight: 600;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  padding: 0.52rem 0.7rem;
}

.tool-output:empty {
  padding: 0;
  border: 0;
  min-height: 0;
}

.tool-output.is-pop {
  animation: output-pop 0.26s ease both;
}

.tool-output.is-error {
  color: #ffc4c4;
  border-color: rgba(255, 129, 129, 0.56);
  background: rgba(96, 30, 30, 0.36);
}

.tool-output.is-success {
  color: #bcffe9;
  border-color: rgba(45, 212, 191, 0.52);
  background: rgba(24, 95, 84, 0.32);
}

.tool-visual-block {
  margin-top: 0.72rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 14px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 70%),
    var(--ui-panel-bg);
  padding: 0.72rem;
}

.visual-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.number-reel {
  margin-top: 0.5rem;
  min-height: 3.1rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  display: grid;
  place-items: center;
  font-size: clamp(1.9rem, 8vw, 2.4rem);
  font-weight: 760;
  letter-spacing: 0.04em;
  color: #d8f3ff;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.34);
}

.number-reel.is-rolling {
  animation: reel-jitter 0.12s linear infinite;
}

.reaction-zone {
  margin-top: 0.42rem;
  width: 100%;
  min-height: 120px;
  border-radius: 14px;
  border: 1px solid var(--ui-border-soft);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.08), transparent 70%),
    var(--ui-input-bg);
  color: var(--ui-text-soft);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 24px rgba(2, 7, 20, 0.32);
  transition:
    transform 0.18s ease,
    box-shadow 0.22s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.reaction-zone:disabled {
  opacity: 1;
}

.reaction-zone.is-go {
  border-color: rgba(34, 197, 94, 0.64);
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(145deg, rgba(34, 197, 94, 0.32), rgba(16, 185, 129, 0.24)),
    var(--ui-input-bg);
  color: #f0fff7;
  box-shadow:
    0 16px 28px rgba(2, 7, 20, 0.34),
    0 0 0 1px rgba(34, 197, 94, 0.24);
  animation: reaction-pulse 0.9s ease-in-out infinite;
}

.reaction-zone.is-early {
  border-color: rgba(248, 113, 113, 0.6);
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(145deg, rgba(248, 113, 113, 0.28), rgba(239, 68, 68, 0.2)),
    var(--ui-input-bg);
}

.dice-visual {
  margin-top: 0.5rem;
  min-height: 158px;
  display: grid;
  place-items: center;
}

.dice-d6 {
  width: 130px;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04)),
    var(--ui-input-bg);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.66rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 20px 30px rgba(2, 7, 20, 0.36);
}

.dice-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  place-self: center;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transform: scale(0.6);
  opacity: 0.3;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    background-color 0.18s ease;
}

.dice-dot.is-active {
  background: linear-gradient(145deg, #f7fcff, #9fe8ff);
  box-shadow:
    0 0 0 1px rgba(159, 232, 255, 0.28),
    0 0 10px rgba(56, 189, 248, 0.46);
  transform: scale(1);
  opacity: 1;
}

.dice-poly {
  --dice-poly-sides: 20;
  width: 138px;
  height: 138px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  background:
    radial-gradient(circle at 25% 18%, rgba(255, 255, 255, 0.28), transparent 42%),
    linear-gradient(145deg, rgba(56, 189, 248, 0.2), rgba(14, 165, 233, 0.08)),
    var(--ui-input-bg);
  border: 1px solid rgba(56, 189, 248, 0.44);
  clip-path: polygon(50% 1%, 90% 22%, 99% 62%, 74% 97%, 26% 97%, 1% 62%, 10% 22%);
  box-shadow: 0 20px 30px rgba(2, 7, 20, 0.36);
}

.dice-poly strong {
  color: #d6edff;
  font-size: 2rem;
  font-weight: 760;
  text-shadow: 0 0 18px rgba(14, 165, 233, 0.42);
}

.dice-poly small {
  color: #a8dcff;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dice-visual.is-rolling .dice-d6,
.dice-visual.is-rolling .dice-poly {
  animation: dice-roll 0.72s cubic-bezier(0.22, 0.79, 0.26, 1.02) both;
}

.dice-last-roll {
  margin: 0.46rem 0 0;
  text-align: center;
  color: var(--ui-text-soft);
  font-weight: 640;
}

.dice-history {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
}

.dice-history-item {
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  background: var(--ui-chip-bg);
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  color: var(--ui-text-soft);
}

.dice-history-item.is-empty {
  opacity: 0.78;
}

.dice-distribution {
  margin-top: 0.52rem;
  display: grid;
  gap: 0.32rem;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
}

.dice-dist-cell {
  border: 1px solid var(--ui-border-soft);
  border-radius: 10px;
  background: var(--ui-input-bg);
  padding: 0.28rem 0.34rem;
  display: grid;
  gap: 0.2rem;
}

.dice-dist-cell small {
  color: var(--muted);
  font-size: 0.72rem;
}

.dice-dist-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.dice-dist-fill {
  --dist-ratio: 0;
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--dist-ratio));
  background: linear-gradient(90deg, var(--accent-cool), var(--accent), var(--accent-strong));
}

.dice-dist-cell strong {
  font-size: 0.78rem;
  color: var(--text);
}

.coin-stage {
  margin-top: 0.5rem;
  min-height: 180px;
  display: grid;
  place-items: center;
  perspective: 1000px;
}

.coin-visual {
  position: relative;
  width: 142px;
  height: 142px;
  border-radius: 50%;
  transform-style: preserve-3d;
  transition: transform 1.45s cubic-bezier(0.2, 0.82, 0.2, 1);
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 760;
  letter-spacing: 0.02em;
  backface-visibility: hidden;
  border: 1px solid rgba(255, 217, 121, 0.58);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    0 20px 28px rgba(2, 7, 20, 0.36);
}

.coin-front {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.45), transparent 38%),
    linear-gradient(155deg, #f8d26d, #d08a2f);
  color: #5f3b0c;
}

.coin-back {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.44), transparent 38%),
    linear-gradient(155deg, #f8bc63, #c87524);
  color: #5f2f08;
  transform: rotateY(180deg);
}

.coin-visual.is-flipping {
  filter: drop-shadow(0 12px 16px rgba(2, 7, 20, 0.42));
}

.wheel-stage {
  margin-top: 0.54rem;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 290px;
}

.fortune-wheel {
  position: relative;
  width: min(80vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    inset 0 0 0 6px rgba(7, 15, 30, 0.26),
    0 28px 36px rgba(2, 7, 20, 0.44);
  transform: rotate(0deg);
}

.fortune-wheel.is-spinning {
  filter: saturate(1.08) contrast(1.04);
}

.wheel-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.wheel-label {
  --wheel-label-rotate: 0deg;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(var(--wheel-label-rotate))
    translateY(calc(-1 * (min(40vw, 150px) - 30px))) rotate(calc(-1 * var(--wheel-label-rotate)));
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(7, 14, 30, 0.86);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  text-align: center;
  max-width: 72px;
}

.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.03em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.22), transparent 50%),
    linear-gradient(145deg, var(--accent), var(--accent-strong));
}

.wheel-pointer {
  position: absolute;
  top: 12px;
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 24px solid rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 4px 6px rgba(2, 7, 20, 0.35));
  z-index: 2;
}

.wheel-result {
  margin: 0.45rem 0 0;
  text-align: center;
  color: var(--ui-text-soft);
  font-weight: 650;
}

.timer-visual {
  margin-top: 0.5rem;
  position: relative;
  width: 200px;
  aspect-ratio: 1 / 1;
  margin-inline: auto;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track,
.timer-progress {
  fill: none;
  stroke-width: 8;
}

.timer-track {
  stroke: rgba(255, 255, 255, 0.1);
}

.timer-progress {
  stroke: url(#timer-gradient);
  stroke: var(--accent-cool);
  stroke-linecap: round;
  stroke-dasharray: 339.29;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.24s linear;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.36));
}

.timer-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 1.7rem;
  font-weight: 740;
  letter-spacing: 0.02em;
}

.timer-time.is-running {
  animation: timer-pulse 1.4s ease-in-out infinite;
}

.countdown-progress {
  margin-top: 0.5rem;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-input-bg);
  overflow: hidden;
}

.countdown-progress-fill {
  --progress: 0;
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(var(--progress));
  background: linear-gradient(90deg, var(--accent-cool), var(--accent), var(--accent-strong));
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.4);
  transition: transform 0.42s ease;
}

.countdown-live {
  margin: 0.5rem 0 0;
  text-align: center;
  font-weight: 650;
  color: var(--ui-text-soft);
}

.countdown-live.is-done {
  color: #bcffe9;
}

.hydration-glass {
  margin-top: 0.5rem;
  width: 132px;
  height: 198px;
  margin-inline: auto;
  border-radius: 16px 16px 22px 22px;
  border: 1px solid rgba(var(--accent-rgb), 0.44);
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    0 20px 30px rgba(2, 7, 20, 0.34);
  position: relative;
  overflow: hidden;
}

.hydration-water {
  --fill-ratio: 0;
  position: absolute;
  inset: auto 0 0 0;
  height: calc(min(1.2, var(--fill-ratio)) * 100%);
  background: linear-gradient(180deg, rgba(74, 197, 255, 0.82), rgba(28, 127, 234, 0.82));
  transition: height 0.65s cubic-bezier(0.2, 0.85, 0.24, 1);
}

.hydration-wave {
  position: absolute;
  inset: -14px -30px auto;
  height: 24px;
  background:
    radial-gradient(circle at 8px 12px, rgba(255, 255, 255, 0.55) 8px, transparent 9px) 0 0 /
      32px 24px repeat-x;
  opacity: 0.55;
  animation: wave-flow 2s linear infinite;
}

.hydration-percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 760;
  color: #ecfbff;
  text-shadow: 0 1px 10px rgba(6, 20, 39, 0.38);
}

.tool-source {
  margin: 0.5rem 0 0;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
  opacity: 0.9;
}

.tool-source-prefix {
  color: var(--ui-text-soft);
  font-weight: 650;
  letter-spacing: 0.03em;
}

.tool-source-note {
  color: var(--ui-text-soft);
}

.tool-source a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed rgba(var(--accent-rgb), 0.44);
}

.tool-source a:hover,
.tool-source a:focus-visible {
  color: #ffffff;
  border-bottom-color: rgba(var(--accent-rgb), 0.78);
}

.bmi-form .action-row,
.bmi-form .bmi-results {
  grid-column: 1 / -1;
}

.bmi-results,
.detail-results {
  border: 1px solid var(--ui-border-soft);
  border-radius: 14px;
  background:
    linear-gradient(156deg, rgba(255, 255, 255, 0.07), transparent 70%),
    var(--ui-panel-bg);
  padding: 0.72rem;
}

.bmi-results h4,
.detail-results h4 {
  margin: 0;
}

.bmi-grid,
.detail-grid {
  margin-top: 0.58rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0.55rem;
}

.bmi-metric,
.detail-card {
  border: 1px solid var(--ui-border-soft);
  border-radius: 11px;
  background: var(--ui-input-bg);
  padding: 0.5rem 0.56rem;
}

.metric-kicker,
.detail-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.metric-value,
.detail-value {
  margin: 0.18rem 0 0;
  font-size: 1.06rem;
  font-weight: 700;
}

.metric-value.metric-low {
  color: #93c5fd;
}

.metric-value.metric-normal {
  color: #6ee7b7;
}

.metric-value.metric-high {
  color: #fbbf24;
}

.metric-value.metric-very-high {
  color: #fca5a5;
}

.metric-detail,
.detail-hint {
  margin: 0.2rem 0 0;
  color: var(--ui-text-soft);
  font-size: 0.84rem;
}

.bmi-note,
.detail-note {
  margin: 0.62rem 0 0;
  color: var(--ui-text-soft);
  font-size: 0.9rem;
}

.bmi-scale {
  margin-top: 0.62rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  padding: 0.56rem;
}

.bmi-scale-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    rgba(147, 197, 253, 0.8) 0% 23.2%,
    rgba(110, 231, 183, 0.8) 23.2% 46.1%,
    rgba(251, 191, 36, 0.8) 46.1% 64.3%,
    rgba(252, 165, 165, 0.8) 64.3% 100%
  );
}

.bmi-scale-healthy {
  --healthy-start: 0%;
  --healthy-width: 0%;
  position: absolute;
  top: -2px;
  left: var(--healthy-start);
  height: calc(100% + 4px);
  width: var(--healthy-width);
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 1px rgba(7, 14, 20, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.34);
}

.bmi-scale-marker {
  --bmi-pos: 50%;
  position: absolute;
  left: var(--bmi-pos);
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 2.2rem;
  min-height: 1.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.42rem;
  font-size: 0.74rem;
  font-weight: 760;
  border: 1px solid rgba(7, 14, 20, 0.3);
  background: rgba(7, 14, 20, 0.82);
  color: #ffffff;
}

.bmi-scale-legend {
  margin-top: 0.44rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.34rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.bmi-scale-legend span:nth-child(2),
.bmi-scale-legend span:nth-child(3) {
  text-align: center;
}

.bmi-scale-legend span:last-child {
  text-align: right;
}

.metric-form .action-row,
.metric-form .detail-results,
.grade-form .action-row,
.grade-form .detail-results {
  grid-column: 1 / -1;
}

.grade-form {
  gap: 0.74rem;
}

.grade-row {
  display: grid;
  gap: 0.64rem;
}

.macro-bars {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.4rem;
}

.macro-row {
  border: 1px solid var(--ui-border-soft);
  border-radius: 11px;
  background: var(--ui-input-bg);
  padding: 0.44rem 0.52rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.45rem;
  align-items: center;
}

.macro-row p,
.macro-row strong {
  margin: 0;
}

.macro-row strong {
  font-size: 0.82rem;
  color: var(--ui-text-soft);
}

.macro-fill {
  --macro-ratio: 0;
  grid-column: 1 / -1;
  display: block;
  position: relative;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.macro-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--macro-ratio));
  background: linear-gradient(90deg, var(--accent-cool), var(--accent), var(--accent-strong));
}

.macro-row.protein .macro-fill::before {
  background: linear-gradient(90deg, #60a5fa, #38bdf8);
}

.macro-row.carbs .macro-fill::before {
  background: linear-gradient(90deg, #a78bfa, #8b5cf6);
}

.macro-row.fats .macro-fill::before {
  background: linear-gradient(90deg, #f59e0b, #f97316);
}

.heart-zones {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.45rem;
}

.heart-zone-card {
  border: 1px solid var(--ui-border-soft);
  border-radius: 11px;
  background: var(--ui-input-bg);
  padding: 0.42rem 0.5rem;
  display: grid;
  gap: 0.24rem;
}

.heart-zone-kicker {
  margin: 0;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.heart-zone-range {
  margin: 0;
  font-weight: 680;
  color: var(--text);
}

.heart-zone-bar {
  position: relative;
  display: block;
  height: 9px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.24);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.heart-zone-fill {
  --zone-ratio: 0;
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--zone-ratio));
  background: linear-gradient(90deg, #34d399, #22c55e, #f59e0b, #f97316, #ef4444);
}

.work-progress {
  margin-top: 0.5rem;
  position: relative;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: var(--ui-input-bg);
  overflow: hidden;
}

.work-progress-fill {
  --work-ratio: 0;
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--work-ratio));
  background: linear-gradient(90deg, var(--accent-cool), var(--accent), var(--accent-strong));
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.34);
  transition: transform 0.34s ease;
}

.fuel-gauge {
  margin-top: 0.5rem;
  height: 50px;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  position: relative;
  overflow: hidden;
}

.fuel-gauge-fill {
  --fuel-ratio: 0;
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--fuel-ratio));
  background:
    linear-gradient(90deg, rgba(45, 212, 191, 0.85), rgba(56, 189, 248, 0.9), rgba(59, 130, 246, 0.85));
  transition: transform 0.38s ease;
}

.fuel-gauge-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #eff8ff;
  font-size: 1rem;
  font-weight: 760;
  text-shadow: 0 1px 8px rgba(2, 7, 20, 0.42);
}

.setting-group {
  min-inline-size: 0;
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-panel-bg);
  margin: 0;
  padding: 0.7rem;
}

.setting-group legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.color-mode-grid {
  display: grid;
  gap: 0.54rem;
}

.color-mode-option {
  display: block;
  position: relative;
  cursor: pointer;
}

.color-mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-mode-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 11px;
  background: var(--ui-input-bg);
  padding: 0.6rem 0.64rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.color-mode-option:hover .color-mode-preview {
  border-color: rgba(var(--accent-rgb), 0.58);
  box-shadow:
    0 10px 20px rgba(2, 7, 20, 0.26),
    0 0 0 1px rgba(var(--accent-rgb), 0.2);
  transform: translateY(-1px);
}

.mode-copy {
  display: grid;
  gap: 0.15rem;
}

.mode-copy small {
  color: var(--muted);
}

.mode-swatch {
  width: 54px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.mode-swatch.mode-dark {
  background: linear-gradient(120deg, #111827, #374151);
}

.mode-swatch.mode-light {
  background: linear-gradient(120deg, #ffffff, #dbe4ef);
}

.mode-swatch.mode-nocturne {
  background: linear-gradient(120deg, #0c1a34, #ff8a3d);
}

.mode-swatch.mode-sunset {
  background: linear-gradient(120deg, #4a1821, #ff7a45);
}

.mode-swatch.mode-forest {
  background: linear-gradient(120deg, #0f2a1f, #33b87a);
}

.mode-swatch.mode-lagoon {
  background: linear-gradient(120deg, #0d2347, #38bdf8);
}

.color-mode-option input:checked + .color-mode-preview {
  border-color: rgba(var(--accent-rgb), 0.82);
  box-shadow:
    0 0 0 2px rgba(var(--accent-rgb), 0.34),
    0 12px 24px rgba(var(--accent-rgb), 0.18);
}

.color-mode-option input:checked + .color-mode-preview .mode-swatch {
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.62),
    0 0 0 4px rgba(var(--accent-rgb), 0.13);
}

.color-mode-option input:focus-visible + .color-mode-preview {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.settings-form {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.6rem;
}

.changelog-list {
  list-style: none;
  padding: 0;
}

.changelog-entry {
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-panel-bg);
}

.changelog-meta {
  margin: 0;
  font-size: 0.86rem;
}

.changelog-title {
  font-weight: 700;
}

.changelog-details {
  color: var(--ui-text-soft);
}

.changelog-warning {
  margin: 0.36rem 0 0;
  color: #ffc4c4;
  font-size: 0.84rem;
}

.snake-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.snake-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 1.9rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  padding: 0.2rem 0.64rem;
  background: var(--ui-chip-bg);
  color: var(--ui-text-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.snake-stat strong {
  color: var(--text);
}

.snake-grid {
  --snake-grid-size: 16;
  width: min(92vw, 360px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(var(--snake-grid-size), minmax(0, 1fr));
  gap: 2px;
  padding: 0.36rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  touch-action: none;
  user-select: none;
}

.snake-cell {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.snake-cell.is-snake {
  background: rgba(45, 212, 191, 0.7);
}

.snake-cell.is-head {
  background: rgba(56, 189, 248, 0.95);
}

.snake-cell.is-food {
  background: rgba(248, 113, 113, 0.96);
}

.snake-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 54px));
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 0.42rem;
  width: max-content;
}

.snake-control[data-snake-direction="up"] {
  grid-area: up;
}

.snake-control[data-snake-direction="left"] {
  grid-area: left;
}

.snake-control[data-snake-direction="down"] {
  grid-area: down;
}

.snake-control[data-snake-direction="right"] {
  grid-area: right;
}

.snake-control {
  min-height: 2.4rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 10px;
  background: var(--ui-input-bg);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: none;
}

.tictactoe-board {
  margin-top: 0.5rem;
  max-width: 320px;
  display: grid;
  gap: 0.42rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tictactoe-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--ui-border-soft);
  border-radius: 11px;
  background: var(--ui-input-bg);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: none;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.tictactoe-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.58);
  box-shadow: 0 8px 16px rgba(2, 7, 20, 0.26);
}

.tictactoe-cell:disabled {
  cursor: default;
  opacity: 0.9;
}

.tictactoe-status {
  margin: 0;
  font-weight: 600;
}

.typing-headline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.typing-stat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.9rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 999px;
  padding: 0.2rem 0.64rem;
  background: var(--ui-chip-bg);
  color: var(--ui-text-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.typing-text-display,
.typing-ghost {
  margin: 0;
  min-height: 3.2rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  padding: 0.62rem 0.7rem;
  font-family: "SF Mono", "SFMono-Regular", Menlo, Monaco, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.typing-target,
.sprint-word,
.memory-sequence-display {
  margin: 0;
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-input-bg);
  padding: 0.58rem 0.68rem;
  font-weight: 700;
  text-align: center;
}

.typing-target {
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.typing-char {
  transition: color 0.12s ease, background-color 0.12s ease;
}

.typing-char.is-correct {
  color: #86efac;
}

.typing-char.is-wrong {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.2);
  border-radius: 4px;
}

.typing-char.is-current {
  color: #fde68a;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.finger-hints {
  border: 1px solid var(--ui-border-soft);
  border-radius: 12px;
  background: var(--ui-panel-bg);
  padding: 0.58rem 0.66rem;
  color: var(--ui-text-soft);
  font-size: 0.88rem;
}

.finger-hints p {
  margin: 0.22rem 0 0;
}

.finger-hints p:first-child {
  margin-top: 0;
}

.sprint-word {
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.memory-sequence-display {
  font-size: clamp(1.35rem, 4.4vw, 1.8rem);
  letter-spacing: 0.15em;
  font-family: "SF Mono", "SFMono-Regular", Menlo, Monaco, "Courier New", monospace;
}

.memory-sequence-display.is-reveal {
  animation: memory-pop 0.46s ease both;
}

.tools-footer {
  margin-top: 1.42rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.back-link {
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes workspace-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes output-pop {
  from {
    opacity: 0.5;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reel-jitter {
  0% {
    transform: translateY(0) scale(1);
  }

  25% {
    transform: translateY(-1px) scale(1.02);
  }

  50% {
    transform: translateY(1px) scale(0.99);
  }

  75% {
    transform: translateY(-1px) scale(1.01);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes dice-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }

  45% {
    transform: rotate(-8deg) scale(0.95);
  }

  70% {
    transform: rotate(8deg) scale(1.03);
  }

  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes timer-pulse {
  0%,
  100% {
    text-shadow: 0 0 0 rgba(var(--accent-rgb), 0);
  }

  50% {
    text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.36);
  }
}

@keyframes wave-flow {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(32px);
  }
}

@keyframes reaction-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 16px 28px rgba(2, 7, 20, 0.34),
      0 0 0 1px rgba(34, 197, 94, 0.24);
  }

  50% {
    transform: scale(1.01);
    box-shadow:
      0 18px 30px rgba(2, 7, 20, 0.34),
      0 0 0 2px rgba(34, 197, 94, 0.34);
  }
}

@keyframes pill-bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

@keyframes tab-breathe {
  0%,
  100% {
    box-shadow: 0 12px 24px rgba(var(--accent-rgb), 0.26);
  }

  50% {
    box-shadow: 0 16px 30px rgba(var(--accent-rgb), 0.4);
  }
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.42);
  }

  100% {
    box-shadow: 0 0 0 8px rgba(45, 212, 191, 0);
  }
}

@keyframes memory-pop {
  from {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
  }

  to {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
  }
}

@media (max-width: 639px) {
  .hero-search {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "search favorite"
      "sort favorite";
  }

  .hero-search input {
    grid-area: search;
  }

  .hero-search select {
    grid-area: sort;
  }

  .favorites-toggle {
    grid-area: favorite;
    align-self: stretch;
    min-height: 100%;
  }

  .header-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-metric-card:last-child {
    grid-column: 1 / -1;
  }

  .smart-strip {
    grid-template-columns: 1fr;
  }

  .menu-tab {
    min-height: 2.5rem;
    padding-inline: 0.48rem;
  }
}

@media (min-width: 640px) {
  .tools-header,
  .panel {
    padding: 1.2rem;
  }

  .color-mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-grid.tool-grid-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-workspace {
    align-items: center;
    padding: 0.8rem;
  }

  .tool-dialog {
    max-width: min(1240px, calc(100vw - 2rem));
    margin: 0 auto;
  }

}

@media (min-width: 900px) {
  .smart-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-grid.tool-grid-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bmi-form,
  .metric-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grade-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .tools-page .page-shell {
    width: min(1780px, calc(100% - 2.6rem));
  }
}

@media (min-width: 1480px) {
  .tool-grid.tool-grid-group {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-dialog {
    max-width: min(1360px, calc(100vw - 2.6rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-workspace,
  .tool-dialog,
  .tool-output.is-pop,
  .reveal-on-scroll {
    animation: none !important;
    transition: none !important;
  }

  .reveal-on-scroll {
    opacity: 1;
    transform: none;
  }
}

/* UX refresh overrides */

.tools-page .page-shell {
  width: min(1700px, calc(100% - 1rem));
}

.tools-header {
  display: grid;
  gap: 1rem;
  padding: 1.05rem;
}

.hero-copy {
  display: grid;
  gap: 0.55rem;
}

.tools-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  line-height: 1.05;
}

.hero-lead {
  margin: 0;
  max-width: 54rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ui-text-soft);
}

.hero-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ui-text-soft);
  font-size: 0.82rem;
}

.hero-story-grid {
  display: grid;
  gap: 0.65rem;
}

.hero-story-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ui-border-soft);
  border-radius: 18px;
  padding: 0.9rem 0.95rem;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 70%),
    rgba(255, 255, 255, 0.04);
  box-shadow: 0 18px 30px rgba(2, 7, 20, 0.2);
}

.hero-story-card::after {
  content: "";
  position: absolute;
  inset: auto -12% -55% auto;
  width: 150px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18), transparent 72%);
  pointer-events: none;
}

.hero-story-kicker,
.hero-spotlight-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent-cool);
}

.hero-story-card strong {
  display: block;
  margin-top: 0.34rem;
  font-size: 1rem;
  line-height: 1.25;
}

.hero-story-card span {
  display: block;
  margin-top: 0.35rem;
  color: var(--ui-text-soft);
  line-height: 1.55;
}

.hero-spotlight {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 22px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.09), transparent 70%),
    linear-gradient(150deg, rgba(var(--accent-rgb), 0.15), transparent 58%),
    var(--ui-card-bg);
}

.hero-spotlight::before {
  content: "";
  position: absolute;
  inset: -30% auto auto 60%;
  width: 220px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

.hero-spotlight > * {
  position: relative;
  z-index: 1;
}

.hero-spotlight h2 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
}

.hero-spotlight-copy {
  margin: 0;
  color: var(--ui-text-soft);
  line-height: 1.6;
}

.hero-jump-grid {
  display: grid;
  gap: 0.52rem;
}

.hero-jump-button {
  justify-content: flex-start;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.1), transparent 70%),
    rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

.hero-jump-button:hover,
.hero-jump-button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.62);
  box-shadow:
    0 16px 28px rgba(2, 7, 20, 0.28),
    0 0 0 1px rgba(var(--accent-rgb), 0.16);
}

.hero-spotlight-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ui-text-soft);
  display: grid;
  gap: 0.38rem;
}

.hero-search {
  margin-top: 0;
  padding: 0.85rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 16px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.05), transparent 68%),
    var(--ui-panel-bg);
}

.hero-search input,
.hero-search select,
.favorites-toggle {
  min-height: 2.85rem;
}

.favorites-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  padding-inline: 0.9rem;
  font-size: 0.9rem;
}

.header-metrics {
  margin-top: 0;
}

.header-metric-card {
  min-height: 86px;
  padding: 0.72rem 0.8rem;
  display: grid;
  align-content: start;
  gap: 0.18rem;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 72%),
    var(--ui-panel-bg);
  box-shadow: 0 16px 28px rgba(2, 7, 20, 0.22);
}

.header-metric-card span {
  font-size: 0.78rem;
  color: var(--ui-text-soft);
}

.main-menu {
  top: 0.65rem;
}

.panel-header {
  display: grid;
  gap: 0.35rem;
}

.panel-header p {
  max-width: 52rem;
}

.section-title-row > div {
  display: grid;
  gap: 0.15rem;
}

.section-title-row h3 {
  font-size: 1.04rem;
}

.featured-tools {
  margin-top: 0.72rem;
  display: grid;
  gap: 0.78rem;
}

.featured-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ui-border-soft);
  border-radius: 16px;
  padding: 0.9rem;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 68%),
    var(--ui-card-bg);
  box-shadow: 0 18px 28px rgba(2, 7, 20, 0.26);
}

.featured-card::after {
  content: "";
  position: absolute;
  inset: auto -18% -55% auto;
  width: 160px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18), transparent 74%);
  pointer-events: none;
}

.featured-card-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent-cool);
}

.featured-card h4 {
  margin: 0.36rem 0 0;
  font-size: 1.1rem;
}

.featured-card p:last-of-type {
  margin: 0.42rem 0 0;
  color: var(--ui-text-soft);
}

.featured-open {
  margin-top: 0.72rem;
  min-height: 2.4rem;
}

.smart-strip {
  margin-top: 0.72rem;
}

.category-filters {
  margin-top: 0.72rem;
}

.tool-results-summary {
  padding: 0.76rem 0.84rem;
}

.tool-results-title {
  font-size: 0.95rem;
}

.tool-grid.tool-grid-group {
  gap: 0.9rem;
}

.tool-card {
  min-height: 224px;
  padding: 0.92rem;
  border-radius: 20px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.11), transparent 62%),
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.06), transparent 54%),
    var(--ui-card-bg);
}

.tool-card-heading {
  min-width: 0;
}

.tool-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tool-meta {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
}

.tool-flag {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.08rem 0.46rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--ui-text-strong);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-card-signals {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

.tool-signal {
  display: inline-flex;
  align-items: center;
  min-height: 1.4rem;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ui-text-soft);
  font-size: 0.7rem;
  font-weight: 680;
}

.tool-signal.is-featured {
  border-color: rgba(var(--accent-rgb), 0.42);
  color: var(--ui-text-strong);
  background: rgba(var(--accent-rgb), 0.14);
}

.tool-signal.is-favorite {
  border-color: rgba(255, 221, 114, 0.52);
  color: #ffe4a1;
  background: rgba(255, 179, 102, 0.14);
}

.tool-signal.is-recent {
  border-color: rgba(56, 189, 248, 0.46);
  color: #b9efff;
  background: rgba(56, 189, 248, 0.1);
}

.tool-signal.is-used {
  border-color: rgba(255, 255, 255, 0.14);
}

.tool-card h3 {
  margin-top: 0.28rem;
  font-size: 1.12rem;
  line-height: 1.2;
}

.tool-description {
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 4.4em;
}

.tool-footer {
  display: grid;
  gap: 0.55rem;
  align-items: end;
}

.tool-usage {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ui-text-soft);
}

.tool-footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.tool-open {
  width: auto;
  min-width: 8.75rem;
  padding-inline: 1rem;
}

.tool-open::after {
  content: "↗";
  margin-left: 0.45rem;
  font-size: 0.92em;
}

.tool-footnote {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: right;
}

.workspace-hint {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--ui-border-soft);
  border-radius: 14px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.06), transparent 68%),
    var(--ui-panel-bg);
}

.workspace-hint p {
  color: var(--ui-text-soft);
}

.tools-page [inert] {
  pointer-events: none;
  user-select: none;
}

@media (max-width: 639px) {
  .tools-header {
    padding: 0.95rem;
  }

  .hero-search {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "search"
      "sort"
      "favorite";
  }

  .hero-search input {
    grid-area: search;
  }

  .hero-search select {
    grid-area: sort;
  }

  .favorites-toggle {
    grid-area: favorite;
    width: 100%;
  }

  .featured-tools,
  .smart-strip,
  .tool-grid.tool-grid-group,
  .hero-story-grid {
    grid-template-columns: 1fr;
  }

  .tool-footer-main {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-open {
    width: 100%;
  }

  .tool-footnote {
    text-align: left;
  }
}

@media (min-width: 640px) {
  .featured-tools,
  .hero-story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .tools-header {
    grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.95fr);
    align-items: start;
  }

  .hero-copy {
    grid-column: 1;
  }

  .hero-spotlight {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
  }

  .hero-search {
    grid-column: 1;
  }

  .header-metrics {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1180px) {
  .hero-story-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Declutter redesign */

.tools-page {
  background:
    radial-gradient(circle at top, rgba(var(--accent-rgb), 0.08), transparent 30%),
    linear-gradient(180deg, rgba(4, 10, 22, 0.98), rgba(7, 16, 31, 1));
}

.ambient-glow {
  opacity: 0.24;
}

.tools-page .page-shell {
  width: min(1480px, calc(100% - 1.5rem));
}

.tools-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.3rem;
  border-radius: 26px;
}

.tools-header::after {
  width: 180px;
  inset: auto -8% -44% auto;
  opacity: 0.7;
}

.tools-header-main {
  display: grid;
  gap: 1rem;
}

.hero-copy {
  gap: 0.75rem;
}

.header-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

.tools-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
  max-width: 15ch;
}

.hero-lead {
  max-width: 54rem;
  font-size: 1.02rem;
  line-height: 1.7;
}

.hero-meta-list {
  gap: 0.45rem;
}

.hero-meta-chip {
  min-height: 1.9rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.045);
}

.hero-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.58rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--ui-border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.hero-link:hover,
.hero-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.54);
  background: rgba(var(--accent-rgb), 0.12);
}

.hero-link-button {
  font: inherit;
  cursor: pointer;
}

.header-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0;
}

.header-metric-card {
  min-height: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 70%),
    rgba(255, 255, 255, 0.03);
  box-shadow: none;
}

.header-metric-card strong {
  font-size: 1.3rem;
}

.hero-search {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: stretch;
  margin-top: 0;
  padding: 1rem;
  border-radius: 22px;
  border: 1px solid var(--ui-border-soft);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.05), transparent 70%),
    rgba(255, 255, 255, 0.025);
}

.hero-search input {
  min-height: 3rem;
  border-radius: 16px;
  font-size: 0.98rem;
}

.hero-search-row {
  display: grid;
  grid-template-columns: minmax(0, 210px) auto auto;
  gap: 0.6rem;
}

.hero-search-field {
  min-width: 0;
}

.hero-search-field select,
.favorites-toggle,
.settings-inline-button {
  min-height: 2.85rem;
  border-radius: 14px;
}

.settings-inline-button {
  padding-inline: 0.95rem;
}

.main-menu {
  position: sticky;
  top: 0.85rem;
  z-index: 10;
  display: inline-flex;
  width: auto;
  grid-template-columns: none;
  gap: 0.45rem;
  padding: 0.45rem;
  margin-bottom: 1rem;
  border-radius: 999px;
}

.menu-tab {
  min-width: 8rem;
  padding-inline: 1rem;
}

.tools-main {
  gap: 1rem;
}

.panel {
  padding: 1.2rem;
  border-radius: 26px;
}

.panel-header {
  gap: 0.45rem;
}

.panel-header h2 {
  font-size: 1.45rem;
}

.panel-header p {
  max-width: 48rem;
  line-height: 1.6;
}

.section-block {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
}

.section-title-row {
  align-items: center;
}

.section-title-row h3 {
  font-size: 1.06rem;
}

.section-title-row p {
  line-height: 1.55;
}

.featured-tools {
  margin-top: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.featured-card {
  border-radius: 20px;
  padding: 1rem;
  box-shadow: none;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), transparent 70%),
    rgba(255, 255, 255, 0.025);
}

.featured-card::after {
  display: none;
}

.featured-open {
  min-height: 2.55rem;
  border-radius: 999px;
}

.smart-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.smart-card {
  border-radius: 18px;
  box-shadow: none;
}

.category-filters {
  gap: 0.5rem;
}

.category-chip {
  padding: 0.48rem 0.92rem;
}

.tool-results-summary {
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 72%),
    rgba(255, 255, 255, 0.025);
}

.tool-grid-categories {
  margin-top: 0.9rem;
  display: grid;
  gap: 1rem;
}

.tool-category-section {
  padding: 1rem;
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 72%),
    rgba(255, 255, 255, 0.02);
}

.tool-category-header {
  margin-bottom: 0.7rem;
}

.tool-category-header h3 {
  font-size: 1.08rem;
}

.tool-category-count {
  min-width: 2.1rem;
}

.tool-grid.tool-grid-group {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.tool-card {
  min-height: 0;
  padding: 1rem;
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 74%),
    rgba(255, 255, 255, 0.03);
  box-shadow: none;
}

.tool-card::after {
  display: none;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.tool-card-top {
  align-items: flex-start;
}

.tool-card h3 {
  margin-top: 0.26rem;
  font-size: 1.08rem;
}

.tool-description {
  min-height: auto;
  margin-top: 0.5rem;
  color: var(--ui-text-soft);
}

.tool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.85rem;
}

.tool-usage {
  font-size: 0.78rem;
}

.tool-open {
  width: auto;
  min-width: 8rem;
  border-radius: 999px;
}

.tool-open::after {
  content: "→";
  margin-left: 0.45rem;
  font-size: 0.95em;
}

.workspace-hint {
  border-radius: 18px;
  box-shadow: none;
}

.tools-footer {
  margin-top: 1.25rem;
}

@media (max-width: 899px) {
  .tools-header-main {
    grid-template-columns: 1fr;
  }

  .header-metrics {
    grid-template-columns: 1fr;
  }

  .smart-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 719px) {
  .tools-page .page-shell {
    width: min(100%, calc(100% - 1rem));
  }

  .tools-header,
  .panel {
    padding: 1rem;
  }

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

  .main-menu {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-tab {
    min-width: 0;
  }

  .featured-tools,
  .smart-strip,
  .tool-grid.tool-grid-group {
    grid-template-columns: 1fr;
  }

  .tool-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-open {
    width: 100%;
  }
}

@media (min-width: 900px) {
  .tools-header-main {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr);
    align-items: start;
  }
}

@media (min-width: 1260px) {
  .tool-grid.tool-grid-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
