:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1d2330;
  --muted: #667085;
  --border: #dde1e8;
  --primary: #3b5bdb;
  --primary-text: #ffffff;
  --regular: #2f9e44;
  --oneshot: #e8590c;
  --full: #c92a2a;
  --error: #c92a2a;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --surface: #1e2129;
    --surface-2: #262a34;
    --text: #e6e8ee;
    --muted: #9aa1b1;
    --border: #343946;
    --primary: #5c7cfa;
    --regular: #51cf66;
    --oneshot: #ff922b;
    --full: #ff6b6b;
    --error: #ff6b6b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.6;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px max(16px, calc((100% - 1100px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header h1 { margin: 0; font-size: 1.25rem; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters .field { margin-bottom: 0; flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }

.badge-server { color: var(--primary); }

.result-count { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.card-host { font-weight: 700; margin-right: auto; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  border: 1px solid currentColor;
}
.badge-定期 { color: var(--regular); }
.badge-単発 { color: var(--oneshot); }
.badge-slots { color: var(--muted); }
.badge-full { color: var(--full); }

.card-body { padding: 12px 16px; flex: 1; }

.card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
}
.card dt { color: var(--muted); font-size: .85rem; white-space: nowrap; padding-top: 1px; }
.card dd { margin: 0; overflow-wrap: anywhere; }
.boss-name { font-weight: 700; }
.conditions { white-space: pre-wrap; }

.members { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.members li {
  padding: 1px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .9rem;
}
.members .vacant { color: var(--muted); border-style: dashed; background: transparent; }
.members li.after-full { border-color: var(--oneshot); }
.members li.after-full::after {
  content: '満員後';
  margin-left: 6px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--oneshot);
}
.member-cancel {
  margin-left: 4px;
  padding: 0 2px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.member-cancel:hover { color: var(--error); }
.late-label { display: block; margin-top: 8px; font-size: .8rem; color: var(--oneshot); font-weight: 700; }

.btn-link {
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .8rem;
  text-decoration: underline;
  cursor: pointer;
}
.btn-link:hover { color: var(--error); }
.foot-left { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.posted-at { color: var(--muted); font-size: .8rem; }

.btn {
  font: inherit;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { padding: 20px; }
dialog h2 { margin: 0 0 16px; font-size: 1.1rem; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; flex: 1; min-width: 0; }
.field > span { font-size: .85rem; font-weight: 700; color: var(--muted); }
.field-row { display: flex; gap: 12px; }
@media (max-width: 480px) { .field-row { flex-direction: column; gap: 0; } }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.apply-target { margin: -8px 0 16px; color: var(--muted); }
.notice {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--oneshot);
  color: var(--oneshot);
  font-size: .9rem;
}
.hint { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--error); min-height: 1.6em; margin: 0 0 8px; font-size: .9rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
