:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #182326;
  --muted: #647074;
  --line: #d8dfda;
  --primary: #11615f;
  --primary-deep: #0d4846;
  --accent: #b56a2a;
  --danger: #b43838;
  --warning-bg: #fff4df;
  --danger-bg: #fff0f0;
  --ok-bg: #edf7f4;
  --shadow: 0 16px 40px rgba(24, 35, 38, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1100px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(17, 97, 95, 0.08), rgba(17, 97, 95, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Yu Gothic", YuGothic,
    "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

[hidden] {
  display: none !important;
}

body.result-mode {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app {
  width: min(1600px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.result-mode .app {
  width: calc(100vw - 28px);
  height: 100vh;
  padding: 12px 0;
}

.result-mode .app-header {
  display: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 13px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(116px, 1fr));
  gap: 8px;
}

.summary-strip > div {
  min-height: 54px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 8px 20px rgba(24, 35, 38, 0.05);
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.summary-strip strong {
  font-size: 22px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 1.05fr) minmax(380px, 0.72fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  min-height: 620px;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 214px;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: #fbfcfb;
  line-height: 1.55;
}

.add-members {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  overflow: hidden;
}

.add-members textarea {
  height: 82px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 97, 95, 0.13);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.button.primary {
  min-width: 124px;
  color: #fff;
  background: var(--primary);
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-deep);
}

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

.button.secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.button.compact {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.button.full {
  width: calc(100% - 16px);
  margin: 8px;
}

.button.large {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

.message-stack {
  display: grid;
  gap: 6px;
  min-height: 34px;
  margin: 10px 0 12px;
}

.message {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.45;
}

.message.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(180, 56, 56, 0.22);
}

.message.warning {
  color: #78531b;
  background: var(--warning-bg);
  border: 1px solid rgba(181, 106, 42, 0.24);
}

.message.ok {
  color: var(--primary-deep);
  background: var(--ok-bg);
  border: 1px solid rgba(17, 97, 95, 0.18);
}

.member-board {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 10px;
}

.member-column {
  min-height: 292px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  overflow: hidden;
}

.member-column.inactive {
  background: #f8f5f2;
}

.mini-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.member-list {
  display: grid;
  align-content: start;
  gap: 6px;
  height: 256px;
  padding: 8px;
  overflow: auto;
}

.member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.member-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.status-select {
  width: 92px;
  min-height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 72px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.number-field {
  display: grid;
  grid-template-columns: 96px auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

input[type="number"] {
  width: 96px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fbfcfb;
}

.table-count-select,
.capacity-select {
  width: 96px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fbfcfb;
  font-weight: 700;
}

.capacity-list {
  display: grid;
  gap: 8px;
  max-height: 398px;
  overflow: auto;
  padding-right: 2px;
}

.capacity-row {
  display: grid;
  grid-template-columns: 54px minmax(84px, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.table-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 28px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.capacity-row span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.seat-balance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.seat-balance > div {
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.seat-balance strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.seat-balance p {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--danger);
  background: var(--danger-bg);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.seat-balance.ok p {
  color: var(--primary-deep);
  background: var(--ok-bg);
}

.seat-balance.over p {
  color: #78531b;
  background: var(--warning-bg);
}

.manage-actions {
  margin-top: 12px;
}

.result-view {
  height: calc(100vh - 24px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.result-view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  margin-bottom: 10px;
}

.result-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.shuffle-status {
  min-height: 38px;
  margin-bottom: 10px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 148px);
  overflow: auto;
  padding-right: 2px;
}

.result-table {
  min-height: 154px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  overflow: hidden;
}

.result-table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #eef5f3;
}

.result-table-head h3 {
  font-size: 15px;
}

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

.seat-count.over {
  color: var(--danger);
}

.result-members {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 116px;
  padding: 7px;
}

.result-member {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 6px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.result-member select {
  width: 78px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.result-member.empty-seat {
  display: flex;
  align-items: center;
  color: var(--muted);
  border-style: dashed;
  background: #f7f8f7;
}

.is-shuffling .result-member {
  border-color: rgba(17, 97, 95, 0.3);
  background: #f0fbf8;
}

.shuffle-meter {
  position: relative;
  overflow: hidden;
  min-height: 38px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(17, 97, 95, 0.18);
  color: var(--primary-deep);
  background: var(--ok-bg);
  font-size: 13px;
  font-weight: 700;
}

.shuffle-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(17, 97, 95, 0.16), transparent);
  animation: sweep 0.9s linear infinite;
}

@keyframes sweep {
  to {
    transform: translateX(100%);
  }
}

@media (max-width: 1240px) {
  .app {
    width: calc(100vw - 28px);
  }

  .workspace {
    grid-template-columns: minmax(500px, 1fr) minmax(340px, 0.72fr);
  }
}
