:root {
  --accent: #4338ca;
  --accent-strong: #3730a3;
  --accent-soft: #e0e7ff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --bg: #f3f4f8;
  --danger: #dc2626;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --maybe: #b45309;
  --ng: #94a3b8;
  font-family: "YuGothic", "Yu Gothic Medium", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

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

/* ---------- ヘッダー ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  border-radius: 7px;
}

/* ---------- レイアウト ---------- */

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  flex: 1;
  display: grid;
  gap: 12px;
  align-content: start;
}

.loading {
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
}

.hero h1 {
  margin: 8px 0 4px;
  font-size: 1.45rem;
  line-height: 1.4;
}

.lead {
  margin: 0 0 4px;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
}

.stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

form.stack > .card {
  margin: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
  margin: 16px 0 8px;
}

.h-small {
  font-size: 1.2rem;
  margin: 0 0 8px;
}

.event-title {
  margin: 4px 0;
  font-size: 1.4rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.memo {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0;
}

.field-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin: 12px 0 6px;
}

.card > .field-label:first-child,
.stack > .field-label:first-child {
  margin-top: 0;
}

.stack > .field-label {
  margin: 4px 0 -6px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px; /* iOS で入力時に拡大されないように */
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-color: var(--accent);
}

input[readonly] {
  background: #f8fafc;
  font-size: 14px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}

.error:empty {
  display: none;
}

.notice {
  background: #fef3c7;
  color: #92400e;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-weight: 700;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row-label {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-between .field-label {
  margin-bottom: 6px;
}

.inline {
  display: flex;
  gap: 8px;
}

.inline > input,
.inline > select {
  flex: 1;
  min-width: 0;
}

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

.spacer {
  flex: 1;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  width: 100%;
  margin: 8px 0;
}

/* ---------- ボタン ---------- */

.btn,
.btn-ghost,
.btn-danger,
.link {
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #cbd5e1;
  background: var(--surface);
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
}

.btn:hover:not(:disabled) {
  background: #f8fafc;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-line {
  background: #06c755;
  border-color: #06c755;
  color: #fff;
}

.btn-line:hover {
  background: #05b04b !important;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  min-height: 40px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.9rem;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-ghost:disabled {
  opacity: 0.3;
}

.btn-danger {
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
}

.btn-danger.small {
  min-height: 36px;
  font-size: 0.85rem;
}

.btn-danger:disabled {
  opacity: 0.3;
}

.link {
  border: none;
  background: none;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- カレンダー ---------- */

.calendar {
  margin: 12px 0 4px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.cal-head .btn-ghost {
  font-size: 1.4rem;
  width: 44px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-week {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.cal-day {
  aspect-ratio: 1;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cal-day:hover:not(:disabled) {
  border-color: var(--accent);
}

.cal-day:disabled {
  background: transparent;
  color: #cbd5e1;
  cursor: default;
}

.sun {
  color: #dc2626;
}

.sat {
  color: #2563eb;
}

.cal-day.selected {
  background: var(--accent);
  color: #fff;
}

/* ---------- 予定のページ ---------- */

.created {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.created h2 {
  margin-bottom: 4px;
}

.created p {
  margin: 0;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badges:empty {
  display: none;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.admin {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.decided-text {
  margin: 4px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ok-soft);
  color: var(--ok);
}

.share {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.share-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.share-actions .btn {
  flex: 1;
}

/* 集計表：スマホでは横にスクロールし、候補の列は固定する */
.table-wrap {
  overflow-x: auto;
  margin: 0 -16px;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 0.9rem;
}

.grid th,
.grid td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.grid thead th {
  font-size: 0.8rem;
  color: var(--muted);
}

.grid .sticky {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: left;
  z-index: 1;
  max-width: 11em;
  white-space: normal;
  min-width: 8em;
  box-shadow: 1px 0 0 var(--border);
}

.grid .num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  width: 2.5em;
}

.grid .person {
  max-width: 6em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid .person .link {
  font-size: 0.8rem;
  padding: 0;
}

.mark {
  font-weight: 700;
}

.mark.v2 {
  color: var(--ok);
}

.mark.v1 {
  color: var(--maybe);
}

.mark.v0,
.mark.vnone {
  color: var(--ng);
}

.grid tr.best td,
.grid tr.best th {
  background: #eef2ff;
}

.grid tr.decided td,
.grid tr.decided th {
  background: var(--ok-soft);
}

.comments ul li {
  display: grid;
  gap: 2px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.comments .list li {
  display: block;
}

.comments .list li strong {
  margin-right: 8px;
}

.list a {
  color: var(--accent-strong);
  font-weight: 700;
}

/* 回答フォーム */
.answers {
  display: grid;
  gap: 6px;
}

.answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.answer-label {
  font-weight: 700;
  overflow-wrap: anywhere;
  min-width: 0;
}

.seg {
  display: flex;
  gap: 4px;
  flex: none;
}

.seg-btn {
  width: 48px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}

.seg-btn.v2.on {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.seg-btn.v1.on {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}

.seg-btn.v0.on {
  background: #64748b;
  border-color: #64748b;
  color: #fff;
}

.admin summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-strong);
}

.admin[open] summary {
  margin-bottom: 12px;
}

/* ---------- その他 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.offscreen {
  position: fixed;
  left: -9999px;
}

.footer {
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-note {
  margin: 0 0 8px;
}

.footer a {
  color: var(--muted);
}
