:root {
  --text:             #111111;
  --muted:            #666666;
  --hairline:         #e5e5e5;
  --dot-active:       #22c55e;
  --dot-quiet:        #f59e0b;
  --dot-inactive:     #9ca3af;
  --dot-external:     #60a5fa;
  --pill-active-bg:   #111111;
  --pill-active-text: #ffffff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: #ffffff;
  max-width: 960px;
  margin: 0 auto;
  padding: 52px 24px 96px;
}

/* ── Header ── */

.site-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.site-nav {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.site-title a,
.site-title a:visited,
.site-title a:hover,
.site-title a:active {
  color: var(--text);
  text-decoration: none;
}

.site-subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.back-link {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Controls ── */

.controls {
  margin-top: 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modality-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

a.pill {
  text-decoration: none;
  display: inline-block;
  line-height: 1.6;
}

.pills {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pill-group {
  display: flex;
  gap: 4px;
}

.pill {
  padding: 3px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  background: none;
  color: var(--text);
  user-select: none;
  transition: border-color 0.1s;
}


.pill:hover:not(.selected) {
  border-color: #aaaaaa;
}

.pill.selected {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: var(--pill-active-bg);
}

.sub-pills {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
}

.sub-pills.visible {
  display: flex;
  justify-content: center;
}

.sub-pill {
  font-size: 11px;
  padding: 2px 8px;
  color: var(--muted);
  border-color: var(--hairline);
}

.sub-pill.selected {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: var(--pill-active-bg);
}

/* ── About page ── */

.about-wrap {
  max-width: 560px;
  margin: 0 auto;
}

.about-body {
  margin-top: 12px;
}

.health-legend {
  list-style: none;
  margin: 16px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.health-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.about-body p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 28px;
}

.about-body a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.search {
  width: 240px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  outline: none;
  color: var(--text);
  margin-top: 22px;
  margin-bottom: 12px;
}

.search:focus {
  border-color: #aaaaaa;
}

/* ── Meta bar ── */

.meta {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.meta-left,
.meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-sep {
  color: var(--hairline);
}

.meta-link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Table ── */

.tool-table {
  margin-top: 28px;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tool-table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--text);
}

.tool-table th:first-child {
  width: 24px;
  padding-right: 0;
}

.tool-table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

.tool-table td:first-child {
  padding-right: 0;
}

.section-header td {
  padding-top: 28px;
  padding-bottom: 6px;
  padding-right: 0;
  border-bottom: 1px solid var(--text);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-header:first-child td {
  padding-top: 12px;
}

.tool-table tr.inactive td {
  opacity: 0.5;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-active    { background: var(--dot-active); }
.dot-quiet     { background: var(--dot-quiet); }
.dot-inactive  { background: var(--dot-inactive); }
.dot-external  { background: var(--dot-external); }
.dot-unknown   { background: transparent; border: 1.5px solid var(--dot-inactive); }

.tool-name a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.tool-name a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}


.col-date {
  display: none;
}

.tool-table.show-dates .col-date {
  display: table-cell;
}

.tool-desc,
.tool-stage,
.tool-lang,
.tool-modality,
.tool-stars {
  color: var(--muted);
}

.tool-stage,
.tool-lang,
.tool-modality,
.tool-stars,
.col-date {
  white-space: nowrap;
}

.col-date {
  color: var(--muted);
  font-size: 12px;
}

.lang-th,
.modality-th,
.stars-th {
  position: relative;
}

.lang-header-btn,
.modality-header-btn,
.stars-header-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.lang-header-btn:hover,
.lang-header-btn.lang-header-active,
.modality-header-btn:hover,
.modality-header-btn.modality-header-active,
.stars-header-btn:hover,
.stars-header-btn.stars-header-active {
  color: var(--text);
}

.lang-dropdown,
.modality-dropdown,
.stars-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  z-index: 100;
  min-width: 130px;
  flex-direction: column;
  padding: 4px 0;
}

.lang-dropdown.open,
.modality-dropdown.open,
.stars-dropdown.open {
  display: flex;
}

.lang-option,
.modality-option,
.stars-option {
  font-family: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 5px 12px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.lang-option:hover,
.modality-option:hover,
.stars-option:hover {
  color: var(--text);
  background: var(--hairline);
}

.lang-option.selected,
.modality-option.selected,
.stars-option.selected {
  color: var(--text);
  font-weight: 500;
}

#lang-tag {
  font-size: 12px;
  color: var(--muted);
}

.lang-clear {
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

/* ── Suggest form ── */

.suggest-form {
  margin-top: 36px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.radio-group {
  display: flex;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}

.tool-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}

.tool-hint a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  padding: 7px 8px;
  outline: none;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #aaaaaa;
}

.field-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field-note a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.submit-btn {
  align-self: flex-start;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 16px;
  border: 1px solid var(--text);
  border-radius: 2px;
  background: var(--text);
  color: #fff;
  cursor: pointer;
}

.submit-btn:hover {
  background: #333;
  border-color: #333;
}

.footer {
  margin-top: 52px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
}

.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hidden { display: none !important; }

.mobile-modality {
  display: none;
}

/* ── Mobile ── */

@media (max-width: 640px) {
  body {
    padding: 36px 20px 64px;
  }

  .site-header-row {
    flex-direction: column;
    gap: 20px;
  }

  .site-subtitle {
    margin-top: 3px;
  }

  .site-nav {
    gap: 10px;
    flex-wrap: wrap;
    row-gap: 6px;
    justify-content: center;
  }

  .controls {
    margin-top: 44px;
    gap: 14px;
  }

  .modality-pills {
    display: none;
  }

  .pills {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .pill-group {
    justify-content: center;
    flex-wrap: wrap;
  }

  .pill {
    padding: 6px 12px;
  }

  .sub-pills.visible {
    justify-content: center;
  }

  .search {
    width: 100%;
    margin-top: 0;
    margin-bottom: 0;
  }

  .meta {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }

  .meta-right {
    display: none;
  }

  .meta-left {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Hide filter status tags */
  #lang-tag,
  #modality-tag {
    display: none !important;
  }

  .mobile-modality {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  /* Stacked table layout */
  .tool-table thead,
  .lang-th, .tool-lang,
  .modality-th, .tool-modality,
  .stars-th, .tool-stars,
  .col-date {
    display: none !important;
  }

  .tool-table,
  .tool-table tbody {
    display: block;
  }

  .tool-table tr.section-header {
    display: block;
  }

  .tool-table tr.section-header td {
    display: block;
    padding-top: 28px;
    padding-bottom: 6px;
    padding-right: 0;
    border-bottom: 1px solid var(--text);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .tool-table tr:not(.section-header) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    padding: 11px 0;
    border-bottom: 1px solid var(--hairline);
  }

  .tool-table tr:not(.section-header) td {
    border-bottom: none;
    padding: 0;
  }

  .tool-table tr:not(.section-header) td:first-child {
    width: 20px;
    flex-shrink: 0;
    align-self: center;
  }

  .tool-name {
    flex: 1;
    min-width: 0;
  }

  .tool-desc {
    width: 100%;
    padding-left: 20px;
    margin-top: 3px;
    font-size: 12px;
  }
}

/* ── Dark mode ── */

@media (prefers-color-scheme: dark) {
  :root {
    --text:             #ededec;
    --muted:            #888888;
    --hairline:         #2a2a2a;
    --pill-active-bg:   #ededec;
    --pill-active-text: #111111;
  }

  body {
    background: #111111;
  }

  .lang-dropdown,
  .modality-dropdown,
  .stars-dropdown {
    background: #1a1a1a;
  }

  .search,
  .field input,
  .field select,
  .field textarea {
    background: #1a1a1a;
    color: var(--text);
  }

  .submit-btn {
    background: var(--text);
    color: #111111;
    border-color: var(--text);
  }

  .submit-btn:hover {
    background: #cccccc;
    border-color: #cccccc;
  }
}
