:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dee8;
  --paper: #f5f7fa;
  --surface: #ffffff;
  --primary: #136f63;
  --primary-dark: #0d5049;
  --accent: #e9b44c;
  --danger: #bd3f32;
  --ok: #2f9e44;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.icon-button {
  display: grid;
  gap: 4px;
  width: 42px;
  height: 42px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.icon-button span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.brand {
  display: grid;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.brand strong {
  font-size: 17px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(23, 32, 42, 0.32);
}

.side-menu {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: min(310px, 86vw);
  padding: 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fff;
  transform: translateX(-100%);
  transition: transform 180ms ease;
}

.side-menu.is-open {
  transform: translateX(0);
}

.menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.side-menu p {
  margin: 18px 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.side-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.side-menu a.active {
  background: #eff8f5;
  color: var(--primary-dark);
}

.side-menu a[aria-disabled="true"] {
  color: #98a2b3;
}

.side-menu a span {
  color: #98a2b3;
  font-size: 12px;
}

.app-main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px 12px 32px;
}

.screen {
  display: grid;
  gap: 16px;
}

.input-panel {
  display: grid;
  gap: 16px;
}

.feature-page {
  width: min(100%, 560px);
  margin: 0 auto;
}

.feature-intro {
  display: grid;
  margin-bottom: 12px;
}

.feature-intro h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.home-page,
.static-page {
  width: min(100%, 720px);
  margin: 0 auto;
}

.home-title {
  display: grid;
  gap: 8px;
  padding: 10px 2px 0;
}

.home-title h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

.home-title p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.feature-grid {
  display: grid;
  gap: 10px;
}

.feature-card {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.feature-card.is-ready {
  border-color: rgba(19, 111, 99, 0.36);
  background: #f7fcfa;
}

.feature-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.feature-card strong {
  font-size: 20px;
  line-height: 1.2;
}

.feature-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.static-content {
  display: grid;
  gap: 10px;
}

.static-content p,
.static-content a {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.55;
}

.static-content a {
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: none;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mode-tabs button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.mode-tabs button.active {
  background: var(--primary);
  color: #fff;
}

.mode-tabs button:disabled {
  opacity: 0.48;
}

.title-block h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.title-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.origin-form {
  display: grid;
  gap: 12px;
}

.seo-note {
  display: grid;
  gap: 8px;
  padding: 2px 2px 0;
}

.seo-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.seo-note a {
  justify-self: start;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.link-flow,
.meeting-participant-form {
  display: grid;
  gap: 10px;
}

.link-flow input,
.link-flow select,
.meeting-participant-form input,
.meeting-participant-form select {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.meeting-link-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(19, 111, 99, 0.28);
  border-radius: 8px;
  background: #f7fcfa;
}

.meeting-link-box span {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.meeting-link-box code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
}

.invite-links {
  display: grid;
  gap: 8px;
}

.invite-links div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
}

.mini-button {
  min-height: 34px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.meeting-space-screen {
  gap: 14px;
}

.meeting-status {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.meeting-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.meeting-status strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.space-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.space-slots li {
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.space-slots li.is-empty {
  color: var(--muted);
  font-weight: 800;
}

.form-toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.random-toggle,
.care-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.random-multiplier {
  display: inline-grid;
  min-width: 34px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(19, 111, 99, 0.35);
  border-radius: 999px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
}

.toolbar-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.random-toggle.is-on,
.care-toggle.is-on {
  border-color: var(--ok);
  color: var(--primary-dark);
  background: #f0faf3;
}

.status-light {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b8c0cc;
}

.random-toggle.is-on .status-light,
.care-toggle.is-on .status-light {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(47, 158, 68, 0.14);
}

.participant-header,
.origin-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.8fr) minmax(140px, 1.4fr) 38px;
  gap: 6px;
  align-items: center;
}

.participant-table.is-care-on .participant-header,
.participant-table.is-care-on .origin-row {
  grid-template-columns: minmax(62px, 0.7fr) minmax(112px, 1.3fr) 58px 38px;
}

.care-column,
.weight-select {
  display: none;
}

.participant-table.is-care-on .care-column,
.participant-table.is-care-on .weight-select {
  display: block;
}

.participant-table {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.participant-header {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  padding: 0 2px 2px;
}

.origin-list {
  display: grid;
  gap: 8px;
}

.origin-row input,
.origin-row select {
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.origin-row input {
  padding: 0 10px;
}

.origin-row select {
  padding: 0 6px;
  font-weight: 900;
}

.remove-origin {
  width: 38px;
  height: 44px;
  border: 1px solid #f1c6c0;
  border-radius: 8px;
  background: #fff6f4;
  color: var(--danger);
  font-weight: 900;
}

.remove-origin:disabled {
  opacity: 0.45;
}

.action-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.text-button {
  justify-self: start;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 900;
}

.result-hero {
  border: 1px solid rgba(19, 111, 99, 0.28);
  border-radius: 8px;
  background: #f1faf7;
  overflow: hidden;
}

.result-hero p {
  margin: 0;
  padding: 10px 11px 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.hero-station-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(46px, auto) minmax(46px, auto);
  gap: 10px;
  align-items: center;
  padding: 10px 11px 12px;
}

.hero-station {
  display: grid;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.hero-station h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-station span,
.hero-metric span,
.hero-metric strong {
  font-size: 17.6px;
  line-height: 1.2;
}

.hero-station span,
.hero-metric span {
  color: var(--muted);
  font-weight: 800;
}

.hero-metric {
  display: grid;
  gap: 4px;
  min-width: 46px;
  justify-items: end;
  text-align: right;
}

.hero-metric strong {
  color: var(--ink);
  font-weight: 900;
}

.random-winner-note {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(233, 180, 76, 0.55);
  border-radius: 8px;
  background: #fff8e8;
  color: #694b06;
  font-weight: 900;
  line-height: 1.45;
}

.time-list small {
  color: var(--muted);
  font-size: 12px;
}

.result-section {
  display: grid;
  gap: 8px;
}

.section-label {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

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

.time-list li,
.candidate-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.time-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}

.time-list span,
.time-list small {
  display: block;
}

.candidate-list li.is-best {
  border-color: rgba(19, 111, 99, 0.45);
  background: #f7fcfa;
}

.candidate-list li.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.candidate-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(46px, auto) minmax(46px, auto);
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
}

.candidate-station {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: left;
}

.candidate-station strong {
  min-width: 0;
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.candidate-station span,
.candidate-metric span,
.candidate-metric strong {
  font-size: 12.8px;
  line-height: 1.25;
}

.candidate-station span,
.candidate-metric span {
  color: var(--muted);
  font-weight: 800;
}

.candidate-metric {
  display: grid;
  gap: 3px;
  min-width: 46px;
  justify-items: end;
  text-align: right;
}

.candidate-metric strong {
  color: var(--ink);
  font-weight: 900;
}

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

.last-train-note {
  margin: -4px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 390px) {
  .participant-header,
  .origin-row {
    grid-template-columns: 1fr 1fr 36px;
  }

  .participant-table.is-care-on .participant-header,
  .participant-table.is-care-on .origin-row {
    grid-template-columns: 1fr 1fr 54px 36px;
  }

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

  .candidate-list li {
    grid-template-columns: minmax(0, 1fr) minmax(42px, auto) minmax(42px, auto);
    gap: 8px;
  }

  .hero-station-card {
    grid-template-columns: minmax(0, 1fr) minmax(42px, auto) minmax(42px, auto);
    gap: 8px;
  }

  .hero-station h2 {
    font-size: 20px;
  }

  .hero-station span,
  .hero-metric span,
  .hero-metric strong {
    font-size: 16px;
  }
}
