:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1f2a30;
  --muted: #5d6a70;
  --line: #e2ddd2;
  --brand: #0e6e8c;
  --brand-ink: #ffffff;
  --accent: #e8833a;
  --today: #fff4e2;
  --sun: #c2410c;
  --sat: #1d5fa8;
  --shadow: 0 1px 2px rgba(30, 40, 50, .06), 0 4px 16px rgba(30, 40, 50, .06);
  /* カテゴリ色 */
  --c-hanabi: #d9480f;
  --c-matsuri: #c2255c;
  --c-ichi: #2b8a3e;
  --c-light: #b08900;
  --c-sports: #1c7ed6;
  --c-nature: #5c940d;
  --c-culture: #7048e8;
  --c-taiken: #0c8599;
  --c-other: #6b7280;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12181b; --surface: #1a2226; --surface-2: #222c31; --text: #e8edef; --muted: #9aa7ad;
    --line: #2e3a40; --brand: #4fb3d1; --brand-ink: #0b1316; --accent: #f0a060; --today: #2b2618;
    --sun: #ff8a65; --sat: #7fb2ff; --shadow: none;
    --c-hanabi: #ff8a50; --c-matsuri: #f06595; --c-ichi: #51cf66; --c-light: #fcc419; --c-sports: #4dabf7;
    --c-nature: #94d82d; --c-culture: #9775fa; --c-taiken: #3bc9db; --c-other: #adb5bd;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12181b; --surface: #1a2226; --surface-2: #222c31; --text: #e8edef; --muted: #9aa7ad;
  --line: #2e3a40; --brand: #4fb3d1; --brand-ink: #0b1316; --accent: #f0a060; --today: #2b2618;
  --sun: #ff8a65; --sat: #7fb2ff; --shadow: none;
  --c-hanabi: #ff8a50; --c-matsuri: #f06595; --c-ichi: #51cf66; --c-light: #fcc419; --c-sports: #4dabf7;
  --c-nature: #94d82d; --c-culture: #9775fa; --c-taiken: #3bc9db; --c-other: #adb5bd;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 15px; line-height: 1.6;
}
a { color: var(--brand); }
button { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M4 21c4-4 8 4 12 0s8 4 12 0v7H4z' fill='%23fff'/%3E%3Ccircle cx='22' cy='10' r='4' fill='%23ffb347'/%3E%3C/svg%3E") center/100% no-repeat;
}
.brand-name { display: block; font-family: "Zen Maru Gothic", sans-serif; font-weight: 700; font-size: 18px; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: var(--muted); }
.header-nav { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.header-nav a { text-decoration: none; }
.btn-submit { background: var(--accent); color: #fff !important; padding: 7px 12px; border-radius: 999px; font-weight: 700; white-space: nowrap; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 12px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav h1 { font-family: "Zen Maru Gothic", sans-serif; font-size: 24px; margin: 0 6px; min-width: 7.5em; text-align: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 20px; line-height: 1; cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover, .text-btn:hover { border-color: var(--brand); }
.text-btn { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; margin-left: 4px; }
.view-toggle { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.view-toggle button { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.view-toggle button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }

/* filters */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  --c: var(--c-other);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px 4px 10px;
  cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; font-weight: 700; }
.chip[aria-pressed="true"]::before { background: #fff; }
.filter-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 10px; font-size: 13px; }
.select { display: inline-flex; align-items: center; gap: 8px; }
.select select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* category colors */
[data-cat="花火"] { --c: var(--c-hanabi); }
[data-cat="祭り"] { --c: var(--c-matsuri); }
[data-cat="市・マルシェ"] { --c: var(--c-ichi); }
[data-cat="ライトアップ"] { --c: var(--c-light); }
[data-cat="スポーツ"] { --c: var(--c-sports); }
[data-cat="花・自然"] { --c: var(--c-nature); }
[data-cat="文化・クラフト"] { --c: var(--c-culture); }
[data-cat="体験"] { --c: var(--c-taiken); }
[data-cat="グルメ・出店"] { --c: #e67700; }
[data-cat="講座・交流"] { --c: #5f3dc4; }
[data-cat="音楽・ナイト"] { --c: #a61e4d; }
[data-cat="その他"] { --c: var(--c-other); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-cat="グルメ・出店"] { --c: #ffa94d; }
  :root:not([data-theme="light"]) [data-cat="講座・交流"] { --c: #b197fc; }
  :root:not([data-theme="light"]) [data-cat="音楽・ナイト"] { --c: #f783ac; }
}

/* calendar */
.calendar { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head span { text-align: center; font-size: 12px; font-weight: 700; padding: 8px 0; color: var(--muted); background: var(--surface-2); }
.cal-head .sun, .day.sun .num { color: var(--sun); }
.cal-head .sat, .day.sat .num { color: var(--sat); }
.day {
  min-height: 112px; border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; background: var(--surface);
  text-align: left; cursor: default;
}
.day:nth-child(7n+1) { border-left: 0; }
.day.out { background: var(--surface-2); }
.day.out .num { opacity: .45; }
.day.today { background: var(--today); }
.day.today .num { background: var(--accent); color: #fff !important; border-radius: 999px; padding: 0 7px; }
.num { font-size: 12px; font-weight: 700; align-self: flex-start; }
.ev {
  --c: var(--c-other);
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c);
  border-radius: 4px; padding: 1px 5px; font-size: 11.5px; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev:hover { background: color-mix(in srgb, var(--c) 26%, transparent); }
.ev.recurring { opacity: .7; border-left-style: dotted; }
.ev.approx { border-left-style: dashed; }
.more { font-size: 11px; color: var(--muted); border: 0; background: none; text-align: left; padding: 0 4px; cursor: pointer; }
.dots { display: none; }
.day-panel { border-top: 1px solid var(--line); padding: 12px; }
.day-panel h3 { margin: 0 0 8px; font-size: 15px; }

/* list */
.list { display: flex; flex-direction: column; gap: 18px; }
.list h2 { font-family: "Zen Maru Gothic", sans-serif; font-size: 18px; margin: 4px 0 8px; }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card {
  --c: var(--c-other);
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 12px; padding: 12px 14px; text-align: left; cursor: pointer; width: 100%;
  display: flex; flex-direction: column; gap: 4px;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--c); }
.card .when { font-size: 13px; font-weight: 700; color: var(--c); }
.card .title { font-weight: 700; font-size: 15px; line-height: 1.4; }
.card .meta { font-size: 12.5px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { --c: var(--c-other); font-size: 11px; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--text); }
.empty { color: var(--muted); padding: 24px; text-align: center; background: var(--surface); border-radius: 12px; border: 1px dashed var(--line); }

.extra { margin-top: 28px; }
.extra h2 { font-family: "Zen Maru Gothic", sans-serif; font-size: 18px; margin: 0; }
.extra p { margin: 2px 0 10px; font-size: 13px; }
.notice { font-size: 12.5px; color: var(--muted); margin: 24px 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }

/* dialog */
dialog {
  border: 0; border-radius: 16px; padding: 22px 22px 18px; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10, 20, 25, .45); }
.dlg-close-form { position: absolute; top: 10px; right: 10px; margin: 0; }
#dlgBody h2 { font-family: "Zen Maru Gothic", sans-serif; margin: 6px 36px 10px 0; font-size: 20px; line-height: 1.4; }
#dlgBody dl { display: grid; grid-template-columns: 5em 1fr; gap: 6px 10px; margin: 12px 0; font-size: 14px; }
#dlgBody dt { color: var(--muted); }
#dlgBody dd { margin: 0; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; text-decoration: none; font-size: 13px; font-weight: 700; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.src { font-size: 12px; color: var(--muted); margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }

/* footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 32px; padding: 22px 0 30px; font-size: 13px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.footer-inner p { margin: 2px 0; }
.footer-title { font-weight: 700; }
.footer-links { display: flex; flex-direction: column; gap: 4px; }

/* about page */
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 22px 22px; margin: 20px 0; }
.prose h1 { font-family: "Zen Maru Gothic", sans-serif; font-size: 24px; }
.prose h2 { font-family: "Zen Maru Gothic", sans-serif; font-size: 18px; margin-top: 28px; border-left: 4px solid var(--brand); padding-left: 10px; }
.prose li { margin: 4px 0; }

/* mobile */
@media (max-width: 720px) {
  .header-nav a:not(.btn-submit) { display: none; }
  .brand-name { font-size: 16px; }
  .month-nav h1 { font-size: 19px; min-width: 6.5em; }
  .toolbar { margin-top: 14px; }
  .day { min-height: 58px; padding: 3px 2px; align-items: center; cursor: pointer; }
  .day .ev, .day .more { display: none; }
  .day .num { align-self: center; }
  .dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 100%; }
  .dot { --c: var(--c-other); width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
  .dot.recurring { opacity: .45; }
  .day.selected { outline: 2px solid var(--brand); outline-offset: -2px; }
  .card-list { grid-template-columns: 1fr; }
  #dlgBody dl { grid-template-columns: 4.5em 1fr; }
}
