:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --line: #e2e6ee;
  --text: #1d2230;
  --muted: #6b7385;
  --accent: #4a6fa5;
  --accent-soft: #eaf0f9;
  --ok: #3f7d5c;
  --danger: #a3494f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 32, 51, .06), 0 8px 24px rgba(24, 32, 51, .05);
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 14px; font-weight: 600; }
.brand-text small { color: var(--muted); font-size: 11px; }

.topnav { display: flex; align-items: center; gap: 10px; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }

.who { color: var(--muted); font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { flex: 1 1 auto; width: 100%; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 20px auto;
  max-width: 860px;
  width: calc(100% - 32px);
}

.panel-narrow { max-width: 420px; margin-top: 6vh; }
.center { text-align: center; }

.panel-title { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.panel-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.view.is-hidden, .is-hidden { display: none !important; }

/* ---------- forms ---------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(24,32,51,.08); }

.form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: #fff; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3f5f8e; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-ok { background: var(--accent-soft); color: var(--accent); border-color: #d3e0f2; }
.btn-danger { background: #fbeeee; color: var(--danger); border-color: #f0d9da; }

.form-msg { min-height: 1.2em; margin: 0; font-size: 12.5px; color: var(--muted); }
.form-msg.is-error { color: var(--danger); }
.form-msg.is-ok { color: var(--ok); }

.fineprint { margin: 18px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.7; }

/* ---------- spinner ---------- */
.spinner {
  width: 28px; height: 28px;
  margin: 4px auto 16px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- board layout ---------- */
.board-wrap {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  align-items: start;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.side-title { margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.member-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 6px; border-radius: 8px; }
.member-list li.is-self { background: var(--accent-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3cad8; flex: 0 0 8px; }
.dot.is-on { background: var(--ok); }
.member-role { margin-left: auto; font-size: 10.5px; color: var(--muted); }

.thread {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 70vh;
  max-height: calc(100vh - 130px);
  overflow: hidden;
}
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 10px; }
.thread-title { margin: 0; font-size: 14px; font-weight: 600; }
.thread-sub { color: var(--muted); font-size: 11.5px; margin-left: auto; }

.messages { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.msg { display: flex; gap: 10px; }
.msg-avatar {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.msg-main { min-width: 0; flex: 1 1 auto; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-name { font-size: 12.5px; font-weight: 600; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.msg.is-self .msg-body { color: #22304a; }

.empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; }

.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); align-items: flex-end; }
.composer textarea { resize: none; max-height: 120px; }
.composer .btn { flex: 0 0 auto; }

/* ---------- admin tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-table .ta-right { text-align: right; }
.data-table td .btn { margin-left: 6px; }
.data-table .cell-body { max-width: 380px; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); }
.badge-pending { background: #fdf5e6; color: #93701f; }
.badge-approved { background: #eaf5ee; color: var(--ok); }
.badge-blocked { background: #fbeeee; color: var(--danger); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 180px; }

.footer { padding: 14px 16px; text-align: center; color: var(--muted); font-size: 11px; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .board-wrap { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .sidebar { order: 2; }
  .thread { order: 1; max-height: none; min-height: 68vh; }
  .panel { padding: 18px 16px; margin: 14px auto; width: calc(100% - 20px); }
  .panel-narrow { margin-top: 4vh; }
  .who { max-width: 26vw; }
  .composer { position: sticky; bottom: 0; }
  input, textarea, .btn { font-size: 16px; } /* iOS の自動ズーム防止 */
  .composer .btn, .btn-sm, .tab { font-size: 14px; }
}
