/* ── Shell ──────────────────────────────────────────────── */
.page-shell {
  max-width: 1020px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* ── Layout: sidebar + main ─────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.main {
  min-width: 0;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  margin-bottom: 2rem;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.page-link {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  color: var(--text-muted);
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
}

.page-link:hover {
  color: var(--text-primary);
}

.page-link.active {
  color: var(--brand-blue);
  border-bottom-color: var(--brand-blue);
}

.brand-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-blue);
  font-family: 'Inter', sans-serif;
  margin-bottom: 1rem;
}

.site-header h1 {
  font-size: clamp(3.5rem, 15vw, 6rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

/* Date line — the select lives inside a sentence */
.date-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  flex-wrap: wrap;
}

.date-line b {
  color: var(--text-primary);
  font-weight: 600;
}

/* Prev/next day buttons */
.day-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.day-nav button {
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.day-nav button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.day-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── Tally ───────────────────────────────────────────────── */
.tally {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.tally:empty {
  display: none;
}

.tally b {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Sidebar: month/date navigation ─────────────────────── */
.sidebar {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  padding-right: 0.25rem;
}

.month {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.25rem 0 0.35rem;
}

.month > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.5rem 0.25rem;
}

.month > summary::-webkit-details-marker { display: none; }
.month > summary:hover { color: var(--text-primary); }

.month-count {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-muted);
  background: var(--bg-glass-hover);
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.5rem;
}

.date-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0.1rem 0 0.5rem;
}

.date-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, color 0.12s ease;
}

.date-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.date-link.selected {
  background: var(--brand-blue);
  color: #fff;
}

.dl-wd {
  font-size: 0.66rem;
  color: var(--text-muted);
  width: 1.5rem;
  flex-shrink: 0;
}

.date-link.selected .dl-wd { color: rgba(255, 255, 255, 0.8); }

.dl-today {
  margin-left: auto;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

.date-link.selected .dl-today { color: #fff; }

/* ── Filter ──────────────────────────────────────────────── */
.filter-row {
  margin: 0.75rem 0 0.25rem;
}

.filter-row input {
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

/* ── Log list ────────────────────────────────────────────── */
.log-list {
  margin-top: 0;
}

/* ── Log entry ───────────────────────────────────────────── */
.log-entry {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0 1.75rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.log-entry.inactive {
  opacity: 0.65;
}

/* Time in the left gutter */
.entry-time {
  font-size: 0.72rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  line-height: 1.4;
  text-align: right;
  padding-top: 0.2rem;
}

/* Right column */
.entry-content {
  min-width: 0;
}

.entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.entry-head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.log-entry.inactive .entry-head h2 {
  color: var(--text-secondary);
}

/* Line chips next to the title */
.chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.chip {
  font-size: 0.62rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--brand-blue);
  border: 1px solid var(--border-glow);
  background: var(--accent-glow);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
  line-height: 1.5;
}

.times .duration {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Description ─────────────────────────────────────────── */
.desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin-bottom: 0.75rem;
}

/* ── Timestamps ──────────────────────────────────────────── */
.times {
  display: flex;
  gap: 1.25rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  font-family: 'Inter', sans-serif;
}

/* ── History ─────────────────────────────────────────────── */
.history {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border-subtle);
}

.history > summary {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-blue);
  user-select: none;
  font-family: 'Inter', sans-serif;
  list-style: none;
}

.history > summary::-webkit-details-marker { display: none; }
.history > summary:hover { color: var(--brand-blue-hover); }

.change {
  margin-top: 0.45rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg-glass-hover);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.change time {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.change .field { font-weight: 600; color: var(--text-secondary); }
.change .old   { color: var(--status-danger); text-decoration: line-through; }
.change .new   { color: var(--status-success); }

/* ── Groups ──────────────────────────────────────────────── */
.group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--bg-glass-hover);
  transition: background 0.15s ease;
}

.group-header::-webkit-details-marker { display: none; }
.group-header:hover { background: var(--bg-hover); }

.group[open] > .group-header {
  border-bottom: 1px solid var(--border-subtle);
}

.group-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
}

.group-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.group-count {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.5rem;
  line-height: 1.4;
}

.group-chevron {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  display: inline-block;
  line-height: 1;
}

.group[open] .group-chevron {
  transform: rotate(90deg);
}

.group-entries {
  padding: 0 1.25rem;
}

.group-entries .log-entry:last-child {
  border-bottom: none;
}

/* ── States ──────────────────────────────────────────────── */
.state-msg {
  padding: 4rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
}

/* ── Trends page: sections + charts ──────────────────────── */
.section {
  margin-top: 2.5rem;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.section-sub {
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.chart {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  padding: 1.25rem 1.25rem 0.75rem;
}

.bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 160px;
  padding-bottom: 1.4rem; /* reserved space for absolutely-positioned labels */
}

.chart-small .bars {
  height: 110px;
}

.bar {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-width: 0;
  text-decoration: none;
}

.bar-fill {
  display: block;
  width: 100%;
  background: var(--brand-blue);
  border-radius: 3px 3px 0 0;
  opacity: 0.78;
  transition: opacity 0.15s ease;
}

.bar:hover .bar-fill {
  opacity: 1;
}

/* Label sits in the reserved padding below the bars, so it never adds to the
   bar height (which previously pushed tall bars out the top of the chart). */
.bar-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.35rem;
  font-size: 0.6rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

/* Floating tooltip over chart columns */
.chart-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 250px;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.chart-tip[hidden] {
  display: none;
}

.chart-tip > b {
  font-size: 0.75rem;
  color: var(--text-primary);
  margin-bottom: 0.1rem;
}

.chart-tip span b {
  color: var(--text-primary);
  font-weight: 600;
}

.chart-tip .tip-hint {
  margin-top: 0.25rem;
  font-size: 0.64rem;
  color: var(--text-muted);
}

/* ── Trends page: search + longest ───────────────────────── */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input {
  flex: 1;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.search-form button {
  padding: 0.5rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #fff;
  background: var(--brand-blue);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-form button:hover {
  background: var(--brand-blue-hover);
}

.search-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  margin-bottom: 0.5rem;
}

.search-hit {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.search-hit.inactive {
  opacity: 0.75;
}

.search-hit time {
  display: block;
  font-size: 0.7rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.search-hit h3 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.3rem;
}

.search-hit p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Settings page ───────────────────────────────────────── */
.theme-options {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.theme-options label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 8.5rem;
  padding: 0.75rem 1.1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-options label:hover {
  border-color: var(--brand-blue);
}

.theme-options label:has(input:checked) {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.theme-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.setting-hint {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 800px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
    border-top: 1px solid var(--border-subtle);
  }
}

@media (max-width: 520px) {
  .log-entry {
    grid-template-columns: 2.5rem 1fr;
    gap: 0 1.25rem;
  }

  .entry-head {
    flex-direction: column;
    gap: 0.35rem;
  }
}
