:root {
  --bg: #f6f7f2;
  --ink: #17201a;
  --muted: #68736b;
  --line: #d9dfd4;
  --surface: #ffffff;
  --surface-soft: #eef3ec;
  --green: #26734d;
  --green-dark: #155b3a;
  --green-soft: #d9eddf;
  --blue: #245a9a;
  --blue-soft: #dbe9f8;
  --amber: #a96714;
  --amber-soft: #f3e6d0;
  --red: #a33d35;
  --shadow: 0 18px 50px rgba(29, 43, 34, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 247, 242, 0.94)),
    var(--bg);
  color: var(--ink);
  font-family:
    "Pretendard",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

button {
  border: 0;
  font: inherit;
  touch-action: manipulation;
}

.app-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4.3vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: min(420px, 100%);
}

.status-strip span {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  padding: 0 14px;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(37, 58, 44, 0.06);
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(520px, 1fr) minmax(360px, 430px);
  gap: 18px;
  align-items: start;
}

.workspace > * {
  min-width: 0;
}

.side-panel,
.calendar-panel,
.results-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.panel-block {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-block:last-child {
  border-bottom: 0;
}

.participant-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.participant-button {
  position: relative;
  display: flex;
  min-height: 42px;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 10px 0 12px;
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.participant-button:hover {
  border-color: var(--green);
  background: var(--surface-soft);
}

.participant-button.active {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.participant-button .badge {
  min-width: 20px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}

.participant-button.active .badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.participant-button.complete .badge {
  background: var(--green-soft);
  color: var(--green-dark);
}

.participant-button.active.complete .badge {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.notice p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.notice p:last-child {
  margin-bottom: 0;
}

.actions {
  display: grid;
  gap: 8px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 13px;
  cursor: pointer;
  font-weight: 800;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

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

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

.secondary-action.danger {
  color: var(--red);
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  transform: none;
}

.calendar-panel,
.results-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.legend-dot.selected {
  background: var(--green-dark);
}

.legend-dot.heat {
  background: var(--blue);
}

.legend-dot.disabled {
  background: #d3d7d0;
}

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

.month {
  min-width: 0;
}

.month-title {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.month-title h3 {
  margin: 0;
  font-size: 1rem;
}

.month-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.weekday-row,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.weekday-row span {
  min-height: 22px;
}

.date-grid {
  gap: 6px;
}

.day-cell {
  position: relative;
  display: grid;
  min-height: 72px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.day-cell:hover {
  border-color: var(--green);
  box-shadow: 0 8px 20px rgba(21, 91, 58, 0.1);
  transform: translateY(-1px);
}

.day-cell.blank {
  border-color: transparent;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.day-cell.out-of-range {
  background: #edf0eb;
  color: #9aa29a;
  cursor: not-allowed;
}

.day-cell.out-of-range:hover {
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}

.day-cell.selected {
  border-color: var(--green-dark);
  background:
    linear-gradient(0deg, rgba(21, 91, 58, 0.13), rgba(21, 91, 58, 0.13)),
    var(--surface);
  box-shadow: inset 0 0 0 2px var(--green-dark);
}

.day-number {
  font-size: 1.02rem;
  font-weight: 900;
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.day-cell.selected .day-meta {
  color: var(--green-dark);
}

.top-results {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.result-card.best {
  border-color: rgba(36, 90, 154, 0.38);
  background:
    linear-gradient(90deg, rgba(219, 233, 248, 0.9), rgba(255, 255, 255, 0.95)),
    var(--surface);
}

.result-rank {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.result-date {
  margin: 5px 0;
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.25;
}

.result-people {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: var(--surface);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.5;
}

.score-pill {
  display: inline-flex;
  min-width: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--amber-soft);
  padding: 3px 9px;
  color: var(--amber);
  font-weight: 900;
}

.name-list {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(16px);
  border-radius: 6px;
  background: var(--ink);
  padding: 12px 14px;
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  .masthead {
    display: block;
  }

  .status-strip {
    justify-content: flex-start;
    margin-top: 18px;
  }

  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .results-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 14px, 720px);
    padding-top: 12px;
  }

  h1 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    overflow: visible;
  }

  .participant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: block;
  }

  .legend {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .day-cell {
    min-height: 58px;
    padding: 6px 4px;
    align-content: center;
    gap: 3px;
    text-align: center;
  }

  .day-meta {
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 10px, 430px);
  }

  .masthead {
    padding-top: 4px;
  }

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

  .status-strip span {
    width: 100%;
    justify-content: center;
  }

  .calendar-panel,
  .results-panel,
  .panel-block {
    padding: 12px;
  }

  .date-grid {
    gap: 3px;
  }

  .day-cell {
    min-height: 52px;
    padding: 5px 2px;
  }

  .day-number {
    font-size: 0.96rem;
  }

  .day-meta {
    font-size: 0.6rem;
  }

  .day-meta span:nth-child(2) {
    display: none;
  }
}
