:root {
  --primary: #1976d2;
  --primary-hover: #1565c0;
  --primary-light: #eef2f7;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --warning: #ef6c00;
  --warning-light: #fff3e0;
  --danger: #c62828;
  --danger-light: #fde8e8;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --border: #e0e4ea;
  --text: #333333;
  --text-muted: #555555;
  --radius: 10px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.08);
  /* バッジ用カラー (以前のGAS版完全復元: ソリッドカラー+白文字) */
  --badge-sesshin-bg: #6a1b9a;
  --badge-sesshin-text: #ffffff;
  --badge-sesshin-border: #6a1b9a;
  --badge-reinou-bg: #ef6c00;
  --badge-reinou-text: #ffffff;
  --badge-reinou-border: #ef6c00;
  --badge-soubukai-bg: #00695c;
  --badge-soubukai-text: #ffffff;
  --badge-soubukai-border: #00695c;
  --badge-manual-bg: #546e7a;
  --badge-manual-text: #ffffff;
  --badge-manual-border: #546e7a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121820;
    --card-bg: #1e2632;
    --border: #2e3846;
    --text: #f0f4f8;
    --text-muted: #9aa5b5;
    --primary-light: #15325b;
    --success-light: #0d381e;
    --warning-light: #442407;
    --danger-light: #401010;
    /* バッジ用カラー (ダークモード) */
    --badge-sesshin-bg: #7b1fa2;
    --badge-sesshin-text: #ffffff;
    --badge-sesshin-border: #7b1fa2;
    --badge-reinou-bg: #f57c00;
    --badge-reinou-text: #ffffff;
    --badge-reinou-border: #f57c00;
    --badge-soubukai-bg: #00796b;
    --badge-soubukai-text: #ffffff;
    --badge-soubukai-border: #00796b;
    --badge-manual-bg: #607d8b;
    --badge-manual-text: #ffffff;
    --badge-manual-border: #607d8b;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 16px 12px calc(80px + env(safe-area-inset-bottom, 0px));
  max-width: 680px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 20px;
  padding: 12px 0;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 8px;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

p.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--card-bg);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

input[type="file"] {
  display: none;
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 13px;
}

.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  width: auto;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 13px;
}

.action-btn {
  width: auto;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13px;
  flex: 0 0 auto;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: #a8c4e0;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  background: var(--primary-light);
  border: 1px solid #d0d7de;
  color: #1565c0;
}

.btn-secondary:hover {
  background: #e2eaf4;
  border-color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.progress-container {
  display: none;
  margin-top: 16px;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.progress-status {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-sesshin {
  background: var(--badge-sesshin-bg);
  color: var(--badge-sesshin-text);
  border-color: var(--badge-sesshin-border);
}
.badge-reinou {
  background: var(--badge-reinou-bg);
  color: var(--badge-reinou-text);
  border-color: var(--badge-reinou-border);
}
.badge-soubukai {
  background: var(--badge-soubukai-bg);
  color: var(--badge-soubukai-text);
  border-color: var(--badge-soubukai-border);
}
.badge-manual {
  background: var(--badge-manual-bg);
  color: var(--badge-manual-text);
  border-color: var(--badge-manual-border);
}

.event-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fafbfc;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  .event-card {
    background: var(--card-bg);
  }
}

.event-card:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

/* 44x44px 以上のタップターゲットを確保するラッパー */
.event-checkbox-wrap {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: -6px 0 -6px -6px;
  touch-action: manipulation;
  border-radius: 8px;
}

.event-checkbox {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

.event-content {
  flex: 1;
  min-width: 0;
}

.event-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 4px;
}

.event-date {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.event-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}

/* iOS Safari 自動ズーム防止: 16px 以上必須 */
.event-title-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 8px;
  min-height: 40px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.event-title-input:focus {
  border-color: var(--primary);
  background: var(--bg);
  outline: none;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* 44x44px タップターゲットの削除ボタン (以前のGAS版スタイル: 薄赤背景に赤文字) */
.btn-delete {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
  margin: -6px -6px -6px 0;
  touch-action: manipulation;
}

.btn-delete:hover, .btn-delete:focus {
  background: #fcd0d0;
  color: var(--danger);
  outline: none;
}

.btn-delete:active {
  transform: scale(0.92);
}

.action-bar {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 8px;
  align-items: center;
  backdrop-filter: blur(8px);
}

.summary-banner {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  touch-action: manipulation;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* インラインアラート通知バナー */
.alert-banner {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow);
}

.alert-banner.info {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--text);
}

.alert-banner.warning {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: var(--text);
}

.alert-banner.error {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--text);
}

.alert-banner-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: -1px;
}

.alert-banner-content {
  flex: 1;
}

.alert-banner-close {
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
}

/* 抽出0件時の空状態 (Empty State) */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 12px;
  line-height: 1.6;
  max-width: 440px;
  margin: 0 auto;
}

canvas#pdfCanvas {
  display: none;
}
