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

:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-soft: #fbfaf8;
  --text: #171717;
  --muted: #6b7280;
  --line: #e5e1da;
  --dark: #26211d;
  --green: #047857;
  --green-bg: #dff5ea;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(39, 32, 26, .08);
  --radius: 10px;
  --max-w: 840px;
  --sidebar-w: 220px;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.layout {
  display: flex;
  height: 100%;
}

/* ─── Sidebar ─── */

.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: #2f2924;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-close {
  display: none;
}

.sidebar-brand {
  padding: 1.6rem 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-eyebrow {
  color: #f7c974;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-title {
  margin-top: .15rem;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.sidebar-nav {
  flex: 1;
  padding: .6rem .6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .7rem .75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(192, 138, 47, .22);
  color: #f7c974;
}

.sidebar-icon {
  font-size: 1.15rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Main area ─── */

.main-area {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

/* ─── Animations ─── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.calendar-view {
  animation: fadeIn .2s ease;
}

.route-table {
  animation: fadeIn .2s ease;
}

/* ─── Calendar ─── */

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cal-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: .04em;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.cal-nav-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.cal-nav-btn:hover {
  border-color: #c08a2f;
  color: #c08a2f;
}

.cal-today-btn {
  height: 2rem;
  padding: 0 .9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.cal-today-btn:hover {
  background: var(--line);
  border-color: #c08a2f;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.cal-weekday {
  padding: .55rem .3rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--line);
}

.cal-cell {
  position: relative;
  min-height: 5rem;
  padding: .4rem .5rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background .12s;
}

.cal-cell:hover {
  background: var(--surface-soft);
}

.cal-other-month .cal-date,
.cal-other-month .cal-lunar {
  color: #c9c1b7;
}

.cal-lunar {
  display: block;
  font-size: .68rem;
  color: var(--muted);
  line-height: 1.3;
}

.cal-lunar-start {
  color: var(--red);
  border-bottom: 2px solid var(--red);
  display: inline-block;
}

.cal-date {
  display: block;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-top: .15rem;
}

.cal-today {
  background: #fef2f2;
}

.cal-date-today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
  margin-top: .35rem;
}

.cal-has-data {
  cursor: pointer;
}

.cal-has-data:hover {
  background: #f0ece6;
}

.cal-value {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--amber);
  margin-top: .25rem;
}

.cal-selected {
  outline: 2px solid #c08a2f;
  outline-offset: -2px;
  background: #fdf8ed;
  z-index: 1;
}

/* ─── Detail panel ─── */

.detail-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: fadeIn .2s ease;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: #2f2924;
  border-radius: var(--radius) var(--radius) 0 0;
}

.detail-title {
  font-size: .95rem;
  font-weight: 800;
  color: #fff;
}

.detail-close {
  width: 1.7rem;
  height: 1.7rem;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}

.detail-close:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
}

.detail-body {
  padding: .8rem 1rem;
}

.detail-row {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .45rem 0;
}

.detail-row + .detail-row {
  border-top: 1px solid var(--line);
}

.detail-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 4.5rem;
}

.detail-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.detail-note-text {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.55;
}

/* ─── Task list in detail panel ─── */

.detail-tasks {
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .35rem 0;
}

.task-num {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: #2f2924;
  color: #f7c974;
  font-size: .7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .1rem;
}

.task-time {
  flex-shrink: 0;
  min-width: 7rem;
  font-size: .76rem;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted);
  font-weight: 600;
  margin-top: .15rem;
  white-space: nowrap;
}

.task-text {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.5;
}

/* ─── Summary bar ─── */

.summary-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: .35rem;
}

.summary-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}

.summary-value {
  font-size: .95rem;
  font-weight: 800;
  color: var(--dark);
}

.summary-divider {
  width: 1px;
  height: 1.4rem;
  background: var(--line);
  flex-shrink: 0;
}

/* ─── Route Table ─── */

.route-search {
  margin-bottom: 1rem;
}

.route-search input {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: .55rem .7rem;
  font-size: .9rem;
  outline: none;
}

.route-search input:focus {
  border-color: #c08a2f;
  box-shadow: 0 0 0 3px rgba(192, 138, 47, .16);
}

.empty-state {
  border: 1px dashed #c9c1b7;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .6);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

/* Route section (reuses check-section pattern) */

.check-section {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  background: #2f2924;
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}

.section-header:hover {
  background: #3b342d;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.section-header-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.section-count {
  font-size: .75rem;
  font-weight: 700;
  color: #f7c974;
}

.section-arrow {
  font-size: .85rem;
  transition: transform .2s ease;
  color: #f7c974;
}

.check-section.open .section-arrow {
  transform: rotate(90deg);
}

.section-body {
  overflow: hidden;
}

.route-item {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.route-item:last-child {
  border-bottom: none;
}

.route-item-name {
  font-weight: 700;
  font-size: .94rem;
  color: var(--text);
}

.route-item-desc {
  margin-top: .2rem;
  font-size: .82rem;
  color: var(--muted);
}

.route-item-link {
  display: inline-block;
  margin-top: .35rem;
  font-size: .8rem;
  color: var(--blue);
  text-decoration: none;
  word-break: break-all;
}

.route-item-link:hover {
  text-decoration: underline;
}

.route-item-path {
  display: inline-block;
  margin-top: .35rem;
  padding: .2rem .5rem;
  font-size: .78rem;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface-soft);
  border-radius: 4px;
  color: var(--muted);
}

/* ─── Responsive ─── */

@media (max-width: 719px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 15;
    width: 2.3rem;
    height: 2.3rem;
    border: none;
    border-radius: 8px;
    background: #2f2924;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    -webkit-backface-visibility: hidden;
    transition: opacity .2s;
  }

  .sidebar-toggle:hover {
    opacity: .85;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(0, 0, 0, .45);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 25;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    will-change: transform;
    transition: -webkit-transform .25s ease, transform .25s ease;
    width: var(--sidebar-w);
  }

  .sidebar.open {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .7);
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s;
  }

  .sidebar-close:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
  }

  .sidebar-brand {
    padding: 1.2rem .8rem .9rem;
    position: relative;
  }

  .sidebar-title {
    font-size: 1.1rem;
  }

  .sidebar-nav {
    padding: .4rem .4rem .8rem;
  }

  .sidebar-item {
    padding: .6rem .6rem;
    font-size: .82rem;
  }

  .main-area {
    padding-top: .2rem;
  }
}

/* ─── Cookbook ─── */

.cookbook-card {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}

.cookbook-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: .03em;
}

.cookbook-tags {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .4rem;
}

.cookbook-tag {
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.cookbook-steps {
  margin-top: .8rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.cookbook-step {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .25rem 0;
}

.cookbook-check {
  flex-shrink: 0;
  font-size: .85rem;
  margin-top: .05rem;
}

.cookbook-step-text {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.55;
}

.cookbook-note {
  margin-top: .8rem;
  padding: .6rem .8rem;
  font-size: .8rem;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 6px;
  line-height: 1.5;
}

.cookbook-source {
  display: inline-block;
  margin-top: .6rem;
  font-size: .8rem;
  color: var(--blue);
  text-decoration: none;
}

.cookbook-source:hover {
  text-decoration: underline;
}
