:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-soft: #f5f5f7;
  --text: #242426;
  --muted: #66666d;
  --subtle: #8a8a91;
  --border: #e3e3e7;
  --accent: #c1121f;
  --accent-strong: #a40f1a;
  --accent-soft: #fff0f1;
  --warning: #8f5d00;
  --warning-bg: #fff7df;
  --success: #0b6b52;
  --success-bg: #eaf7f1;
  --shadow: 0 14px 38px rgba(22, 22, 26, 0.06);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:active,
.button:active {
  transform: translateY(1px);
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

button.small,
.button.small {
  min-height: 38px;
  padding: 7px 13px;
  font-size: 14px;
}

:focus-visible {
  outline: 3px solid rgba(193, 18, 31, 0.35);
  outline-offset: 2px;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.narrow {
  width: min(760px, calc(100% - 32px));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(227, 227, 231, 0.86);
  background: rgba(251, 251, 253, 0.86);
  backdrop-filter: blur(18px);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
}

.text-brand {
  font-size: 18px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}

.nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 7px;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.app-hero,
.detail-hero {
  padding: 34px 0 52px;
}

.app-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.filter-panel,
.results-panel,
.plain-panel,
.feedback-form,
.deadline-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filter-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 22px;
}

.panel-head h1,
.page-head h1,
.detail-main h1 {
  margin: 6px 0 10px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: 0;
}

.panel-head h1 {
  font-size: 32px;
}

.page-head h1,
.detail-main h1 {
  font-size: clamp(34px, 5vw, 56px);
}

.detail-main h1 {
  font-size: clamp(30px, 3.6vw, 46px);
}

.panel-head p,
.page-head p,
.detail-main p,
.section-head p,
.split-section p,
.plain-panel p {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.eyebrow-link {
  display: inline-flex;
  text-decoration: none;
}

.eyebrow-link:hover {
  text-decoration: underline;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.hero-metrics div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 10px;
}

.hero-metrics strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.hero-metrics span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.advanced-filters {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.advanced-filters summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.advanced-grid {
  display: grid;
  gap: 14px;
  padding: 0 12px 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.field.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  min-height: 44px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

.filter-actions,
.grant-actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.grant-actions button {
  flex: 0 0 auto;
}

.source-box {
  display: grid;
  gap: 3px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.quick-filters button {
  min-height: 34px;
  border-color: var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 500;
}

.quick-filters button:hover {
  border-color: rgba(193, 18, 31, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.source-box strong {
  color: var(--text);
}

.source-box a,
.text-link,
.back-link {
  color: var(--accent);
  text-decoration: none;
}

.source-box a:hover,
.text-link:hover,
.back-link:hover {
  text-decoration: underline;
}

.results-panel {
  min-height: 70vh;
  padding: 22px;
}

.result-toolbar,
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.result-toolbar h2,
.section-head h2,
.plain-panel h2,
.split-section h2 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.summary-pills span {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
}

.status-message {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 12px;
}

.active-filters span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 13px;
}

.grant-list {
  display: grid;
  gap: 12px;
}

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

.grant-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.grant-card:hover {
  border-color: rgba(193, 18, 31, 0.28);
  box-shadow: 0 10px 30px rgba(22, 22, 26, 0.06);
  transform: translateY(-1px);
}

.grant-card h3 {
  margin: 8px 0 8px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
}

.grant-card h3 a {
  text-decoration: none;
}

.grant-card h3 a:hover {
  color: var(--accent);
}

.grant-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.decision-row {
  display: grid;
  gap: 3px;
  margin: 0 0 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 12px;
}

.decision-row strong {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.decision-row span {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.grant-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category,
.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
}

.category {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge {
  background: var(--success-bg);
  color: var(--success);
}

.badge.warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.danger {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.muted {
  background: var(--surface-soft);
  color: var(--muted);
}

.grant-facts,
.deadline-panel dl,
.info-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.grant-facts {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.grant-facts div,
.deadline-panel dl div,
.info-list div {
  min-width: 0;
}

.grant-facts dt,
.deadline-panel dt,
.info-list dt {
  color: var(--subtle);
  font-size: 12px;
}

.grant-facts dd,
.deadline-panel dd,
.info-list dd {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.load-more {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.load-more button {
  min-width: 220px;
}

.section {
  padding: 56px 0;
}

.page-head {
  padding-bottom: 22px;
}

.split-section,
.feedback-grid,
.two-column,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 24px;
  align-items: start;
}

.step-list {
  display: grid;
  gap: 10px;
}

.step-list div,
.step-list button {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 13px;
  text-align: left;
  text-decoration: none;
}

.step-list button {
  min-height: auto;
  width: 100%;
  justify-content: stretch;
}

.step-list button:hover {
  border-color: rgba(193, 18, 31, 0.3);
  background: #fff;
  color: var(--text);
}

.step-list span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.step-list p {
  margin: 0;
  color: var(--text);
}

.link-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.link-rail.compact {
  margin-top: 18px;
}

.link-rail a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 7px 13px;
  text-decoration: none;
  font-size: 14px;
}

.link-rail a:hover {
  border-color: rgba(193, 18, 31, 0.35);
  color: var(--accent);
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.directory-link {
  min-height: 132px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 17px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.directory-link:hover {
  border-color: rgba(193, 18, 31, 0.3);
  box-shadow: 0 10px 30px rgba(22, 22, 26, 0.06);
  transform: translateY(-1px);
}

.directory-link span {
  color: var(--muted);
  font-size: 13px;
}

.directory-link strong {
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.directory-link small {
  color: var(--subtle);
  font-size: 13px;
  line-height: 1.5;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}

.muted-section {
  background: var(--surface-soft);
  border-block: 1px solid var(--border);
}

.plain-panel,
.feedback-form,
.deadline-panel {
  padding: 22px;
}

.empty-state {
  max-width: 620px;
}

.empty-state .button {
  margin-top: 8px;
}

.feedback-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.feedback-form button {
  justify-self: start;
}

.form-note {
  margin: 0;
  color: var(--muted);
  align-self: center;
}

.hp-field {
  position: absolute;
  left: -9999px;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
}

.footer-grid {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-grid span {
  color: var(--text);
  font-weight: 600;
  margin-right: auto;
}

.footer-grid a {
  color: var(--muted);
  text-decoration: none;
}

.footer-grid a:hover {
  color: var(--accent);
}

.lead.compact {
  max-width: 760px;
}

.deadline-panel {
  margin-top: 18px;
}

.check-list {
  margin: 12px 0 0;
  padding-left: 1.2em;
  color: var(--muted);
}

.check-list li + li {
  margin-top: 8px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.related-link {
  min-height: 118px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  text-decoration: none;
}

.related-link span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

@media (max-width: 980px) {
  .app-layout,
  .split-section,
  .feedback-grid,
  .two-column,
  .detail-layout,
  .directory-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
  }

  .wide-list,
  .related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .header-inner {
    min-height: 58px;
    padding: 8px 0;
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .text-brand {
    font-size: 15px;
  }

  .nav {
    width: auto;
    flex: 1;
    justify-content: flex-start;
  }

  .nav a {
    min-height: 34px;
    padding: 6px;
    font-size: 12px;
  }

  .source-box {
    display: none;
  }

  .app-hero,
  .detail-hero {
    padding-top: 12px;
  }

  .filter-panel,
  .results-panel {
    padding: 16px;
    box-shadow: none;
  }

  .panel-head h1,
  .page-head h1,
  .detail-main h1 {
    font-size: 27px;
  }

  .panel-head p {
    margin: 0;
    font-size: 14px;
  }

  .hero-metrics {
    display: none;
  }

  .filters {
    gap: 10px;
    margin-top: 14px;
  }

  input,
  select,
  textarea {
    min-height: 42px;
    padding: 9px 10px;
  }

  .result-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .summary-pills {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 2px;
  }

  .summary-pills span,
  .active-filters span {
    flex: 0 0 auto;
  }

  .active-filters {
    display: none;
  }

  .grant-facts,
  .feedback-form {
    grid-template-columns: 1fr;
  }

  .filter-actions,
  .grant-actions,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .filter-actions button,
  .grant-actions .button,
  .detail-actions .button,
  .feedback-form button {
    width: 100%;
  }

  .quick-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-top: 10px;
    padding-bottom: 2px;
  }

  .quick-filters button {
    flex: 0 0 auto;
  }

  .results-panel {
    min-height: auto;
  }

  .grant-card {
    padding: 15px;
  }
}

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