/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --secondary: #10b981;
  --secondary-dark: #059669;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e0f2fe;
  --text: #0c2340;
  --text-muted: #4a6fa5;
  --text-light: #64748b;
  --shadow: 0 1px 3px rgba(14,165,233,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(14,165,233,.1), 0 2px 4px rgba(0,0,0,.06);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ===== ユーティリティ ===== */
.hidden { display: none !important; }
.view { min-height: 100vh; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border-radius: var(--radius-sm); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; white-space: nowrap; gap: 6px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-dark); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.backup-section { margin-bottom: 4px; }
.backup-subtitle { font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 10px; }
.backup-btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.backup-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.backup-restore-row { display: flex; flex-direction: column; gap: 12px; }
.restore-item { display: flex; flex-direction: column; gap: 6px; }
.restore-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 16px; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-answered { background: #d1fae5; color: #065f46; }
.badge-archived { background: #f1f5f9; color: var(--text-muted); }

/* ===== 認証画面 ===== */
#auth-view {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.auth-container {
  background: var(--surface); border-radius: 20px;
  padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.logo { text-align: center; margin-bottom: 28px; }
.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.logo h1 { font-size: 28px; font-weight: 800; color: var(--primary); }
.version-badge { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; line-height: 1; }
.title-wrap { display: flex; flex-direction: column; gap: 2px; }
.logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }


.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px;
  transition: border-color .15s; outline: none;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ===== ヘッダー ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to right, #e0f2fe, #ffffff);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(14,165,233,.15);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 800; color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 10px; }
.username-badge {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
}

/* ===== ダッシュボード ===== */
.dashboard-main {
  max-width: 700px; margin: 0 auto; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 16px;
}

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

.join-form { display: flex; gap: 10px; }
.code-input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 18px; font-weight: 700;
  letter-spacing: 4px; text-transform: uppercase; outline: none;
  text-align: center; transition: border-color .15s;
}
.code-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.create-form { display: flex; gap: 10px; }
.create-form input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.create-form input:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px #d1fae5; }

.events-list { display: flex; flex-direction: column; gap: 10px; }
.event-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer;
  transition: all .15s;
}
.event-item:hover { border-color: var(--primary); background: var(--primary-light); }
.event-item-info { display: flex; flex-direction: column; gap: 2px; }
.event-item-title { font-weight: 600; font-size: 15px; }
.event-item-meta { font-size: 12px; color: var(--text-muted); }
.event-item-code {
  background: var(--primary); color: #fff;
  padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 700; letter-spacing: 2px;
}
.inactive-badge { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }

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

/* ===== イベント画面 ===== */
.event-info { display: flex; flex-direction: column; gap: 2px; }
.event-info h1 { font-size: 18px; font-weight: 700; line-height: 1.2; }
.event-code-badge { font-size: 12px; color: var(--text-muted); }
.event-code-badge strong { color: var(--primary); font-size: 14px; letter-spacing: 2px; }

.event-main {
  max-width: 680px; margin: 0 auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
}

/* 一般ユーザー：2カラムレイアウト */
.event-main-2col {
  max-width: 1200px;
  display: grid;
  grid-template-columns: 560px 1fr;
  gap: 20px;
  align-items: start;
}
.event-left-panel {
  position: sticky;
  top: 20px;
}
.event-right-panel {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.panel-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin: 0 0 14px 0; padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

@media (max-width: 700px) {
  .event-main-2col {
    grid-template-columns: 1fr;
  }
  .event-left-panel { position: static; }
}

.question-form-card { padding: 20px; overflow: visible; }
.question-input-wrapper textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; resize: both;
  outline: none; font-family: inherit; line-height: 1.5;
  transition: border-color .15s;
  min-width: 200px; min-height: 280px; overflow: auto;
  box-sizing: border-box;
}
.question-input-wrapper textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.question-form-footer {
  display: flex; align-items: center; justify-content: space-between; margin-top: 10px;
}
.form-actions { display: flex; align-items: center; gap: 6px; }
.char-count { font-size: 12px; color: var(--text-muted); }
.char-count.near-limit { color: var(--warning); }
.char-count.at-limit { color: var(--danger); }

/* ===== MD Help Button & Popover ===== */
.md-help-wrapper { position: relative; display: inline-flex; align-items: center; }
.md-help-btn {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-size: 11px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; padding: 0; flex-shrink: 0;
  transition: border-color .15s, color .15s; line-height: 1;
}
.md-help-btn:hover { border-color: var(--primary); color: var(--primary); }
.md-help-popover {
  display: none; position: absolute; bottom: calc(100% + 8px); right: 0;
  width: 280px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 12px 14px; z-index: 300; font-size: 13px; color: var(--text);
}
.md-help-popover.visible { display: block; }
.md-help-popover h4 { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.md-help-table { width: 100%; border-collapse: collapse; }
.md-help-table tr + tr td { border-top: 1px solid var(--border); }
.md-help-table td { padding: 4px 6px; vertical-align: middle; }
.md-help-table td:first-child { white-space: nowrap; width: 50%; }
.md-help-table code {
  background: var(--bg); padding: 1px 5px; border-radius: 4px;
  font-size: 11px; font-family: monospace; color: var(--primary-dark);
}

.md-help-popover.below {
  bottom: auto;
  top: calc(100% + 8px);
  right: auto;
  left: 0;
}

.filter-bar { display: flex; gap: 6px; }
.filter-btn {
  padding: 6px 16px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all .15s;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

.questions-list { display: flex; flex-direction: column; gap: 12px; }

.question-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 18px 20px;
  display: flex; gap: 16px; align-items: flex-start;
  box-shadow: var(--shadow); transition: all .2s;
  animation: fadeIn .3s ease;
  resize: both; overflow: auto;
  min-width: 280px; min-height: 80px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.question-card.answered { border-left: 3px solid var(--secondary); }
.question-card.archived { opacity: .55; }

.vote-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; min-width: 44px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  transition: all .15s; flex-shrink: 0;
}
.vote-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.vote-btn.voted { background: var(--primary); border-color: var(--primary); color: #fff; }
.vote-btn.voted .vote-icon { filter: brightness(0) invert(1); }
.vote-count { font-size: 14px; font-weight: 700; }
.vote-icon { font-size: 18px; }

.question-body { flex: 1; min-width: 0; }
.question-content { font-size: 15px; line-height: 1.7; word-break: break-word; margin-bottom: 10px; }
.question-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.question-author { font-weight: 600; color: var(--text); }

.admin-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-answered { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.btn-answered:hover { background: #a7f3d0; }
.btn-archive { background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border); }
.btn-archive:hover { background: var(--border); }
.btn-reopen { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #c7d2fe; }
.btn-reopen:hover { background: #c7d2fe; }
.user-question-actions { margin-top: 6px; }
.btn-withdraw { background: none; color: var(--text-muted); border: 1px solid var(--border); }
.btn-withdraw:hover { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .app-header { padding: 10px 14px; }
  .app-header h1 { font-size: 17px; }
  .dashboard-main, .event-main { padding: 16px 12px; }
  .event-main-2col { padding: 12px 10px; }
  .card { padding: 18px 16px; }
  .join-form, .create-form { flex-direction: column; }
  .question-card { padding: 14px; gap: 10px; }
}

/* ===== スレッド・返信 ===== */
.thread-toggle-bar { margin-top: 10px; }
.thread-toggle-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--primary); font-weight: 600;
  padding: 4px 0; display: flex; align-items: center; gap: 4px;
}
.thread-toggle-btn:hover { text-decoration: underline; }

.thread-section {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.thread-empty { font-size: 13px; color: var(--text-muted); }

.reply-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f0f4ff; border-radius: var(--radius-sm);
  padding: 10px 12px; border-left: 3px solid var(--primary);
  animation: fadeIn .25s ease;
}
.reply-avatar {
  font-size: 20px; flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); border-radius: 50%;
}
.reply-body { flex: 1; min-width: 0; }
.reply-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.reply-author { font-weight: 700; font-size: 13px; color: var(--primary-dark); }
.reply-admin-label {
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px; letter-spacing: .3px;
}
.reply-time { font-size: 11px; color: var(--text-muted); }
.reply-content { font-size: 14px; line-height: 1.6; word-break: break-word; color: var(--text); }
.btn-delete-reply {
  margin-top: 6px; background: none; border: none;
  color: var(--danger); font-size: 11px; cursor: pointer; padding: 0;
}
.btn-delete-reply:hover { text-decoration: underline; }

.reply-form-wrapper {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 12px; border: 1.5px dashed var(--border);
}
.reply-textarea {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px;
  font-family: inherit; resize: both; outline: none;
  transition: border-color .15s;
}
.reply-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.reply-form-footer { margin-top: 8px; display: flex; justify-content: flex-end; }

/* ===== 管理画面 ===== */
.admin-main {
  max-width: 1100px; margin: 0 auto; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 0;
}

.admin-tabs {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.admin-tab-btn {
  padding: 10px 22px; border: none; background: transparent;
  font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s;
}
.admin-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab-btn:hover:not(.active) { color: var(--text); }

.admin-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.create-user-form {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 20px; margin-bottom: 20px; border: 1.5px dashed var(--border);
}
.create-user-form h3 { font-size: 15px; margin-bottom: 14px; color: var(--text); }
.admin-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.admin-form-grid .form-group select {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; outline: none;
  background: var(--surface); width: 100%;
}
.admin-form-actions { display: flex; gap: 8px; margin-top: 14px; }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th {
  text-align: left; padding: 10px 12px; background: var(--bg);
  border-bottom: 2px solid var(--border); font-weight: 700;
  color: var(--text-muted); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:hover td { background: #fafbff; }
.table-scroll-wrap {
  overflow-y: auto;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.role-badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.role-admin { background: var(--primary-light); color: var(--primary-dark); }
.role-group_admin { background: #fef3c7; color: #92400e; }
.role-user  { background: #f1f5f9; color: var(--text-muted); }
.group-tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; background: #e0f2fe; color: #0369a1; margin: 1px 2px; white-space: nowrap; }
.group-user-check-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.group-user-check-row:hover { background: var(--primary-light); }
.group-user-check-row input[type="checkbox"] { flex-shrink: 0; width: 15px; height: 15px; cursor: pointer; }
.group-user-check-name { font-weight: 600; white-space: nowrap; }
.group-user-check-email { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-admin-card { border: 2px solid #fef3c7; background: linear-gradient(135deg, #fffbeb, #fef9ee); }
.group-admin-card-inner { display: flex; align-items: center; gap: 16px; }
.group-admin-card-icon { font-size: 32px; flex-shrink: 0; }
.group-admin-card-title { font-size: 15px; font-weight: 700; color: #92400e; margin: 0 0 4px; }
.group-admin-card-desc { font-size: 13px; color: #78350f; margin: 0; }
.group-admin-card-inner .btn { margin-left: auto; white-space: nowrap; flex-shrink: 0; }

.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-delete-user {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fca5a5;
}
.btn-delete-user:hover { background: #fca5a5; }

.status-dot { font-size: 13px; font-weight: 600; }
.status-dot.active { color: var(--secondary); }
.status-dot.inactive { color: var(--text-muted); }

@media (max-width: 700px) {
  .admin-form-grid { grid-template-columns: 1fr; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 8px; }
}

/* ===== すべてを見るボタン ===== */
.show-all-btn {
  margin-top: 8px;
  color: var(--primary);
  border-color: var(--primary);
}
.show-all-btn:hover { background: var(--primary-light); }

/* ===== ソートバー ===== */
.sort-bar {
  display: flex; align-items: center; gap: 6px;
}
.sort-label { font-size: 13px; color: var(--text-muted); }
.sort-btn {
  padding: 5px 14px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all .15s;
}
.sort-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.sort-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ===== ヘッダー内参加フォーム ===== */
.header-join-form {
  display: flex; align-items: center; gap: 6px;
}
.header-code-input {
  width: 110px; padding: 6px 10px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: 2px;
  text-transform: uppercase; background: var(--surface);
  color: var(--text);
}
.header-code-input:focus { outline: none; border-color: var(--primary); }
.error-msg-inline {
  font-size: 12px; color: var(--danger);
  white-space: nowrap;
}

/* ===== ユーザー返信 ===== */
.reply-item.reply-user {
  border-left: 3px solid var(--border);
}
.reply-item.reply-admin {
  border-left: 3px solid var(--primary);
}
.reply-item.reply-user .reply-avatar {
  background: #f0f0f0;
}

/* ===== 返信するリンク ===== */
.reply-toggle-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; padding: 4px 0;
  background: none; border: none; cursor: pointer;
  color: var(--primary); font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.reply-toggle-link:hover { text-decoration: underline; }

/* ===== 管理者ビュー グリーンテーマ ===== */
#admin-view,
#admin-view,
#event-admin-view {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --bg: #f8fffe;
  --border: #d1fae5;
}

/* 管理者ヘッダーの背景を薄いグリーンに */
#admin-view .app-header,
#event-admin-view .app-header {
  background: linear-gradient(to right, #dcfce7, #ffffff);
  border-bottom-color: #bbf7d0;
  box-shadow: 0 1px 4px rgba(22,163,74,.15);
}

/* 管理者タブのアクティブ色 */
#admin-view .admin-tab-btn.active {
  color: #16a34a;
  border-bottom-color: #16a34a;
}

/* 管理者バッジ */
.badge-admin {
  background: #dcfce7;
  color: #15803d;
}

/* ===== 添付ファイル ===== */
.hidden-file-input { display: none; }
.attach-btn { cursor: pointer; }

.file-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-top: 6px;
  background: var(--primary-light); border-radius: 8px;
  font-size: 13px;
}
.file-preview-name { font-weight: 600; color: var(--primary-dark); }
.file-preview-size { color: var(--text-muted); }

.attachments-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 8px;
}
.attachment-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 12px; color: var(--text); text-decoration: none;
  transition: border-color .15s;
}
.attachment-item:hover { border-color: var(--primary); color: var(--primary); }
.attachment-image { flex-direction: column; padding: 6px; }
.attachment-thumb {
  max-width: 200px; max-height: 150px;
  border-radius: 6px; object-fit: cover;
  display: block;
}
.attachment-name { font-size: 11px; color: var(--text-muted); }
.attachment-size { color: var(--text-muted); }

/* ===== アップロード設定 ===== */
.upload-settings-form { max-width: 600px; }
.settings-type-shortcuts {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.type-badge {
  padding: 3px 10px; border-radius: 20px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: all .15s;
}
.type-badge:hover { border-color: var(--primary); }

/* ===== SMTP設定 ===== */
.smtp-toggle-row {
  margin-bottom: 16px;
}
.toggle-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; cursor: pointer; font-size: 15px;
}
.toggle-label input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer;
  accent-color: var(--primary);
}

/* ===== 未回答アラート ===== */
.unanswered-alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 12px;
  background: #fef2f2; border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  color: #dc2626; font-size: 14px; font-weight: 600;
  animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
  0%, 100% { border-color: #fca5a5; }
  50%       { border-color: #ef4444; }
}

/* イベント一覧の未回答バッジ */
.unanswered-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  background: #fef2f2; color: #dc2626;
  font-size: 11px; font-weight: 700;
  border: 1px solid #fca5a5;
  animation: pulse-border 2s infinite;
}
.event-item.has-unanswered {
  border-left: 3px solid #ef4444;
}

/* ===== 参加済みイベント ドロップダウン ===== */
.event-dropdown-wrapper {
  position: relative;
}
.event-dropdown-btn {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; white-space: nowrap;
}
.event-dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 260px; max-height: 340px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
}
.dropdown-header {
  padding: 10px 14px 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-light); letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.dropdown-event-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; gap: 8px;
  transition: background .15s;
}
.dropdown-event-item:hover { background: var(--bg); }
.dropdown-event-item.active { background: #eff6ff; }
.dropdown-event-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropdown-event-meta {
  font-size: 11px; color: var(--text-light);
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.dot-active  { color: #16a34a; font-size: 10px; }
.dot-inactive { color: #9ca3af; font-size: 10px; }
.dropdown-empty {
  padding: 16px 14px; font-size: 13px; color: var(--text-light); text-align: center;
}

/* ===== ドロップダウン内 参加フォーム ===== */
.dropdown-join-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.dropdown-join-form {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 14px 4px;
}
.dropdown-join-form input {
  flex: 1; padding: 5px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none;
}
.dropdown-join-form input:focus {
  border-color: var(--primary);
}

/* ===== モーダル共通 ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 420px; padding: 0;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-close-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-light);
  line-height: 1; padding: 2px 6px;
}
.modal-close-btn:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body .form-group { display: flex; flex-direction: column; gap: 6px; }
.modal-body .form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.modal-body .form-group input {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none;
}
.modal-body .form-group input:focus { border-color: var(--primary); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}
.hint { font-size: 11px; color: var(--text-light); font-weight: 400; }
.success-msg {
  padding: 8px 12px; background: #f0fdf4; color: #16a34a;
  border: 1px solid #86efac; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; text-align: center;
}

/* ===== パスワードポリシー ===== */
.policy-preview {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px;
  padding: 10px 12px; background: #f0fdf4;
  border: 1px solid #86efac; border-radius: var(--radius-sm);
}
.policy-preview-title { width: 100%; font-size: 12px; font-weight: 700; color: #15803d; }
.policy-rule {
  font-size: 12px; color: #166534;
  background: #dcfce7; border-radius: 20px;
  padding: 2px 10px;
}
.policy-hint {
  font-size: 12px; color: #6b7280; margin-top: 4px;
  padding: 6px 8px; background: #f9fafb;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.policy-hint strong { color: var(--text); }

/* ===== ログイン画面 補助リンク ===== */
.auth-links {
  text-align: center; margin-top: 12px;
}
.auth-links a {
  font-size: 13px; color: var(--primary); text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }
.auth-sub-title {
  font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text);
}
.auth-desc {
  font-size: 13px; color: var(--text-light); margin-bottom: 16px; line-height: 1.6;
}

/* ===== 3カラムヘッダー（一般ユーザーイベント画面） ===== */
.app-header-3col {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.app-header-3col .header-left  { justify-self: start; }
.app-header-3col .header-center { justify-self: center; text-align: center; }
.app-header-3col .header-right { justify-self: end; }

.header-site-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  letter-spacing: .01em;
}

.event-info-center h1 {
  font-size: 20px; font-weight: 700; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 360px;
}
.event-info-center .event-code-badge {
  font-size: 13px;
}

/* ===== 参加者管理モーダル ===== */
.modal-box-lg { max-width: 560px; }

.participants-add-row {
  display: flex; gap: 8px; align-items: center;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.participants-select {
  flex: 1; padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; background: #fff;
}
.participants-select:focus { border-color: var(--primary); }

.participants-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 320px; overflow-y: auto;
}
.participant-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff;
  gap: 8px;
}
.participant-row:hover { background: var(--bg); }
.participant-info {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.participant-name { font-size: 14px; font-weight: 600; color: var(--text); }
.participant-email { font-size: 12px; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== リアクション（ピッカー形式） ===== */
.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}
/* 反応済み・カウント表示ピル */
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  line-height: 1.4;
}
.reaction-pill:hover { background: #f0f9ff; border-color: var(--primary); }
.reaction-pill.reaction-mine {
  background: #e0f2fe;
  border-color: var(--primary);
  font-weight: 600;
}
.reaction-pill span { font-size: 12px; font-weight: 600; }

/* ＋ボタン（ピッカーを開く） */
.reaction-picker-wrap { position: relative; }
.reaction-add-btn {
  padding: 2px 8px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
  line-height: 1.4;
  white-space: nowrap;
}
.reaction-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg);
}

/* ドロップダウン */
.reaction-picker-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  gap: 2px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  white-space: nowrap;
}
.reaction-picker-dropdown.hidden { display: none; }
.picker-emoji-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: all 0.12s;
}
.picker-emoji-btn:hover {
  background: var(--bg);
  border-color: var(--border);
  transform: scale(1.2);
}
.picker-emoji-btn.picker-active {
  background: #e0f2fe;
  border-color: var(--primary);
}

/* ===== 管理者返信トースト通知 ===== */
#reply-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 320px;
}
.reply-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  pointer-events: all;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s, transform 0.3s;
}
.reply-toast.reply-toast-show {
  opacity: 1;
  transform: translateX(0);
}
.reply-toast-icon { font-size: 22px; flex-shrink: 0; }
.reply-toast-body { flex: 1; min-width: 0; }
.reply-toast-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}
.reply-toast-preview {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-toast-go {
  flex-shrink: 0;
  padding: 4px 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.reply-toast-go:hover { background: var(--primary-dark, #0284c7); }
.reply-toast-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}
.reply-toast-close:hover { background: var(--surface); }
/* 返信ハイライト（スクロール後の点滅） */
.reply-highlight {
  animation: reply-flash 0.5s ease-in-out 3;
}
@keyframes reply-flash {
  0%,100% { background: inherit; }
  50%      { background: #fef9c3; }
}

/* ===== イベントタイトルインライン編集 ===== */
.event-title-cell { min-width: 160px; }
.event-title-edit { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.event-title-input {
  padding: 4px 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 14px;
  width: 200px;
  outline: none;
}

/* ===== CSV 一括操作 ===== */
.csv-card { margin-top: 20px; }
.csv-dl-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.csv-hint { font-size: 13px; color: var(--text-light); margin: 2px 0; }
.csv-hint code { background: var(--surface); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.csv-dl-btns { display: flex; gap: 8px; flex-shrink: 0; }
.csv-ops-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) { .csv-ops-row { grid-template-columns: 1fr; } }
.csv-op-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.csv-op-box h3 { font-size: 15px; font-weight: 700; margin: 0; }
.csv-file-input {
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}
.csv-result {
  font-size: 13px;
  background: var(--surface);
  border-radius: 6px;
  padding: 10px 12px;
}
.csv-result.hidden { display: none; }
.csv-result-loading { color: var(--text-light); }
.csv-result-error { background: #fff1f2; color: var(--danger); }
.csv-summary { font-weight: 600; margin-bottom: 6px; }
.csv-detail-list {
  margin: 0;
  padding-left: 16px;
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
}
.csv-detail-list li { margin: 2px 0; font-size: 12px; }

/* ===== CSV 登録履歴 ===== */
.csv-history-section { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.csv-history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.csv-history-header h3 { margin: 0; font-size: 15px; }
.csv-history-table { font-size: 13px; }
.csv-hist-ok  { color: #16a34a; font-weight: 600; text-align: center; }
.csv-hist-skip { color: var(--text-light); text-align: center; }
.csv-hist-err  { color: var(--danger); font-weight: 600; text-align: center; }

/* ===== 分析ページ ===== */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.analytics-kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.kpi-icon { font-size: 22px; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 700px) { .analytics-row { grid-template-columns: 1fr; } }
.analytics-card { margin-bottom: 0 !important; }
.analytics-card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; }

/* 棒グラフ共通 */
.analytics-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.analytics-bar-label {
  width: 90px;
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.analytics-bar-label--wide { width: 160px; white-space: normal; line-height: 1.3; }
.analytics-bar-track {
  flex: 1;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.analytics-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.analytics-bar-val { font-size: 12px; color: var(--text-light); flex-shrink: 0; min-width: 44px; text-align: right; }

/* 日別チャート */
.analytics-daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  padding-bottom: 28px;
  overflow-x: auto;
}
.analytics-day-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.day-bars { display: flex; align-items: flex-end; gap: 2px; height: 80px; }
.day-bar { width: 10px; border-radius: 3px 3px 0 0; min-height: 2px; transition: height 0.3s; }
.day-bar-q { background: #0ea5e9; }
.day-bar-r { background: #10b981; }
.day-label { font-size: 10px; color: var(--text-light); margin-top: 4px; white-space: nowrap; }
.analytics-legend { font-size: 12px; color: var(--text-light); display: flex; gap: 12px; margin-top: 4px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* TOP ユーザー 2カラム */
.analytics-top-users-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .analytics-top-users-grid { grid-template-columns: 1fr; } }
.analytics-sub-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--text-light); }

/* イベント別回答率バー */
.analytics-rate-bar {
  position: relative;
  height: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-width: 80px;
}
.analytics-rate-fill { height: 100%; background: #10b981; border-radius: 8px; }
.analytics-rate-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.4);
}

#admin-view .analytics-kpi-card .kpi-value,
#event-admin-view .analytics-kpi-card .kpi-value { color: var(--primary); }

/* ===== FAQ (一般ユーザー左パネル) ===== */
.faq-panel-card { margin-top: 16px; padding: 16px; }
.faq-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.faq-panel-header .panel-title { margin: 0; }
#faq-list { max-height: 400px; overflow-y: auto; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-question-btn {
  width: 100%; display: flex; align-items: flex-start; gap: 8px;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 10px 4px; color: var(--text-primary); font-size: 0.9rem;
}
.faq-question-btn:hover { background: var(--bg-secondary); border-radius: 6px; }
.faq-q-icon {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: white; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.faq-q-text { flex: 1; line-height: 1.4; }
.faq-chevron { flex-shrink: 0; font-size: 0.7rem; color: var(--text-secondary); margin-top: 4px; }
.faq-answer {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 4px 12px 30px; color: var(--text-secondary); font-size: 0.88rem;
}
.faq-a-icon {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--success, #22c55e); color: white; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.faq-answer p { margin: 0; line-height: 1.5; }

/* ===== FAQ 管理者 ===== */
.admin-faq-form { display: flex; flex-direction: column; gap: 12px; max-width: 700px; }
.admin-faq-form .form-row { display: flex; gap: 16px; flex-wrap: wrap; }
#admin-view .faq-cell-question,
#admin-view .faq-cell-answer { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* FAQに追加ボタン */
.btn-faq {
  background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0;
}
.btn-faq:hover { background: #dcfce7; }

/* ===== グループ管理 ===== */
.group-checkbox-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.group-checkbox-item {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px; font-size: 0.85rem;
}
.group-checkbox-item input { cursor: pointer; }

#admin-view .btn-danger {
  background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
}
#admin-view .btn-danger:hover { background: #fee2e2; }

#group-detail-panel { border-top: 3px solid var(--primary); }

/* 分析グループフィルター */
.analytics-filter-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 10px 16px;
  background: var(--bg-secondary); border-radius: 8px;
  font-size: 0.9rem; flex-wrap: wrap;
}
.analytics-tab-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.analytics-tab-title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.analytics-filter-bar select { min-width: 160px; }
.analytics-filter-bar input[type="date"] {
  padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-primary);
  color: var(--text-primary); font-size: 0.9rem;
  cursor: pointer;
}
.analytics-filter-bar input[type="date"]:focus {
  outline: none; border-color: var(--primary);
}
.analytics-date-sep { color: var(--text-secondary); }

/* ===== イベント作成グループ制限 ===== */
.event-group-restrict { margin-top: 6px; }
.event-group-toggle-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; cursor: pointer; font-size: 0.85rem;
  color: var(--text-secondary); width: 100%; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
}
.event-group-toggle-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.event-group-toggle-hint { font-size: 0.8rem; color: var(--text-secondary); }
.event-group-hint-text { font-size: 0.82rem; color: var(--text-secondary); margin: 6px 0 4px; }
#event-group-list {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px; font-size: 0.88rem; background: var(--bg-primary);
  color: var(--text-primary); margin-top: 4px;
}
#event-group-list option { padding: 4px 6px; }
#event-group-list option:checked { background: var(--primary); color: white; }

/* ===== AI生成ボタン ===== */
.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white; border: none; font-size: 0.8rem;
  transition: opacity 0.15s;
}
.btn-ai:hover { opacity: 0.85; }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }

#admin-view .ai-settings-form .form-group,
#admin-view #ai-settings-form .form-group { margin-bottom: 14px; }
#admin-view #ai-settings-form input[type="url"],
#admin-view #ai-settings-form input[type="text"],
#admin-view #ai-settings-form input[type="password"],
#admin-view #ai-settings-form input[type="number"],
#admin-view #ai-settings-form textarea { width: 100%; }

/* ===== 成り代わり（代理投稿）フォーム ===== */
.admin-post-form-details { margin-bottom: 12px; }
.admin-post-form-summary {
  cursor: pointer; font-size: 0.88rem; font-weight: 600;
  color: var(--primary); padding: 6px 0; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 4px;
}
.admin-post-form-summary::-webkit-details-marker { display: none; }
.admin-post-form-card { margin-top: 8px; padding: 12px 14px; }
.admin-post-form-card .form-group { margin-bottom: 8px; }
.admin-post-form-card .form-hint { font-size: 0.78rem; color: var(--text-secondary); font-weight: 400; }
.admin-post-form-card .form-input,
.admin-post-form-card .form-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 0.88rem; background: var(--bg-primary);
  color: var(--text-primary); box-sizing: border-box;
}
.admin-post-form-card .form-textarea { resize: vertical; }
.admin-post-form-card .form-row-end { display: flex; justify-content: flex-end; }

/* 返信フォームの表示名入力 */
.reply-impersonate-input {
  width: 100%; border: 1px solid var(--border); border-radius: 5px;
  padding: 4px 8px; font-size: 0.82rem; background: var(--bg-secondary);
  color: var(--text-primary); box-sizing: border-box; margin-bottom: 6px;
}
.reply-impersonate-input::placeholder { color: var(--text-secondary); }

/* ===== Markdown レンダリング ===== */
.md-body { word-break: break-word; line-height: 1.7; }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body p { margin: 0 0 .6em; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { font-weight: 700; margin: .8em 0 .3em; line-height: 1.3; }
.md-body h1 { font-size: 1.2em; }
.md-body h2 { font-size: 1.1em; }
.md-body h3 { font-size: 1em; }
.md-body ul, .md-body ol { padding-left: 1.4em; margin: .4em 0; }
.md-body li { margin: .15em 0; }
.md-body code { background: var(--bg-secondary); border-radius: 3px; padding: .1em .35em; font-size: .88em; font-family: monospace; }
.md-body pre { background: var(--bg-secondary); border-radius: 6px; padding: .75em 1em; overflow-x: auto; margin: .5em 0; }
.md-body pre code { background: none; padding: 0; font-size: .85em; }
.md-body blockquote { border-left: 3px solid var(--border); margin: .4em 0; padding: .2em .8em; color: var(--text-muted); }
.md-body a { color: var(--primary); text-decoration: underline; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: .6em 0; }
.md-body table { border-collapse: collapse; width: 100%; font-size: .9em; margin: .5em 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: .3em .6em; text-align: left; }
.md-body th { background: var(--bg-secondary); font-weight: 600; }

/* ===== インライン編集フォーム ===== */
.edit-inline-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.edit-textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1.5px solid var(--primary); border-radius: 6px; font-size: 14px; line-height: 1.6; resize: both; font-family: inherit; background: var(--bg); color: var(--text); }
.edit-inline-actions { display: flex; gap: 6px; }
.btn-edit { color: var(--text-muted); border-color: var(--border); }
.btn-edit:hover { color: var(--primary); border-color: var(--primary); }

/* ===== 印刷（PDF保存）スタイル ===== */
@media print {
  /* 分析タブ以外を全て非表示 */
  body > #app > *:not(#admin-view) { display: none !important; }
  #admin-view .app-header,
  #admin-view .admin-tabs,
  .admin-tab-content:not(#admin-analytics-tab),
  .analytics-filter-bar,
  .analytics-pdf-btn,
  #analytics-pdf-btn-top { display: none !important; }

  /* 分析タブを表示 */
  #admin-view,
  #admin-analytics-tab { display: block !important; visibility: visible !important; }

  /* 印刷ヘッダー */
  #analytics-print-header { display: block !important; }

  /* レイアウト調整 */
  body { background: white; margin: 0; font-size: 11pt; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 12pt; }
  .analytics-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12pt; }
  .analytics-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8pt; }
  .analytics-kpi-card { border: 1px solid #ccc; padding: 8pt; text-align: center; }
  .kpi-value { font-size: 18pt; font-weight: 700; }
  .kpi-label { font-size: 9pt; color: #666; }

  /* バーチャートの色を印刷向けに調整 */
  .analytics-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* ページ設定 */
  @page { margin: 15mm; size: A4; }
}

/* 印刷ヘッダー（通常時は非表示） */
#analytics-print-header { display: none; }
