/* AM FREE ルーム予約の参加者の画面。旧の画面の作りを移し、色はホームページの設計書の「色」にそろえた
   (地 #fcfbfe・文字 #2a2540・差し色 #6c5ce7 / #00b8b3 / #c2286f / #fdcb6e、シールの緑 #0d8a55)。
   O は緑系・X は赤系のチップ(色だけでなく文字でも区別する)。 */
:root {
  --bg: #fcfbfe;
  --surface: #ffffff;
  --surface-2: #f6f4fd;
  --border: #e4def6;
  --text: #2a2540;
  --text-muted: #5d5878;
  --accent: #6c5ce7;
  --accent-text: #5543d6;
  --accent-weak: #f1eefc;
  --free: #0d8a55;
  --free-weak: #e3f6ec;
  --taken: #c2286f;
  --taken-weak: #fdeaf2;
  --warn: #8a5a00;
  --warn-weak: #fff4dc;
  --danger: #b4235f;
  --toast-bg: #2a2540;
  --toast-text: #ffffff;
  --shadow: 0 1px 2px rgba(42, 37, 64, .06), 0 10px 24px -12px rgba(108, 92, 231, .35);
  --radius: 16px;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }

/* ---- ヘッダー ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-brand { font-size: .74rem; color: var(--text-muted); justify-self: start; }
.app-title { margin: 0; font-size: 1.05rem; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.linkbtn {
  justify-self: end;
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 4px;
  font: inherit;
  font-size: .86rem;
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
  border-radius: 8px;
}
.linkbtn:focus-visible, .btn:focus-visible, .modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- 本体 ---- */
.main { max-width: 1080px; margin: 0 auto; padding: 14px 16px 64px; }
.event-day { margin: 0 0 12px; text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--accent-text); letter-spacing: .02em; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; color: var(--text-muted); font-size: .82rem; }
.legend b { font-family: var(--mono); }
.legend .free { color: var(--free); }
.legend .taken { color: var(--taken); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }

/* ---- 部屋のカード ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.is-full { opacity: .85; }
.card.is-locked { border-color: #e9c37a; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.room-title { min-width: 0; }
.room-name { margin: 0; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.room-concept { margin: 3px 0 0; font-size: .8rem; font-weight: 700; line-height: 1.45; color: var(--accent-text); overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.badge { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge--lock { background: var(--warn-weak); color: var(--warn); }
.badge--owner { background: var(--accent-weak); color: var(--accent-text); }
.badge--full { background: var(--taken-weak); color: var(--taken); }
.badge--mine { background: var(--free-weak); color: var(--free); }

.marks { display: flex; gap: 6px; font-family: var(--mono); font-size: 1.5rem; font-weight: 700; }
.mark { width: 1.45em; height: 1.45em; display: grid; place-items: center; border-radius: 9px; line-height: 1; }
.mark--free { color: var(--free); background: var(--free-weak); }
.mark--taken { color: var(--taken); background: var(--taken-weak); }

.meta { font-size: .82rem; color: var(--text-muted); margin: 0; }
.meta strong { color: var(--text); font-size: .95rem; margin-right: .6em; }
.members { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 5px; }
.members li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: .76rem; color: var(--text-muted); overflow-wrap: anywhere; }
.members li.is-mine { background: var(--free-weak); border-color: var(--free); color: var(--free); font-weight: 700; }
.card-actions { display: flex; align-items: stretch; gap: 8px; margin-top: auto; }

/* ---- ボタン ---- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 700;
  font-size: .88rem;
  border-radius: 12px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:disabled { cursor: not-allowed; opacity: .5; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--danger { background: var(--danger); color: #fff; }
.card-actions .btn--reserve { flex: 1 1 auto; min-width: 0; }
.card-actions .btn--sub, .btn--sub { flex: 0 0 auto; padding: 9px 12px; font-size: .82rem; }
.card-actions .btn--icon { flex: 0 0 auto; padding: 9px 12px; font-size: 1.05rem; line-height: 1.2; }

/* ---- 知らせ ---- */
.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-size: .87rem; border: 1px solid; white-space: pre-line; }
.notice--error { background: var(--taken-weak); border-color: var(--taken); color: var(--danger); }
.notice--warn { background: var(--warn-weak); border-color: #e9c37a; color: var(--warn); }
.notice--closed { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-text); font-weight: 700; text-align: center; font-size: .95rem; }
.skeleton { text-align: center; color: var(--text-muted); padding: 48px 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: .87rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* ---- モーダル(div で作る。dialog 要素は使わない) ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(28, 22, 52, .55); }
.modal-panel {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px); /* iOS のアドレスバーの分を除いた高さ */
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-close { appearance: none; background: none; border: 0; font-size: 1.35rem; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 5px; }
.field input { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input::placeholder { color: var(--text-muted); opacity: .65; }
.hint { font-size: .76rem; color: var(--text-muted); margin-top: 5px; }
.hint--block { margin: 12px 0 0; }
.form-error { display: none; background: var(--taken-weak); color: var(--danger); border-radius: 10px; padding: 9px 12px; font-size: .82rem; margin-bottom: 12px; }
.form-error.show { display: block; }

.cancel-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.cancel-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.cancel-list .who { font-weight: 700; overflow-wrap: anywhere; }

/* ---- 使い方 ---- */
.help-lead { background: var(--accent-weak); border: 1px solid #cfc6f3; border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; }
.help-lead h3 { margin: 0 0 8px; font-size: .95rem; color: var(--accent-text); }
.help-lead ul { margin: 0; padding-left: 1.15em; }
.help-lead li { font-size: .9rem; margin-bottom: 4px; }
.help-section { margin-bottom: 18px; }
.help-section h3 { margin: 0 0 8px; font-size: .9rem; color: var(--accent-text); letter-spacing: .02em; }
.help-section p, .help-section li { font-size: .87rem; }
.help-section ol, .help-section ul { margin: 0; padding-left: 1.25em; }
.help-text { margin: 8px 0 0; }
.help-note { margin: 10px 0 6px; }
.help-marks { display: grid; gap: 8px; }
.help-marks div { display: flex; align-items: center; gap: 10px; font-size: .87rem; }
.help-chip { flex: 0 0 auto; width: 2.1em; height: 2.1em; display: grid; place-items: center; border-radius: 9px; font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.help-example { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .87rem; white-space: pre-wrap; }
.help-contact { background: var(--warn-weak); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin-top: 8px; }
.help-contact a { color: inherit; font-weight: 700; }

@media (max-width: 520px) {
  .app-header { grid-template-columns: 1fr auto; padding: 10px 12px; }
  .app-brand { display: none; }
  .app-title { font-size: .95rem; text-align: left; }
  .grid { grid-template-columns: 1fr; }
  .event-day { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
