:root {
  --ink: #20221d;
  --muted: #70736a;
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --line: #dedbd1;
  --accent: #e95f3c;
  --accent-dark: #be4327;
  --green: #2f684f;
  --soft-green: #e2eee7;
  --shadow: 0 18px 50px rgb(38 41 32 / 12%);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(247 245 239 / 92%);
}

.brand {
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  background: var(--green);
  display: grid;
  place-items: center;
}

.tagline { color: var(--muted); font-size: 13px; margin: 0 auto 0 0; }
.connection-status {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green);
  background: var(--soft-green);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.connection-status.is-offline {
  color: #8b3e23;
  border-color: #efc5b4;
  background: #fff0e8;
}

.app-shell {
  min-height: calc(100vh - 72px);
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 340px;
}

.calendar-panel { width: 100%; min-height: calc(100vh - 72px); padding: 34px clamp(24px, 5vw, 72px) 48px; overflow-y: auto; position: relative; }

.calendar-toolbar, .agenda-heading, .dialog-header, .dialog-actions {
  display: flex;
  align-items: center;
}

.calendar-toolbar { justify-content: space-between; margin-bottom: 28px; }

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  margin: 0 0 6px;
}

h1, h2 { margin: 0; font-family: Georgia, "Yu Mincho", serif; }
h1 { font-size: clamp(29px, 3vw, 42px); font-weight: 500; }
h2 { font-size: 23px; }

.calendar-actions { display: flex; gap: 7px; }
.text-button, .icon-button, .small-add-button, .secondary-button, .danger-button, .close-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface);
}

.text-button { border-radius: 20px; padding: 8px 14px; font-size: 13px; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; font-size: 24px; line-height: 1; }

.primary-button {
  border: 0;
  border-radius: 24px;
  padding: 11px 19px;
  color: white;
  background: var(--accent);
  box-shadow: 0 6px 18px rgb(233 95 60 / 22%);
}
.primary-button:hover { background: var(--accent-dark); }

.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekday-row {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding-bottom: 10px;
}

.calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar-day {
  appearance: none;
  min-width: 0;
  min-height: 78px;
  padding: 8px;
  text-align: left;
  color: var(--ink);
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  position: relative;
}
.calendar-day:hover { background: #fffaf1; }
.calendar-day.outside { color: #b5b5ae; }
.calendar-day.selected { background: var(--soft-green); }
.calendar-day.today .day-number {
  color: white;
  background: var(--accent);
}
.day-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 14px; font-weight: 600; }
.day-dots { display: flex; gap: 3px; margin-top: 13px; flex-wrap: wrap; }
.day-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.more-count { color: var(--muted); font-size: 9px; }

.day-agenda {
  position: absolute;
  z-index: 620;
  top: 118px;
  left: clamp(18px, 4vw, 54px);
  right: clamp(18px, 4vw, 54px);
  max-height: calc(100vh - 170px);
  padding: 23px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(32 34 29 / 24%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.985);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.day-agenda.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.agenda-backdrop {
  position: absolute;
  z-index: 610;
  inset: 0;
  border: 0;
  background: rgb(247 245 239 / 72%);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s;
}
.agenda-backdrop.is-open { opacity: 1; visibility: visible; }
.agenda-heading { justify-content: space-between; margin-bottom: 17px; }
.agenda-heading-actions { display: flex; align-items: center; gap: 8px; }
.small-add-button { border-radius: 18px; padding: 8px 13px; font-size: 12px; }
.agenda-list { display: grid; gap: 10px; }
.empty-state {
  padding: 26px;
  border: 1px dashed #c9c5ba;
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
}
.empty-state-large { padding: 38px 24px; border-style: solid; background: #fbfaf5; }
.empty-state-large strong { display: block; margin-top: 10px; color: var(--ink); font-family: Georgia, "Yu Mincho", serif; font-size: 20px; }
.empty-state-large p { margin: 7px 0 20px; }
.empty-state-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 27px;
}
.empty-add-button {
  min-width: min(320px, 100%);
  padding: 15px 24px;
  border: 0;
  border-radius: 28px;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 22px rgb(233 95 60 / 24%);
  font-size: 16px;
  font-weight: 700;
}
.empty-add-button:hover { background: var(--accent-dark); transform: translateY(-1px); }

.event-card {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.event-card:hover, .event-card.active { border-color: var(--green); box-shadow: 0 5px 18px rgb(47 104 79 / 10%); }
.event-card-main {
  width: 100%;
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 15px;
  align-items: center;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}
.event-time { color: var(--green); font-family: Georgia, serif; font-size: 17px; }
.event-time small { display: block; margin-top: 2px; font-family: inherit; font-size: 9px; }
.event-title { display: block; font-weight: 700; margin-bottom: 4px; }
.event-place { color: var(--muted); font-size: 13px; line-height: 1.6; }
.route-badge { color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap; }
.event-details { margin: 12px 0 0 73px; padding-top: 11px; border-top: 1px solid #ebe8df; }
.event-detail-line { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.event-detail-line strong { color: var(--ink); }
.event-notes { white-space: pre-wrap; }
.event-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.event-action-button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--ink);
  background: white;
  font-size: 11px;
  text-decoration: none;
}
.event-action-button.route { color: white; border-color: var(--green); background: var(--green); }

.help-panel {
  min-height: calc(100vh - 72px);
  padding: 40px 26px 46px;
  border-right: 1px solid var(--line);
  background: #f1efe8;
}
.help-panel-inner { position: sticky; top: 28px; }
.help-panel h2 { font-size: 27px; }
.help-steps { display: grid; gap: 24px; margin: 30px 0 0; padding: 0; list-style: none; }
.help-steps li { display: grid; grid-template-columns: 31px 1fr; gap: 11px; align-items: start; }
.help-step-number {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-family: Georgia, serif;
  font-size: 14px;
}
.help-steps strong { display: block; margin: 3px 0 6px; font-size: 15px; line-height: 1.5; }
.help-steps p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.help-note { display: grid; grid-template-columns: 22px 1fr; gap: 10px; margin-top: 30px; padding: 15px; border-radius: 11px; background: var(--soft-green); }
.help-note > span { width: 20px; height: 20px; display: grid; place-items: center; border: 1px solid var(--green); border-radius: 50%; color: var(--green); font-family: Georgia, serif; font-size: 11px; }
.help-note p { margin: 0; color: var(--green); font-size: 11px; line-height: 1.7; }

.today-panel {
  position: sticky;
  top: 0;
  align-self: start;
  height: calc(100vh - 72px);
  min-height: calc(100vh - 72px);
  padding: 38px 24px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #efede5;
}
.today-panel-heading { position: sticky; top: 0; padding-bottom: 18px; background: #efede5; z-index: 1; }
.today-date-label { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.today-list { display: grid; gap: 11px; }
.today-empty { padding: 22px 14px; border: 1px dashed #c8c4b8; border-radius: 13px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.7; }
.today-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.today-card-time { margin: 0 0 5px; color: var(--accent); font-family: Georgia, serif; font-size: 16px; }
.today-card-title { margin: 0 0 5px; font-size: 16px; }
.today-card-place { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.today-card-route { margin: 8px 0 0; color: var(--green); font-size: 12px; font-weight: 700; }
.today-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.today-card-actions .event-action-button { padding: 6px 9px; font-size: 10px; }

@media (max-width: 1180px) and (min-width: 861px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr) 290px; }
  .help-panel { padding-inline: 20px; }
  .calendar-panel { padding-inline: 24px; }
}

.leaflet-tile-pane { filter: saturate(.68) sepia(.1); }

dialog {
  width: min(650px, calc(100vw - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(28 30 25 / 55%); backdrop-filter: blur(3px); }
#event-form { padding: 27px; }
.dialog-header { justify-content: space-between; margin-bottom: 23px; }
.close-button { width: 36px; height: 36px; border-radius: 50%; font-size: 21px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.field { display: grid; gap: 7px; font-size: 14px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: white;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(47 104 79 / 10%); }
.field small, .field-help { color: var(--muted); font-size: 12px; line-height: 1.6; font-weight: 400; margin: 0; }
.maps-button {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--green);
  border-radius: 9px;
  color: white;
  background: var(--green);
  font-weight: 700;
}
.maps-button:hover { background: #24543f; }
.clipboard-button {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid var(--green);
  border-radius: 9px;
  color: var(--green);
  background: white;
  font-weight: 700;
}
.clipboard-button:hover { background: var(--soft-green); }
.route-options-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--green);
  background: white;
  font-size: 11px;
  font-weight: 700;
}
.route-options-list { display: grid; gap: 9px; }
.route-option-row {
  display: grid;
  grid-template-columns: auto minmax(90px, .55fr) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf6;
}
.route-option-row input[type="radio"] { width: 17px; height: 17px; accent-color: var(--green); }
.route-option-row input[type="text"], .route-option-row input[type="url"], .route-option-row textarea { padding: 8px 9px; }
.route-option-row textarea {
  grid-column: 2 / -1;
  width: 100%;
  min-height: 70px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: white;
  font-size: 12px;
  line-height: 1.6;
}
.remove-route-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: #9c3c2c;
  background: #f4e2dd;
}
.routes-empty { color: var(--muted); padding: 13px; border: 1px dashed var(--line); border-radius: 9px; text-align: center; font-size: 11px; }
#picker-map { height: 190px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#picker-map.map-offline {
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  background: #f3f0e8;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}
.dialog-actions { margin-top: 24px; gap: 10px; }
.action-spacer { flex: 1; }
.secondary-button, .danger-button { padding: 10px 16px; border-radius: 22px; }
.danger-button { color: #a03526; border-color: #e4b7ae; }
.is-hidden { display: none; }
.toast {
  position: fixed;
  z-index: 2000;
  left: 50%;
  bottom: 24px;
  padding: 11px 18px;
  border-radius: 24px;
  color: white;
  background: var(--ink);
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .topbar { height: 64px; padding: 0 16px; }
  .tagline { display: none; }
  .connection-status { display: none; }
  .topbar .primary-button { margin-left: auto; padding: 10px 14px; }
  .calendar-panel { padding: 25px 16px 34px; }
  .app-shell { display: block; }
  .help-panel { min-height: auto; padding: 24px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .help-panel-inner { position: static; }
  .help-steps { grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 7px; }
  .help-note { max-width: 430px; }
  .today-panel { position: static; height: auto; min-height: auto; padding: 28px 16px 40px; border-top: 1px solid var(--line); border-left: 0; overflow: visible; }
  .today-panel-heading { position: static; }
  .calendar-day { min-height: 60px; padding: 5px; }
  .day-dots { margin-top: 7px; }
  .day-agenda { position: fixed; top: auto; left: 10px; right: 10px; bottom: 10px; max-height: min(72vh, 650px); }
  .agenda-backdrop { position: fixed; inset: 0; }
}

@media (max-width: 480px) {
  .brand { font-size: 23px; }
  .brand-mark { width: 32px; height: 32px; }
  .calendar-toolbar { align-items: flex-end; }
  h1 { font-size: 27px; }
  .calendar-day { min-height: 52px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .dialog-actions { flex-wrap: wrap; }
  .route-option-row { grid-template-columns: auto 1fr auto; }
  .route-option-row input[type="url"] { grid-column: 2 / -1; }
  .route-option-row textarea { grid-column: 2 / -1; }
  .agenda-heading { align-items: flex-start; }
  .small-add-button { padding: 7px 9px; }
  .event-details { margin-left: 0; }
}
