:root {
  --ink: #16231f;
  --muted: #61706a;
  --line: #dce5e1;
  --surface: #ffffff;
  --background: #f4f7f5;
  --green: #0c7a58;
  --green-dark: #075b42;
  --green-soft: #e7f4ee;
  --yellow: #f5c744;
  --yellow-soft: #fff7d6;
  --red: #b83b33;
  --red-soft: #fff0ee;
  --shadow: 0 12px 34px rgba(24, 55, 45, 0.08);
}

* { box-sizing: border-box; }
html { font-family: Inter, "Noto Sans JP", "Yu Gothic UI", sans-serif; color: var(--ink); background: var(--background); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.site-header {
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 15px; background: var(--yellow);
  display: grid; place-items: center; font-weight: 900; letter-spacing: -0.08em;
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 18px; }
.brand span { color: var(--muted); font-size: 12px; }
nav { display: flex; align-items: center; gap: 6px; }
nav a, .text-button {
  border: 0; background: transparent; text-decoration: none; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 700;
}
nav a:hover, nav a.active, .text-button:hover { color: var(--green-dark); background: var(--green-soft); }
.inline-form { display: inline; margin: 0; }

.page-shell { width: min(1180px, calc(100% - 36px)); margin: 36px auto 70px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.04em; margin-bottom: 10px; }
h2 { font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.025em; margin-bottom: 8px; }
h3 { margin-bottom: 4px; }
.page-heading p { color: var(--muted); margin-bottom: 0; }
.eyebrow { color: var(--green); font-weight: 900; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px; }

.alert { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 14px 17px; border-radius: 14px; margin-bottom: 18px; }
.alert.success { border-color: #a5d7c6; background: var(--green-soft); }
.alert.error { border-color: #e8aaa4; background: var(--red-soft); }

.connection-badge { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 9px 12px; border-radius: 999px; background: var(--surface); font-size: 13px; white-space: nowrap; }
.connection-badge span { width: 8px; height: 8px; border-radius: 50%; background: #9aa7a2; }
.connection-badge.ready span { background: var(--green); }

.incident-banner { background: var(--ink); color: white; border-radius: 22px; padding: 24px 28px; display: flex; justify-content: space-between; align-items: center; gap: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.incident-banner h2 { margin: 12px 0 7px; }
.incident-banner p { margin: 0; color: #cbd7d2; }
.incident-time { text-align: right; display: grid; gap: 4px; }
.incident-time span { font-size: 12px; color: #cbd7d2; }
.pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--yellow); color: #332a0c; font-weight: 900; font-size: 12px; }
.pill.closed { background: #e8eeeb; color: var(--muted); }
.pill.active { background: var(--green-soft); color: var(--green-dark); }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.metrics article { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 8px 24px rgba(24,55,45,.04); }
.metrics span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metrics strong { font-size: 34px; line-height: 1; }
.metrics small { color: var(--muted); margin-left: 3px; }
.metrics .safe { background: var(--green-soft); border-color: #c5e4d8; }
.metrics .attention { background: var(--red-soft); border-color: #f0c2bd; }
.metrics .pending { background: var(--yellow-soft); border-color: #ebd688; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.compact { padding-bottom: 16px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.button-row { display: flex; gap: 9px; flex-wrap: wrap; }
button, .button-link { border: 0; border-radius: 11px; padding: 12px 16px; font-weight: 900; cursor: pointer; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--green); color: white; }
.primary:hover { background: var(--green-dark); }
.secondary { background: var(--green-soft); color: var(--green-dark); }
.secondary:hover { background: #d9eee6; }
.danger-outline { color: var(--red); background: white; border: 1px solid #e3afa9; }
.wide { grid-column: 1 / -1; }

.member-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.member-card { border: 1px solid var(--line); border-radius: 18px; padding: 18px; min-height: 210px; display: flex; flex-direction: column; }
.member-card.safe { border-top: 5px solid var(--green); }
.member-card.injured, .member-card.help { border-top: 5px solid var(--red); background: #fffafa; }
.member-card.unanswered { border-top: 5px solid var(--yellow); background: #fffdf4; }
.member-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.member-top span { color: var(--muted); font-size: 12px; }
.status { font-size: 13px; padding: 6px 9px; background: #eef2f0; border-radius: 999px; white-space: nowrap; }
.member-card.safe .status { color: var(--green-dark); background: var(--green-soft); }
.member-card.injured .status, .member-card.help .status { color: var(--red); background: var(--red-soft); }
.member-card dl { margin: 18px 0 10px; display: grid; gap: 8px; }
.member-card dl div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #eef2f0; padding-bottom: 7px; }
dt { color: var(--muted); } dd { margin: 0; font-weight: 700; text-align: right; }
.comment { background: #f5f7f6; border-radius: 10px; padding: 10px; font-size: 14px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.line-state { margin-top: auto; padding-top: 12px; font-size: 12px; font-weight: 800; }
.line-state.linked, .member-link-status.linked { color: var(--green); }
.line-state.not-linked, .member-link-status.not-linked { color: var(--red); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label, .stack-form label, .member-edit-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 46px; border: 1px solid #cdd8d3; border-radius: 11px; padding: 10px 12px; background: white; color: var(--ink); }
textarea { resize: vertical; overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(12,122,88,.15); border-color: var(--green); }
.secret-form { max-width: 760px; }
.copy-value { background: #f2f5f3; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 14px 0; overflow-x: auto; }
.copy-value code { overflow-wrap: anywhere; word-break: break-all; }
.success-note { color: var(--green-dark); background: var(--green-soft); border-radius: 12px; padding: 12px; margin: 16px 0 0; font-weight: 800; }

.empty-state { text-align: center; padding: 54px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; margin-bottom: 18px; }
.empty-state p { color: var(--muted); }
.empty-icon { width: 82px; height: 82px; border-radius: 24px; background: var(--yellow); display: grid; place-items: center; font-weight: 900; margin: 0 auto 18px; }
.rules-panel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.rules-panel div { background: var(--surface); padding: 17px; display: grid; gap: 4px; }
.rules-panel strong { font-size: 13px; color: var(--green-dark); }
.rules-panel span { font-size: 13px; color: var(--muted); }

.capacity { display: flex; align-items: baseline; padding: 10px 16px; background: var(--yellow-soft); border-radius: 14px; }
.capacity strong { font-size: 30px; }
.capacity span { color: var(--muted); }
.add-member-form { grid-template-columns: 2fr 1fr auto; align-items: end; }
.member-admin-list { display: grid; gap: 12px; }
.member-admin-list article { border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.member-edit-form { display: grid; grid-template-columns: 2fr 1fr auto 1fr auto; gap: 13px; align-items: end; }
.check-label { display: flex !important; align-items: center; gap: 7px; min-height: 46px; }
.check-label input { width: 18px; min-height: 18px; }
.member-link-status { display: grid; gap: 2px; align-self: center; }
.member-link-status span { color: var(--muted); font-size: 12px; }
.invite-form { text-align: right; margin-top: 8px; }
.invite-result { background: var(--ink); color: white; padding: 26px; border-radius: 22px; margin-bottom: 18px; text-align: center; }
.invite-result code { display: inline-block; font-size: clamp(30px, 8vw, 54px); letter-spacing: .12em; background: white; color: var(--ink); border-radius: 14px; padding: 12px 18px; margin: 10px 0 18px; }
.invite-result p { color: #d1dbd7; }
.invite-result.standalone { max-width: 700px; margin: 70px auto; }
.notice-box { border-left: 5px solid var(--yellow); background: var(--yellow-soft); padding: 20px 22px; border-radius: 0 16px 16px 0; }
.notice-box h2 { font-size: 18px; }
.notice-box p { margin-bottom: 0; color: #5f5224; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; }
td { font-size: 14px; }
.delivery { display: inline-flex; border-radius: 999px; padding: 5px 8px; font-size: 12px; font-weight: 900; }
.delivery.sent { color: var(--green-dark); background: var(--green-soft); }
.delivery.failed { color: var(--red); background: var(--red-soft); }
.delivery.skipped { color: #725c10; background: var(--yellow-soft); }
.empty { color: var(--muted); text-align: center; padding: 22px; }

.login-card { width: min(470px, 100%); margin: 72px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 34px; }
.stack-form { display: grid; gap: 14px; margin-top: 26px; }
.hint { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
footer { width: min(1180px, calc(100% - 36px)); margin: 0 auto 28px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .member-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rules-panel { grid-template-columns: repeat(2, 1fr); }
  .member-edit-form { grid-template-columns: 1fr 1fr; }
  .member-link-status { min-height: 46px; }
}

@media (max-width: 640px) {
  .site-header { align-items: flex-start; padding: 12px 16px; position: static; }
  .brand { min-width: 0; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .brand span { display: none; }
  nav { display: grid; grid-template-columns: repeat(4, auto); justify-content: end; }
  nav a, nav .text-button { padding: 8px 9px; font-size: 13px; }
  nav .inline-form { grid-column: 1 / -1; text-align: right; }
  .page-shell { width: min(100% - 24px, 1180px); margin-top: 22px; }
  .page-heading, .panel-heading, .incident-banner { display: grid; }
  .connection-badge { justify-self: start; }
  .incident-time { text-align: left; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics article:first-child { grid-column: 1 / -1; }
  .member-grid { grid-template-columns: 1fr; }
  .form-grid, .add-member-form { grid-template-columns: 1fr; }
  .rules-panel { grid-template-columns: 1fr; }
  .panel { padding: 18px; border-radius: 18px; }
  .member-edit-form { grid-template-columns: 1fr; }
  .member-edit-form .secondary { width: 100%; }
  .button-row { width: 100%; display: grid; }
  .button-row form, .button-row button { width: 100%; }
  .invite-form { text-align: left; }
  .invite-result code { letter-spacing: .06em; }
  footer { display: grid; gap: 5px; }
}
