:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: #5b4bff;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --border: #e5e7eb;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 3;
  max-height: 100vh;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.brand-title {
  margin: 0;
  font-weight: 700;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-text {
  flex: 1;
}

.sidebar-meta {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.range-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-meta .label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.sidebar-meta .value {
  margin: 2px 0 0;
  font-weight: 700;
}

.stats-stack {
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
}

.stat-label {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link,
.nav-action button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.nav-link:hover,
.nav-action button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-action {
  margin: 0;
}

.main-area {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-backdrop {
  display: none;
}

.floating-nav-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 5;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

@media (min-width: 901px) {
  .floating-nav-toggle {
    display: none;
  }
}

@media (max-width: 900px) {
  .floating-nav-toggle {
    display: inline-flex;
  }
}

.site-main {
  padding: 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.muted {
  color: var(--muted);
}

.site-footer {
  padding: 18px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}

.flash-messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-weight: 600;
}

.flash.success {
  border-color: #10b981;
  color: #0f5132;
}

.flash.error {
  border-color: var(--danger);
  color: #7f1d1d;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.page-header h1 {
  margin: 6px 0 8px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  color: var(--accent-strong);
}

.lede {
  margin: 4px 0 0;
  color: var(--muted);
}

.panel,
.hero-panel,
.calendar-panel,
.page-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-head,
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-subtitle,
.panel-subcopy {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.button,
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
}

.button.ghost,
button.ghost,
.icon-button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.button.secondary,
button.secondary {
  background: #f9fafb;
  border-color: var(--border);
  color: var(--text);
}

.button.danger,
button.danger {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecdd3;
}

.icon-button {
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text);
  padding: 7px 9px;
  border-radius: 10px;
  cursor: pointer;
}

.calendar-toolbar .icon-button {
  padding: 6px 8px;
}

.desktop-hidden {
  display: none;
}

.entry-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-row a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fdfdff;
}

.entry-date {
  font-weight: 700;
}

.entry-summary {
  color: var(--muted);
  flex: 1;
  text-align: right;
}

.feed-sentinel {
  width: 100%;
  height: 8px;
}

.calendar-explorer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-titles p {
  margin: 0;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-input-row {
  display: flex;
  gap: 6px;
}

.search-input-row input {
  flex: 1;
  padding: 8px 10px;
}

.search-form.compact label {
  font-size: 0.9rem;
  color: var(--muted);
}

.chip-button,
.view-button {
  border: 1px solid var(--border);
  background: #f9fafb;
  color: inherit;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.95rem;
}

.view-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.calendar-toolbar .search-form {
  flex: 1 1 240px;
  max-width: 340px;
}

.view-button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.view-crumbs {
  color: var(--muted);
}

.hero-panel {
  gap: 12px;
}

.hero-copy {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 68ch;
}

.hero-card,
.calendar-panel,
.page-panel {
  background: #fdfdff;
}

.hero-stats {
  display: flex;
  gap: 16px;
}

.hero-card-label,
.metric-label {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.hero-card-meta,
.metric-value {
  margin: 4px 0 0;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-weight: 700;
  font-size: 1.4rem;
}

.stat-label {
  margin: 2px 0 0;
  color: var(--muted);
}

.calendar-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
}

.calendar-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-flex;
  border: 1px solid var(--border);
  background: #e5e7eb;
}

.legend-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.calendar-grid-surface {
  display: grid;
  gap: 12px;
}

.multi-year-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.year-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f9fafb;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
}

.year-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.year-card.has-entry {
  background: #eef2ff;
  border-color: var(--accent);
}

.year-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.year-number {
  font-size: 1.2rem;
  font-weight: 700;
}

.year-card-sub {
  margin: 6px 0 0;
  color: var(--muted);
}

.entry-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-flex;
  background: var(--accent);
}

.entry-dot.muted {
  background: #e5e7eb;
}

.entry-dot.spaced {
  margin-top: 4px;
}

.year-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.month-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.month-card.has-entry {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(76, 81, 191, 0.1);
}

.mini-month-name {
  font-weight: 700;
  margin-bottom: 6px;
}

.mini-day-headers,
.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.mini-day-headers span {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

.mini-day {
  font-size: 0.78rem;
  text-align: center;
  padding: 4px 0;
  border-radius: 6px;
  color: var(--muted);
}

.mini-day.has-entry {
  background: #eef2ff;
  color: var(--text);
  font-weight: 700;
}

.mini-day.muted {
  opacity: 0.5;
}

.month-view {
  display: grid;
  gap: 6px;
}

.month-grid-header,
.month-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 6px;
}

.month-day-header {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.month-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: #fff;
  transition: border-color 120ms ease, background 120ms ease;
  position: relative;
}

.month-cell.has-entry {
  background: #f3f4ff;
  border-color: var(--accent);
}

.month-cell-number {
  font-weight: 700;
}

.month-cell .entry-dot {
  width: 8px;
  height: 8px;
  position: absolute;
  right: 8px;
  bottom: 8px;
  margin-top: 0;
}

.week-days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.week-day-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 4px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.week-day-card.has-entry {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(76, 81, 191, 0.1);
}

.week-day-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.week-day-name {
  font-weight: 700;
}

.week-day-month {
  color: var(--muted);
  margin: 0;
}

.week-day-status {
  display: flex;
  justify-content: flex-end;
}

.day-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.day-panel.has-entry {
  border-color: var(--accent);
}

.day-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr));
  gap: 8px;
}

.ribbon-panel {
  gap: 10px;
}

.ribbon-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.ribbon-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
}

.legend-bar {
  width: 36px;
  height: 10px;
  border-radius: 12px;
  background: linear-gradient(90deg, #c7d2fe, #6366f1);
  display: inline-flex;
}

.ribbon-visual {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  position: relative;
  max-height: 520px;
  overflow: auto;
}

.ribbon-canvas {
  width: 100%;
  min-height: 320px;
}

.ribbon-tooltip {
  position: absolute;
  background: #0f172a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  pointer-events: none;
  z-index: 2;
  max-width: 320px;
}

.ribbon-svg {
  width: 100%;
  touch-action: none;
  cursor: grab;
}

.ribbon-svg.is-dragging {
  cursor: grabbing;
}

.day-layer .day-cell {
  fill: #e5e7eb;
  cursor: pointer;
  transition: fill 120ms ease, opacity 120ms ease;
}

.day-layer .day-cell.has-entry {
  fill: var(--accent);
}

.day-layer .day-cell:hover {
  fill: var(--accent-strong);
  opacity: 0.9;
}

.event-layer .event-span {
  fill: #c7d2fe;
  stroke: #4f46e5;
  stroke-width: 1.2px;
  cursor: pointer;
  opacity: 0.92;
}

.event-layer .event-span:hover {
  fill: #a5b4fc;
}

.axis-layer text {
  font-size: 0.85rem;
  fill: var(--muted);
}

.axis-layer path,
.axis-layer line {
  stroke: var(--border);
}

.today-marker {
  stroke: var(--danger);
  stroke-dasharray: 4 3;
  stroke-width: 1.4px;
}

.text-fallback {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.text-fallback summary {
  cursor: pointer;
  font-weight: 600;
}

.heatmap-wrapper {
  position: relative;
}

.year-markers {
  position: absolute;
  inset: 0 auto 0 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  gap: 0;
}

.year-marker {
  transform: translateY(-50%);
  background: #f3f4f6;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 999px;
  position: absolute;
  right: 0;
}

.heatmap-wrapper .heatmap-grid {
  padding-left: 72px;
}

.heatmap-wrapper {
  position: relative;
  margin-top: 10px;
  padding: 6px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
  grid-auto-rows: 12px;
  gap: 4px;
}

.heatmap-day {
  width: 100%;
  height: 12px;
  border-radius: 4px;
  background: #e5e7eb;
  border: 1px solid #e5e7eb;
  display: block;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.heatmap-day.has-entry {
  background: var(--accent);
  border-color: var(--accent);
}

.heatmap-day:hover,
.heatmap-day:focus {
  transform: scale(1.15);
  outline: none;
  border-color: var(--accent-strong);
}

.heat-tooltip {
  position: absolute;
  transform: translate(-50%, -110%);
  background: #0f172a;
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
}

  width: 8px;
  height: 8px;
  border-radius: 50%;
  right: 6px;
  bottom: 6px;
  background: transparent;
}

.calendar-day.has-entry::after {
  background: #fff;
}

.calendar-day.no-entry::after {
  background: #d1d5db;
}

.entry-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}

.entry-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.entry-card-header > div:first-child {
  flex: 1 1 100%;
}

.entry-card-content {
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #f9fafb;
}

.entry-meta {
  color: var(--muted);
}

.meta-item + .meta-item {
  margin-left: 8px;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.entry-location-list {
  margin: 6px 0;
}

.entry-location-list li {
  margin-bottom: 4px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.entry-form form,
.form-surface {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-input-row,
.selected-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tag-input-row input {
  flex: 1;
  min-width: 220px;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="email"],
input[type="date"],
textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

textarea {
  min-height: 200px;
}

.tag-chip,
.tag-suggestion,
.tag-chip-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: #eef2ff;
}

.selected-tags .tag-chip,
.tag-list .tag-chip {
  border: none;
  box-shadow: none;
}

.tag-chip-wrapper {
  padding: 0 6px;
}

.tag-suggestion {
  background: #eef2ff;
  color: inherit;
  border: none;
  font-weight: 300;
}

.remove-tag {
  border: none;
  background: transparent;
  padding: 4px 6px;
  color: var(--muted);
  cursor: pointer;
}

.remove-tag:hover {
  background: inherit
}

@media (max-width: 720px) {
  .entry-row a {
    flex-direction: column;
    align-items: flex-start;
  }

  .entry-summary {
    text-align: left;
  }
}

.map-toggle {
  align-self: flex-start;
}

.entry-map-container {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  flex: 1 1 100%;
}

.entry-map {
  width: 100%;
  min-height: 260px;
}

.tag-directory {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: #0b1021;
  text-decoration: none;
  border-bottom: 1px solid #e5e7eb;
}

.tag-row:last-child { border-bottom: none; }
.tag-row:hover { background: #f5f5f7; }
.tag-name { font-weight: 600; text-transform: capitalize; }

.places-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

.places-map {
  width: 100%;
  min-height: 360px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.place-list h3 { margin-top: 0; font-size: 18px; }
.place-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.place-list a { text-decoration: none; color: #0b1021; display: block; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; }
.place-list a:hover { border-color: #6c4fff; }
.place-name { display: block; font-weight: 600; }
.place-address { display: block; color: #4b5563; font-size: 14px; margin-top: 2px; }

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.1);
  }

  .sidebar[data-open="true"] {
    transform: translateX(0);
  }

  .desktop-hidden {
    display: inline-flex;
  }

  .places-layout {
    grid-template-columns: 1fr;
  }
}
