:root {
  color-scheme: light;
  --ink: #182230;
  --muted: #5f6b7a;
  --line: #dce3ec;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --navy: #193a66;
  --blue: #2364d2;
  --blue-soft: #eaf1ff;
  --coral: #c94b3c;
  --coral-soft: #fff0ed;
  --green: #237a57;
  --green-soft: #e8f6ef;
  --yellow: #ffe28a;
  --focus: #1261c9;
  --shadow: 0 18px 48px rgba(25, 58, 102, 0.09);
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f8fafc;
  color: var(--ink);
  line-height: 1.65;
}

button,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible,
pre:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(18, 97, 201, 0.28);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.privacy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.privacy-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: clamp(32px, 7vw, 90px);
  align-items: center;
  padding: clamp(64px, 9vw, 118px) 0 clamp(54px, 8vw, 96px);
}

.eyebrow,
.card-kicker,
.section-number {
  margin: 0 0 0.65rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  color: var(--navy);
  font-size: clamp(2.25rem, 5vw, 4.7rem);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.hero-description {
  max-width: 720px;
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.14rem);
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1.7rem 0 0;
  padding: 0;
  list-style: none;
}

.feature-pills li {
  padding: 0.4rem 0.8rem;
  border: 1px solid #cbd8eb;
  border-radius: 999px;
  background: var(--surface);
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 800;
}

.rule-card {
  padding: clamp(24px, 4vw, 36px);
  border: 1px solid #cbd8eb;
  border-top: 5px solid var(--blue);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rule-card h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.35;
}

.rule-list {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.rule-list li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 0.8rem;
  align-items: center;
  color: #334155;
  font-size: 0.92rem;
  font-weight: 700;
}

.rule-list span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.78rem;
}

.rule-note {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace,
.results-section {
  margin-bottom: 42px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
  line-height: 1.25;
}

.section-number {
  margin-bottom: 0.3rem;
}

.text-button {
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.example-notice,
.stale-notice {
  margin: 0 0 1.2rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e8cf74;
  border-radius: 10px;
  background: #fff9dc;
  color: #725b09;
  font-size: 0.84rem;
  font-weight: 700;
}

.input-grid,
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.text-panel {
  display: block;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.label-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.label-row strong,
.label-row small {
  display: block;
}

.label-row strong {
  color: var(--navy);
  font-size: 1rem;
}

.label-row small,
.field-help,
.char-count {
  color: var(--muted);
  font-size: 0.74rem;
}

.char-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

textarea {
  display: block;
  width: 100%;
  min-height: 270px;
  resize: vertical;
  padding: 15px;
  border: 1px solid #c7d0dc;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.75;
}

textarea::placeholder {
  color: #8b97a6;
}

textarea:focus {
  border-color: var(--focus);
}

.field-help {
  display: block;
  margin-top: 0.65rem;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.3rem;
}

.form-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.button-group,
.copy-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.button {
  min-height: 44px;
  padding: 0.65rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button-primary:hover {
  background: #174fae;
}

.button-secondary {
  border-color: #bdc8d6;
  background: var(--surface);
  color: var(--navy);
}

.button-secondary:hover:not(:disabled) {
  border-color: #8ba0b8;
  background: var(--surface-soft);
}

.button-small {
  min-height: 38px;
  padding: 0.48rem 0.85rem;
  font-size: 0.78rem;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  padding: 2rem;
  border: 1px dashed #c7d0dc;
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-bottom: 0.9rem;
  border: 1px solid #c5d5ee;
  border-radius: 16px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 1rem;
  font-weight: 900;
}

.empty-state h3 {
  margin: 0;
  font-size: 1.05rem;
}

.empty-state p {
  max-width: 520px;
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.result-panel.is-stale > :not(.stale-notice) {
  opacity: 0.6;
}

.result-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 0.25fr)) minmax(260px, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 2rem;
}

.metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 96px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.metric strong {
  color: var(--navy);
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric span {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.metric-alert {
  border-color: #f0c5be;
  background: var(--coral-soft);
}

.metric-alert strong {
  color: var(--coral);
}

.result-message {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  color: #294462;
  font-size: 0.83rem;
}

.candidate-toolbar,
.comparison-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.candidate-toolbar h3,
.comparison-heading h3,
.limitations h3 {
  margin: 0;
  font-size: 1.03rem;
}

.candidate-toolbar p,
.comparison-heading p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.copy-area {
  flex: 0 0 auto;
}

.copy-status {
  max-width: 220px;
  color: var(--green);
  font-size: 0.75rem;
}

.candidate-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.candidate-button {
  display: grid;
  width: 100%;
  gap: 0.5rem;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.candidate-button:hover {
  border-color: #9eb2cc;
  background: #fbfcfe;
}

.candidate-button.is-selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(35, 100, 210, 0.13);
}

.candidate-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.category-badge,
.candidate-status {
  display: inline-flex;
  width: fit-content;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.category-number {
  background: #e9f1ff;
  color: #215cae;
}

.category-name {
  background: #f3eefe;
  color: #6741a5;
}

.category-decision {
  background: #e9f7f1;
  color: #287052;
}

.candidate-status.is-missing {
  background: var(--coral-soft);
  color: var(--coral);
}

.candidate-status.is-matched {
  background: var(--green-soft);
  color: var(--green);
}

.candidate-quote {
  overflow-wrap: anywhere;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 800;
}

.candidate-basis {
  color: var(--muted);
  font-size: 0.74rem;
}

.list-empty {
  padding: 1.2rem;
  border: 1px dashed #bdc9d7;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.matched-details {
  margin: 1.2rem 0 2rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.matched-details summary {
  padding: 0.9rem 0;
  color: var(--navy);
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 800;
}

.compact-list {
  padding-bottom: 1rem;
}

.comparison-heading {
  align-items: start;
  margin-top: 2rem;
}

.comparison-heading p {
  max-width: 720px;
  text-align: right;
}

.preview-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.preview-panel h4 {
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--navy);
  font-size: 0.82rem;
}

.text-preview {
  min-height: 230px;
  max-height: 440px;
  margin: 0;
  overflow: auto;
  padding: 1rem;
  background: var(--surface);
  color: #263344;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

mark {
  padding: 0.08em 0.12em;
  border-radius: 3px;
  background: var(--yellow);
  color: #382e0a;
  box-decoration-break: clone;
}

.limitations {
  margin-top: 1.5rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.limitations ul {
  display: grid;
  gap: 0.45rem;
  margin: 0.7rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.77rem;
}

.site-footer {
  padding: 24px 20px 36px;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.copy-fallback {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.noscript-message {
  margin: 1rem;
  padding: 1rem;
  border: 1px solid #f0c5be;
  background: var(--coral-soft);
  color: var(--coral);
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .rule-card {
    max-width: 620px;
  }

  .input-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .result-overview {
    grid-template-columns: repeat(3, 1fr);
  }

  .result-message {
    grid-column: 1 / -1;
  }

  .comparison-heading {
    display: block;
  }

  .comparison-heading p {
    text-align: left;
  }
}

@media (max-width: 600px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .page-shell {
    width: min(100% - 24px, 1180px);
  }

  .hero {
    padding-top: 48px;
  }

  .hero h1 br {
    display: none;
  }

  .workspace,
  .results-section {
    padding: 20px 16px;
    border-radius: 14px;
  }

  .section-heading,
  .action-row,
  .candidate-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .result-overview {
    grid-template-columns: 1fr;
  }

  .result-message {
    grid-column: auto;
  }

  .copy-area {
    align-items: flex-start;
    flex-direction: column;
  }

  .candidate-top {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
