:root {
  --bg: #EFF1ED;
  --white: #FFFFFF;
  --accent: #3DAA6A;
  --accent-hover: #329059;
  --accent-light: #EAF5EF;
  --border: #DDE0DB;
  --text: #2C332E;
  --text-muted: #5A6860;
  --text-light: #9AADA3;
  --connpass: #F97316;
  --peatix: #E11D48;
  --luma: #7C3AED;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: block;
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 14px 8px 36px;
  border-radius: 20px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--white);
}

.search-input::placeholder { color: var(--text-light); }

.header-right { margin-left: auto; }

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

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

#refreshIcon {
  font-size: 16px;
  display: inline-block;
}

.btn-refresh.loading #refreshIcon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── App layout ── */
.app-body {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 16px 20px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.sidebar-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.date-input:focus { border-color: var(--accent); }
.date-sep { color: var(--text-light); font-size: 12px; flex-shrink: 0; }

.sidebar-search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.sidebar-search-input:focus { border-color: var(--accent); }
.sidebar-search-input::placeholder { color: var(--text-light); }

/* Checkboxes */
.check-group, .radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-item, .radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
}

.check-item input, .radio-item input { display: none; }

.checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: var(--white);
}

.check-item input:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.check-item input:checked ~ .checkmark::after {
  content: '';
  display: block;
  width: 4px;
  height: 7px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.radiomark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: var(--white);
}

.radio-item input:checked ~ .radiomark {
  border-color: var(--accent);
}

.radio-item input:checked ~ .radiomark::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.source-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.check-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-light);
}

.sidebar-actions {
  margin-top: auto;
  border-bottom: none;
}

.btn-apply {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.2s;
}

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

.btn-clear {
  width: 100%;
  padding: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-clear:hover { color: var(--text); }

/* ── Main content ── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Week strip ── */
.week-strip {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 10px 20px;
  gap: 6px;
  position: sticky;
  top: 58px;
  z-index: 10;
}

.week-nav {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
  padding: 0;
}

.week-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.week-days {
  display: flex;
  flex: 1;
  justify-content: space-around;
  gap: 2px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 42px;
  transition: background 0.15s, color 0.15s;
  color: var(--text);
}

.week-day:hover { background: var(--accent-light); }

.week-day.today {
  background: var(--accent);
  color: white;
}

.week-day.selected:not(.today) {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.week-day-name {
  font-size: 11px;
  opacity: 0.75;
  line-height: 1;
  margin-bottom: 3px;
}

.week-day.sat { color: #2563EB; }
.week-day.sun { color: #DC2626; }
.week-day.today.sat, .week-day.today.sun { color: white; }

.week-day-num {
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

/* ── Toolbar ── */
.events-toolbar {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
}

.status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.error-bar {
  flex: 1;
  padding: 8px 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  font-size: 13px;
  color: #DC2626;
}

.toolbar-info { flex: 1; }

.event-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.count-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 2px;
}

.toolbar-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

.sort-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  cursor: pointer;
}

.prefecture-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.prefecture-select:focus { border-color: var(--accent); }

/* ── Events list ── */
.events-list {
  padding: 12px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Event item ── */
.event-item {
  display: flex;
  gap: 16px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
  align-items: flex-start;
}

.event-item:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: #C8D5CC;
}

.event-item-thumb {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.event-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.event-item-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: linear-gradient(135deg, #E4EDE7, #D0E5D8);
}

.event-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.event-item-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.event-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.event-item-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.source-badge.connpass { background: rgba(249,115,22,0.12); color: #C95C0A; }
.source-badge.peatix   { background: rgba(225,29,72,0.12);  color: #B81539; }
.source-badge.luma     { background: rgba(124,58,237,0.12); color: #6228C4; }

.participants-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Skeleton loader ── */
.skeleton {
  background: linear-gradient(90deg, #E8EBE8 25%, #F2F4F1 50%, #E8EBE8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-item {
  height: 108px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-sub  { font-size: 13px; color: var(--text-light); margin-top: 8px; }

/* ── Footer ── */
.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.footer a { color: var(--text-muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .sidebar { display: none; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 12px; gap: 10px; }
  .logo-sub { display: none; }
  .events-list { padding: 10px 12px 24px; }
  .week-strip { padding: 8px 10px; }
  .events-toolbar { padding: 10px 12px; }
  .week-day { min-width: 34px; padding: 4px 4px; }
  .week-day-num { font-size: 16px; }
  .event-item-thumb { display: none; }
  .event-item { padding: 12px; }
}
