:root {
  --white: #ffffff;
  --k10: #e4e4e4;
  --k20: #cccccc;
  --k40: #999999;
  --k60: #666666;
  --k80: #333333;
  --black: #1a1a1a;
  --ok: #2d7a4f;
  --ok-light: #e8f5ee;
  --r: 4px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans JP','Yu Gothic','YuGothic',sans-serif; background:var(--white); color:var(--black); min-height:100vh; }

/* Header */
.header { border-bottom:1px solid var(--k10); padding:16px 24px; display:flex; align-items:center; gap:14px; background:var(--white); position:sticky; top:0; z-index:100; }
.logo-icon { width:32px; height:32px; object-fit:contain; flex-shrink:0; }
.logo-text { font-size:0.95rem; font-weight:700; letter-spacing:0.04em; }
.logo-sub { font-size:0.65rem; color:var(--k60); font-weight:400; margin-top:2px; letter-spacing:0.08em; }
.header-right { margin-left:auto; }
/* home画面ではヘッダーの新規作成ボタンを非表示 */
body:has(#view-home.active) .header-right { display:none; }
.btn-home { background:none; border:none; font-family:inherit; font-size:0.75rem; color:var(--k60); cursor:pointer; padding:4px 8px; border-radius:var(--r); }
.btn-home:hover { color:var(--black); background:var(--k10); }

/* Layout */
#app { max-width:680px; margin:0 auto; padding:40px 20px 80px; }

/* Views */
.view { display:none; }
.view.active { display:block; animation:fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* Deleted */
.deleted-mode { background:#000000; }
.deleted-mode .header { display:none; }
.deleted-mode #app { max-width:none; padding:0; }
.deleted-screen { min-height:100vh; background:#000000; color:#ffffff; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:40px 20px; gap:12px; }
.deleted-icon { font-size:2rem; font-weight:300; opacity:0.4; margin-bottom:4px; }
.deleted-text { font-size:1.1rem; font-weight:700; letter-spacing:0.04em; }
.deleted-sub { font-size:0.8rem; color:rgba(255,255,255,0.4); }
.deleted-home-btn { margin-top:12px; background:none; border:1px solid rgba(255,255,255,0.2); color:rgba(255,255,255,0.6); border-radius:var(--r); padding:10px 28px; font-family:inherit; font-size:0.82rem; cursor:pointer; transition:all 0.15s; }
.deleted-home-btn:hover { border-color:rgba(255,255,255,0.5); color:rgba(255,255,255,0.9); }

/* Loading */
.loading { display:flex; align-items:center; justify-content:center; gap:10px; padding:60px 20px; color:var(--k60); font-size:0.85rem; }
.spinner { width:20px; height:20px; border:2px solid var(--k20); border-top-color:var(--black); border-radius:50%; animation:spin 0.7s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }

/* Section head */
.section-head { display:flex; align-items:center; gap:10px; margin-bottom:24px; }
.section-icon { width:18px; height:18px; object-fit:contain; flex-shrink:0; }
.section-label { font-size:0.62rem; font-weight:700; letter-spacing:0.15em; text-transform:uppercase; color:var(--k60); }

/* Card */
.card { border:1px solid var(--k10); border-radius:var(--r); padding:24px; margin-bottom:16px; }

/* Form */
.field { margin-bottom:18px; }
label { display:block; font-size:0.75rem; font-weight:700; color:var(--k60); margin-bottom:6px; letter-spacing:0.04em; }
input[type=text],input[type=date],input[type=time],textarea {
  width:100%; border:1px solid var(--k20); border-radius:var(--r);
  background:var(--white); font-family:inherit; font-size:0.92rem; color:var(--black);
  padding:10px 14px; outline:none; transition:border-color 0.15s;
  -webkit-appearance:none; appearance:none;
}
input:focus,textarea:focus { border-color:var(--black); }
textarea { resize:vertical; min-height:72px; line-height:1.7; }
.input-row { display:flex; gap:10px; flex-wrap:wrap; }
.input-row > * { flex:1; min-width:130px; }
.sub-label { font-size:0.7rem; font-weight:500; color:var(--k60); margin-bottom:5px; display:block; }

/* Toggle */
.toggle-group { display:flex; border:1px solid var(--k20); border-radius:var(--r); overflow:hidden; }
.toggle-btn { flex:1; padding:9px 8px; border:none; background:var(--white); font-family:inherit; font-size:0.82rem; color:var(--k60); cursor:pointer; border-right:1px solid var(--k20); font-weight:500; transition:all 0.15s; }
.toggle-btn:last-child { border-right:none; }
.toggle-btn.active { background:var(--black); color:var(--white); font-weight:700; }

/* Buttons */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:12px 20px; border-radius:var(--r); border:none; font-family:inherit; font-size:0.88rem; font-weight:700; cursor:pointer; transition:all 0.15s; letter-spacing:0.03em; }
.btn-primary { background:var(--black); color:var(--white); width:100%; padding:14px; }
.btn-primary:hover { background:var(--k80); }
.btn-primary:disabled { background:var(--k20); color:var(--k60); cursor:not-allowed; }
.btn-secondary { background:var(--white); color:var(--black); border:1px solid var(--k20); width:100%; padding:12px; }
.btn-secondary:hover { border-color:var(--black); }
.btn-sm { background:var(--white); color:var(--k80); border:1px solid var(--k20); padding:7px 14px; font-size:0.78rem; }
.btn-sm:hover { border-color:var(--black); }
.btn-danger { color:#b33a3a; border-color:#e1b6b6; background:#fff6f6; }
.btn-danger:hover { border-color:#c98a8a; }
.btn-ghost { color:var(--k60); border:1px dashed var(--k20); background:var(--white); }
.btn-ghost:hover { border-color:var(--k40); color:var(--k80); }

/* URL box */
.url-box { background:var(--k10); border-radius:var(--r); padding:12px 14px; font-family:monospace; font-size:0.78rem; color:var(--k80); word-break:break-all; cursor:pointer; display:flex; align-items:center; justify-content:space-between; gap:8px; transition:background 0.15s; }
.url-box:hover { background:var(--k20); }
.copy-hint { font-size:0.7rem; color:var(--k60); text-align:center; margin-top:5px; }

/* Steps */
.steps { display:flex; border-bottom:1px solid var(--k10); margin-bottom:28px; }
.step { flex:1; text-align:center; padding:9px 4px; font-size:0.7rem; font-weight:500; color:var(--k40); border-bottom:2px solid transparent; margin-bottom:-1px; letter-spacing:0.04em; }
.step.active { color:var(--black); border-color:var(--black); font-weight:700; }
.step.done { color:var(--ok); border-color:var(--ok); }

/* Grid */
.grid-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.sched-grid { display:grid; gap:2px; min-width:fit-content; }
.grid-corner { background:transparent; }
.grid-col-label { background:var(--k10); border-radius:3px 3px 0 0; padding:5px 3px; text-align:center; font-size:0.65rem; font-weight:700; color:var(--k60); white-space:nowrap; line-height:1.5; }
.grid-row-label { display:flex; align-items:flex-start; padding-top:3px; font-size:0.65rem; color:var(--k60); padding-right:8px; white-space:nowrap; font-weight:500; border-top:1px solid var(--k20); }
.grid-cell { width:36px; height:28px; border-radius:2px; cursor:pointer; transition:filter 0.08s; border:1px solid transparent; box-shadow:inset 0 1px 0 var(--k10); touch-action:none; user-select:none; -webkit-user-select:none; }
/* 結果グリッドのセルはスクロールを妨げない */
.grid-wrap:has(#result-grid) .grid-cell { touch-action:pan-x pan-y; }
.grid-cell:hover { filter:brightness(0.88); }
.grid-cell.cell-empty { background:var(--k10); border-color:var(--k20); }
.grid-cell.cell-ok { background:var(--black); border-color:var(--black); }
.grid-cell.h0 { background:var(--k10); border-color:var(--k20); }
.grid-cell.h1 { background:#cce0d4; border-color:#b0ccbc; }
.grid-cell.h2 { background:#88c4a4; border-color:#6aaa8a; }
.grid-cell.h3 { background:#4a9a74; border-color:#3a845f; }
.grid-cell.hfull { background:#c47c1a; border-color:#a86515; outline:2px solid #c47c1a44; }

/* Tooltip */
.cell-wrap { position:relative; }
.cell-tip { position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); background:var(--black); color:var(--white); border-radius:var(--r); padding:7px 11px; font-size:0.7rem; line-height:1.6; white-space:nowrap; pointer-events:none; z-index:200; display:none; }
.cell-wrap:hover .cell-tip { display:block; }

/* Best banner */
.best-banner { background:var(--ok-light); border:1px solid #b8d9c4; border-radius:var(--r); padding:14px 18px; display:flex; align-items:flex-start; gap:12px; margin-bottom:16px; }
.best-icon { font-size:1.1rem; flex-shrink:0; }
.best-label { font-size:0.65rem; font-weight:700; color:var(--ok); letter-spacing:0.1em; margin-bottom:3px; }
.best-text { font-size:0.9rem; font-weight:700; color:var(--black); }

/* Participants */
.participants { display:flex; flex-wrap:wrap; gap:6px; }
.p-tag { display:flex; align-items:center; gap:5px; background:var(--k10); border-radius:2px; padding:4px 10px; font-size:0.78rem; font-weight:500; transition:all 0.15s; border:1px solid transparent; }
.p-tag-active { background:var(--black) !important; color:var(--white) !important; }
.p-tag-dim { opacity:0.35; }
.p-tag-reset { background:var(--white) !important; border:1px solid var(--k20) !important; color:var(--k60) !important; font-size:0.72rem !important; }
.p-tag:hover { border-color:var(--k40); }
.p-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }

/* Legend */
.legend { display:flex; gap:14px; flex-wrap:wrap; margin-bottom:14px; }
.legend-item { display:flex; align-items:center; gap:5px; font-size:0.7rem; color:var(--k60); }
.legend-sw { width:13px; height:13px; border-radius:2px; border:1px solid var(--k20); }

/* Comment badge */
.comment-badge { display:inline-block; width:7px; height:7px; background:#e53e3e; border-radius:50%; margin-left:5px; position:relative; top:-1px; vertical-align:middle; }

/* Nav tabs */
.nav-tabs { display:flex; border-bottom:1px solid var(--k10); margin-bottom:20px; }
.nav-tab { padding:9px 18px; background:none; border:none; border-bottom:2px solid transparent; margin-bottom:-1px; font-family:inherit; font-size:0.8rem; font-weight:700; color:var(--k60); cursor:pointer; letter-spacing:0.04em; transition:all 0.15s; }
.nav-tab.active { color:var(--black); border-color:var(--black); }

/* Comment */
.comment-item { border-left:2px solid var(--k20); padding:8px 13px; margin-bottom:12px; }
.c-author { font-size:0.7rem; font-weight:700; margin-bottom:3px; }
.c-body { font-size:0.83rem; line-height:1.75; color:var(--k80); }

/* Already voted */
.voted-box { background:var(--k10); border-radius:var(--r); padding:28px 24px; text-align:center; margin-bottom:20px; }
.voted-box .v-title { font-size:1rem; font-weight:900; margin-bottom:8px; }
.voted-box p { font-size:0.82rem; color:var(--k60); line-height:1.8; }

/* Toast */
.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(80px); background:var(--black); color:var(--white); padding:10px 20px; border-radius:99px; font-size:0.8rem; font-weight:700; z-index:1000; transition:transform 0.3s ease; white-space:nowrap; }
.toast.show { transform:translateX(-50%) translateY(0); }

/* Modal */
.modal { position:fixed; inset:0; display:none; align-items:center; justify-content:center; z-index:1200; padding:20px; }
.modal.active { display:flex; }
.modal-backdrop { position:absolute; inset:0; background:rgba(0,0,0,0.35); }
.modal-card { position:relative; z-index:1; background:var(--white); border:1px solid var(--k10); border-radius:var(--r); padding:20px 22px; width:min(90vw, 420px); box-shadow:0 12px 40px rgba(0,0,0,0.18); animation:popIn 0.16s ease; }
@keyframes popIn { from{opacity:0;transform:translateY(6px) scale(0.98)} to{opacity:1;transform:none} }
.modal-title { font-size:0.9rem; font-weight:700; margin-bottom:10px; }
.modal-body { margin-bottom:16px; }
.modal-event { font-size:0.95rem; font-weight:900; margin-bottom:4px; }
.modal-time { font-size:0.82rem; color:var(--k60); margin-bottom:8px; }
.modal-note { font-size:0.75rem; color:var(--k60); }
.modal-actions { display:flex; gap:8px; }
.modal-actions .btn { width:auto; flex:1; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { padding:12px 14px; }
.modal .url-box { margin-bottom:6px; }

/* Firebase config notice */
.config-notice { background:#fff8e6; border:1px solid #f0d060; border-radius:var(--r); padding:14px 16px; margin-bottom:16px; font-size:0.8rem; line-height:1.7; color:var(--k80); }
.config-notice strong { color:#b07000; }

hr { border:none; border-top:1px solid var(--k10); margin:18px 0; }

/* ============================================================
   ホーム ランディングセクション
   ============================================================ */
.home-landing { margin-bottom: 8px; }

.home-hero { text-align: center; padding: 40px 8px 32px; }
.home-hero-title { font-size: 1.55rem; font-weight: 900; line-height: 1.5; margin-bottom: 14px; letter-spacing: -0.01em; }
.home-hero-sub { font-size: 0.85rem; color: var(--k60); line-height: 1.9; margin-bottom: 24px; }
.home-cta { width: auto; display: inline-flex; padding: 14px 36px; font-size: 0.92rem; }

.home-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 32px; }
.home-feature { border: 1px solid var(--k10); border-radius: var(--r); padding: 16px; }
.home-feature-label { font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; }
.home-feature-text { font-size: 0.78rem; color: var(--k60); line-height: 1.7; }

.home-section { margin-bottom: 28px; }
.home-section-title { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--k60); margin-bottom: 14px; }

.home-howto { border: 1px solid var(--k10); border-radius: var(--r); overflow: hidden; }
.home-step { display: flex; align-items: flex-start; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--k10); }
.home-step:last-child { border-bottom: none; }
.home-step-num { width: 22px; height: 22px; background: var(--black); color: var(--white); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.home-step-title { font-size: 0.88rem; font-weight: 700; margin-bottom: 3px; }
.home-step-sub { font-size: 0.78rem; color: var(--k60); }

.home-faq { border: 1px solid var(--k10); border-radius: var(--r); overflow: hidden; }
.faq-item { border-bottom: 1px solid var(--k10); }
.faq-item:last-child { border-bottom: none; }
.faq-q { padding: 14px 16px; font-size: 0.85rem; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after { content: '＋'; font-size: 0.85rem; color: var(--k40); flex-shrink: 0; }
details[open] > .faq-q::after { content: '－'; }
.faq-a { padding: 0 16px 14px; font-size: 0.83rem; color: var(--k60); line-height: 1.85; }

@media (max-width: 600px) {
  .home-hero { padding: 28px 4px 24px; }
  .home-hero-title { font-size: 1.25rem; }
  .home-features { grid-template-columns: 1fr; gap: 8px; }
}

/* よていくんとは？ボタン（右下固定） */
.btn-about { position:fixed; bottom:24px; right:20px; background:var(--black); color:var(--white); border:none; border-radius:var(--r); font-family:inherit; font-size:0.88rem; font-weight:700; text-decoration:none; padding:12px 20px; box-shadow:0 4px 16px rgba(0,0,0,0.18); z-index:90; transition:all 0.15s; letter-spacing:0.03em; }
.btn-about:hover { background:var(--k80); box-shadow:0 6px 20px rgba(0,0,0,0.22); }

/* Footer */
.site-footer { text-align:center; padding:4px 0 8px; }
.footer-link { font-size:0.72rem; color:var(--k40); text-decoration:none; letter-spacing:0.04em; }
.footer-link:hover { color:var(--k60); text-decoration:underline; }
.ev-title-row { display:flex; justify-content:space-between; align-items:baseline; flex-wrap:wrap; gap:8px; margin-bottom:24px; }
.ev-title { font-size:1.3rem; font-weight:900; }
.ev-count { font-size:0.78rem; color:var(--k60); }
.hint { font-size:0.78rem; color:var(--k60); line-height:1.7; margin-bottom:14px; }

/* 締め切りバッジ */
.closed-badge { display:inline-block; background:#fff0f0; border:1px solid #f0b0b0; color:#c04040; font-size:0.68rem; font-weight:700; padding:2px 8px; border-radius:99px; letter-spacing:0.06em; }

/* イベント一覧 */
.event-list-card { border:1px solid var(--k10); border-radius:var(--r); padding:18px 20px; margin-bottom:10px; transition:border-color 0.15s, box-shadow 0.15s; }
.event-list-card:hover { border-color:var(--k40); box-shadow:0 2px 8px rgba(0,0,0,0.06); }
.event-list-card-hidden { opacity:0.75; }
.ev-list-header { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; margin-bottom:5px; }
.ev-list-name { font-size:1rem; font-weight:700; line-height:1.4; }
.ev-list-role { font-size:0.65rem; font-weight:700; padding:2px 8px; border-radius:99px; letter-spacing:0.06em; flex-shrink:0; white-space:nowrap; }
.ev-list-role-creator { background:var(--ok-light); color:var(--ok); }
.ev-list-role-participant { background:var(--k10); color:var(--k60); }
.ev-list-hidden { background:#f3f3f3; color:var(--k60); font-size:0.62rem; font-weight:700; padding:2px 8px; border-radius:99px; letter-spacing:0.06em; white-space:nowrap; }
.ev-list-date { font-size:0.78rem; color:var(--k60); margin-bottom:12px; }
.ev-list-created { font-size:0.72rem; color:var(--k60); margin-bottom:12px; }
.ev-list-actions { display:flex; gap:8px; }
.ev-list-actions-row { display:flex; align-items:flex-end; justify-content:space-between; gap:10px; }
.ev-list-actions .btn { white-space:nowrap; }
.btn-icon { width:36px; height:36px; padding:0; display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--k20); background:var(--white); color:var(--k80); border-radius:var(--r); font-size:0.9rem; }
.btn-icon:hover { border-color:var(--black); }
.event-list-empty { text-align:center; padding:60px 20px; }
.event-list-empty-icon { font-size:2.4rem; margin-bottom:12px; }
.event-list-empty p { font-size:0.88rem; color:var(--k60); }

/* ============================================================
   レスポンシブ — スマホ対応
   ============================================================ */

/* タブレット〜スマホ（600px以下） */
@media (max-width: 600px) {
  .header { padding: 10px 14px; gap: 8px; }
  .btn-home { font-size: 0.72rem; padding: 6px 10px; }

  #app { padding: 20px 12px 80px; }

  .card { padding: 16px; }
  .voted-box { padding: 20px 14px; }
  .event-list-card { padding: 14px 14px; }
  .modal-card { padding: 18px 14px; }

  /* ステップバー */
  .step { font-size: 0.65rem; padding: 8px 2px; letter-spacing: 0; }

  /* Nav tabs: 全幅に広げる */
  .nav-tabs { width: 100%; }
  .nav-tab { flex: 1; text-align: center; padding: 10px 6px; font-size: 0.78rem; }

  /* ボタン: タッチターゲット最低44px */
  .btn-primary { min-height: 50px; }
  .btn-secondary { min-height: 46px; }
  .toggle-btn { min-height: 44px; padding: 10px 6px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }

  /* イベント一覧: ボタンが折り返せるように */
  .ev-list-actions { flex-wrap: wrap; }
  .ev-list-actions .btn-sm { flex: 1; min-width: 72px; justify-content: center; }

  /* グリッドセル: 少し大きくしてドラッグしやすく */
  .grid-cell { height: 34px; }

  /* ツールチップ: モバイルでは位置を調整 */
  .cell-tip { font-size: 0.68rem; padding: 6px 9px; white-space: normal; min-width: 120px; max-width: 180px; }

  /* セクションタイトル */
  .section-head { margin-bottom: 18px; }

  /* コメント */
  .comment-item { padding: 8px 10px; }
}

/* 結果グリッド: 時間列（左端）を横スクロール時に固定 */
@media (max-width: 600px) {
  #result-grid .grid-row-label,
  #result-grid .grid-corner {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--white);
  }
}

/* 小型スマホ（380px以下） */
@media (max-width: 380px) {
  #app { padding: 16px 10px 80px; }
  .header { padding: 8px 10px; }
  .logo-text { font-size: 0.88rem; }
  .logo-sub { display: none; }
  .card { padding: 12px 10px; }

  .toggle-btn { font-size: 0.73rem; padding: 8px 3px; }
  .toggle-group { gap: 0; }

  .grid-col-label { font-size: 0.6rem; padding: 4px 2px; }
  .grid-row-label { font-size: 0.6rem; padding-right: 5px; }
  .grid-cell { height: 30px; }

  .ev-title { font-size: 1.1rem; }
  .ev-list-name { font-size: 0.92rem; }
  .section-label { font-size: 0.58rem; letter-spacing: 0.1em; }
}

/* ヒートマッププレビューモーダル */
.heatmap-modal-card { width: min(95vw, 500px); max-height: 80vh; overflow-y: auto; }
.heatmap-modal-card .grid-wrap { touch-action: pan-x pan-y; }
.grid-wrap:has(#heatmap-preview-grid) { touch-action: pan-x pan-y; }

/* 回答グリッド: タッチはJSで一元管理（1本指=選択, 2本指=スクロール） */
.grid-wrap {
  touch-action: none;
}
/* 結果グリッド: 1本指で横スクロール可（選択操作なし） */
.grid-wrap:has(#result-grid) {
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
