/* Stopwatch-style layout (inspired by ActivityWatch UI). Dark default, light optional. */
:root,
body.theme-dark {
  --bg: #1a1b1e;
  --surface: #25262b;
  --surface-2: #2c2e33;
  --card: #25262b;
  --text: #f1f3f5;
  --muted: #868e96;
  --accent: #2f9e44;
  --accent-green: #2f9e44;
  --accent-green-border: #2b8a3e;
  --on-accent: #ffffff;
  --on-solid: #ffffff;
  --danger: #c92a2a;
  --danger-border: #a61e1e;
  --error-text: #ff8787;
  --warn: #e8a838;
  --save: #1971c2;
  --save-border: #1864ab;
  --oauth-btn-bg: #ffffff;
  --oauth-btn-text: #333333;
  --oauth-btn-border: #cccccc;
  --signature-surface: #ffffff;
  --focus-ring: var(--save);
  --z-modal-backdrop: 100;
  --border: #373a40;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-xs: 3px;
  --radius-2: 2px;
  --radius-micro: 1px;
  --radius-pill: 999px;
  --z-raised: 1;
  --z-overlay: 2;
  --z-highlight: 3;
  --heatmap-0: #2b2d31;
  --heatmap-1: #153d2a;
  --heatmap-2: #1f6b3a;
  --heatmap-3: #2f9e44;
  --heatmap-4: #51cf66;
  --btn-muted-bg: #343a40;
  --hover-tint: rgba(255, 255, 255, 0.04);
  --banner-error-bg: #5c2b29;
  --banner-error-text: #ffc9c9;
  --modal-backdrop: rgba(0, 0, 0, 0.65);
  --modal-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --stat-hover-border: #454950;
  --tab-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  --label-dot-ring: rgba(0, 0, 0, 0.2);
  --running-live-bg: color-mix(in srgb, var(--accent-green) 8%, var(--surface));
}

body.theme-light {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --card: #ffffff;
  --text: #1d2126;
  --muted: #5f6b76;
  --accent: #2f9e44;
  --accent-green: #2f9e44;
  --accent-green-border: #2b8a3e;
  --on-accent: #ffffff;
  --on-solid: #ffffff;
  --danger: #c92a2a;
  --danger-border: #a61e1e;
  --error-text: #c92a2a;
  --warn: #d97706;
  --save: #1971c2;
  --save-border: #1864ab;
  --oauth-btn-bg: #ffffff;
  --oauth-btn-text: #333333;
  --oauth-btn-border: #cccccc;
  --signature-surface: #ffffff;
  --focus-ring: var(--save);
  --z-modal-backdrop: 100;
  --border: #d4d9df;
  --radius: 6px;
  --heatmap-0: #e4e8ec;
  --heatmap-1: #c3ecd0;
  --heatmap-2: #82d99e;
  --heatmap-3: #2f9e44;
  --heatmap-4: #1d7a32;
  --btn-muted-bg: #e6e9ed;
  --hover-tint: rgba(0, 0, 0, 0.04);
  --banner-error-bg: #ffe3e3;
  --banner-error-text: #862e2e;
  --modal-backdrop: rgba(15, 23, 42, 0.45);
  --modal-shadow: 0 8px 32px rgba(15, 23, 42, 0.18);
  --stat-hover-border: #b8c0c8;
  --tab-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  --label-dot-ring: rgba(15, 23, 42, 0.2);
}

* {
  box-sizing: border-box;
}

body.theme-dark,
body.theme-light {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.theme-dark {
  color-scheme: dark;
}

body.theme-light {
  color-scheme: light;
}

/* Unified app page width: identical on Stopwatch, Activity, and Settings.
   Caps at 1040px on ultrawide, fluid with padding on small screens. */
.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem clamp(0.75rem, 3vw, 2rem) 3rem;
}

.app-nav {
  display: flex;
  gap: 0.35rem;
  margin: 0.5rem 0 0.75rem;
  min-height: 2.1rem;
  align-items: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link-active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.page.narrow {
  max-width: 420px;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  text-wrap: balance;
}

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

.small {
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.user-line {
  margin: 0.25rem 0 0;
}

.h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

.banner {
  padding: 0.65rem 1rem;
  border-radius: 4px;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.banner-error {
  background: var(--banner-error-bg);
  color: var(--banner-error-text);
}

.section {
  margin-top: 1.75rem;
}

.row-input {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  width: 100%;
}

.input.flex {
  flex: 1;
}

.input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.input:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.btn-icon:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.input.input-invalid {
  border-color: var(--danger);
}

.input.input-invalid:focus-visible {
  outline-color: var(--danger);
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-hint {
  margin: 0;
}

.field-hint-error {
  color: var(--error-text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
}

.btn:hover {
  filter: brightness(1.08);
}

.btn-start {
  background: var(--accent-green);
  border-color: var(--accent-green-border);
  color: var(--on-solid);
  font-weight: 600;
  white-space: nowrap;
}

.btn-google {
  background: var(--oauth-btn-bg);
  color: var(--oauth-btn-text);
  border-color: var(--oauth-btn-border);
}

.btn-primary {
  background: var(--save);
  border-color: var(--save-border);
  color: var(--on-solid);
}

.btn-muted {
  background: var(--btn-muted-bg);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger-border);
  color: var(--on-solid);
}

.btn-save {
  background: var(--save);
  border-color: var(--save-border);
  color: var(--on-solid);
}

.btn-small {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-controls {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.stat-value {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.45rem 0.6rem;
  font-size: 1rem;
  font-family: inherit;
}

.stat-value[readonly] {
  cursor: text;
}

.btn-icon {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.running-area {
  background: transparent;
}

.running-area.idle {
  color: var(--muted);
}

.running-area:focus {
  outline: none;
}

.running-area:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.running-live-card {
  background: var(--running-live-bg);
  border: 1px solid var(--accent-green-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.running-live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.running-live-duration {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-green);
}

.running-live-label {
  font-weight: 600;
  font-size: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.running-live-meta {
  margin: 0;
}

.running-live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.history-date {
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: var(--text);
}

.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.history-row-main {
  flex: 1;
  min-width: 0;
}

.history-label {
  font-weight: 600;
}

.history-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.history-empty {
  margin: 0;
  padding: 0.5rem 0;
}

.edit-meta-dev {
  margin: 0 0 0.75rem;
}

.edit-meta-dev summary {
  cursor: pointer;
  list-style: none;
}

.edit-meta-dev summary::-webkit-details-marker {
  display: none;
}

.edit-meta-dev[open] summary {
  margin-bottom: 0.35rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.stopwatch-page .card > .small {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, monospace;
  word-break: break-all;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: 4px;
}

.msg {
  margin-top: 0.75rem;
}

.msg-error {
  color: var(--error-text);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: var(--z-modal-backdrop);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.pdf-import-warn {
  color: var(--warn);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--modal-shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 1rem;
}

.modal-foot {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  gap: 0.5rem;
}

.spacer {
  flex: 1;
}

/* Export dialog */
.export-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem 0.75rem;
  margin: 0 0 0.85rem;
}

.export-fieldset legend {
  margin: 0;
  padding: 0 0.35rem;
}

.export-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1.1rem;
  cursor: pointer;
}

.export-months {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.35rem;
  max-height: 14rem;
  overflow: auto;
  margin-top: 0.35rem;
}

.export-months .export-option {
  margin-right: 0;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.meta-table th,
.meta-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  vertical-align: middle;
}

.meta-table th {
  background: var(--bg);
  text-align: left;
}

/* Activity view */
.activity-page {
  --activity-muted: #9aa3ad;
  --activity-track: #1e2024;
  --activity-grid: rgba(55, 58, 64, 0.45);
  --activity-grid-major: rgba(55, 58, 64, 0.85);
  --label-name-width: 11rem;
}

body.theme-light .activity-page {
  --activity-muted: #5f6b76;
  --activity-track: #eceef1;
  --activity-grid: rgba(150, 158, 168, 0.35);
  --activity-grid-major: rgba(150, 158, 168, 0.7);
}

.section-head {
  margin-bottom: 0.75rem;
}

.section-head .h2 {
  margin: 0;
}

.section-desc {
  margin: 0.25rem 0 0;
}

.segmented {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.85rem;
}

.segmented-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.activity-page .segmented-btn {
  color: var(--activity-muted);
}

.segmented-btn:hover {
  color: var(--text);
  background: var(--hover-tint);
}

.segmented-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.activity-mode-tab-active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--tab-shadow);
}

.activity-day-hero {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
}

.activity-day-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.activity-nav {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-icon-nav {
  min-width: 2.25rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

.activity-day-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 10rem;
  line-height: 1.35;
}

.activity-day-hero-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem 2rem;
}

.activity-hero-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 8rem;
}

.activity-hero-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.activity-hero-label {
  font-size: 0.8rem;
}

.activity-inline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  flex: 1;
  min-width: min(100%, 16rem);
}

.activity-inline-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 4.5rem;
}

.activity-inline-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--activity-muted);
  text-transform: none;
}

.activity-inline-stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.activity-timeline-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 1.1rem;
}

.activity-timeline {
  position: relative;
}

.activity-timeline-hours {
  position: relative;
  height: 1.35rem;
  margin-bottom: 0.5rem;
}

.activity-hour-mark {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--activity-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.activity-hour-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.15rem;
  width: 1px;
  height: 0.45rem;
  background: var(--activity-grid-major);
  transform: translateX(-50%);
}

.activity-timeline-track {
  position: relative;
  min-height: 4rem;
  background:
    repeating-linear-gradient(
      to right,
      transparent,
      transparent calc(100% / 8 - 1px),
      var(--activity-grid-major) calc(100% / 8 - 1px),
      var(--activity-grid-major) calc(100% / 8)
    ),
    repeating-linear-gradient(
      to right,
      transparent,
      transparent calc(100% / 24 - 1px),
      var(--activity-grid) calc(100% / 24 - 1px),
      var(--activity-grid) calc(100% / 24)
    ),
    var(--activity-track);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: visible;
}

.activity-now-marker {
  position: absolute;
  top: -0.35rem;
  bottom: -0.35rem;
  width: 2px;
  margin-left: -1px;
  background: var(--accent-green);
  border-radius: var(--radius-micro);
  box-shadow: 0 0 0 1px rgba(47, 158, 68, 0.25);
  pointer-events: none;
  z-index: var(--z-overlay);
}

.activity-now-marker::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
}

.activity-bar {
  position: absolute;
  border-radius: var(--radius-sm);
  min-width: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.25);
  cursor: default;
  z-index: var(--z-raised);
  overflow: hidden;
  transition: filter 0.15s ease;
}

.activity-bar:hover {
  filter: brightness(1.1);
  z-index: var(--z-highlight);
}

.activity-bar-label {
  display: block;
  padding: 0.15rem 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  pointer-events: none;
}

.activity-bar-running {
  animation: activity-pulse 1.6s ease-in-out infinite;
}

@keyframes activity-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .activity-bar-running {
    animation: none;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      0 0 0 2px var(--accent-green);
  }
}

.activity-empty {
  margin: 0.65rem 0 0;
}

.activity-panel {
  padding: 0.35rem 1rem;
}

.activity-panel-empty {
  margin: 0.5rem 0;
  padding: 0.25rem 0;
}

.activity-panel .label-summary-row:last-child,
.activity-panel .session-row:last-child,
.activity-panel .multi-day-row:last-child {
  border-bottom: none;
}

.label-summary {
  display: flex;
  flex-direction: column;
}

.label-summary-row,
.session-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.label-summary-row {
  grid-template-columns: 0.75rem var(--label-name-width) minmax(0, 1fr) auto;
  align-items: center;
}

.label-summary-bar-track {
  height: 0.55rem;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.label-summary-bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  opacity: 0.9;
}

.hourly-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 0.65rem;
  overflow: hidden;
}

.hourly-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 8.5rem;
  min-width: 100%;
  padding-top: 1.75rem;
}

.hourly-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
  position: relative;
}

.hourly-chart-tooltip {
  position: absolute;
  bottom: calc(100% - 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: var(--z-overlay);
  font-variant-numeric: tabular-nums;
}

.hourly-chart-col:hover .hourly-chart-tooltip,
.hourly-chart-col:focus-within .hourly-chart-tooltip {
  opacity: 1;
}

.hourly-chart-bar {
  display: block;
  width: 100%;
  max-width: 1.35rem;
  background: var(--heatmap-3);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  min-height: 0;
  transition: background 0.15s ease;
}

.hourly-chart-col:hover .hourly-chart-bar {
  background: var(--heatmap-4);
}

.hourly-chart-label {
  font-size: 0.75rem;
  color: var(--activity-muted);
  margin-top: 0.3rem;
  height: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.label-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--label-dot-ring);
}

.label-summary-name {
  font-weight: 600;
  width: var(--label-name-width);
  min-width: var(--label-name-width);
  max-width: var(--label-name-width);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-summary-meta {
  font-size: 0.82rem;
  color: var(--activity-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.session-row {
  grid-template-columns: auto 1fr;
}

.session-row-main {
  min-width: 0;
}

.session-running {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  vertical-align: middle;
}

.session-running::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: activity-pulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .session-running::before {
    animation: none;
  }

  .multi-day-bar-fill {
    transition: none;
  }

  .heatmap-cell:not(.heatmap-cell-empty):hover {
    transform: none;
  }
}

.activity-overview-toolbar {
  margin-top: 1.25rem;
  padding: 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.activity-overview-toolbar-row,
.activity-custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.activity-custom-range[hidden] {
  display: none !important;
}

.overview-range-select {
  max-width: 14rem;
  min-width: 10rem;
}

.overview-date-input {
  max-width: 11rem;
  min-width: 9rem;
}

.activity-toolbar-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--activity-muted);
}

.activity-overview-range {
  margin: 0;
  font-size: 0.85rem;
}

.overview-days-select {
  max-width: 10rem;
  min-width: 8rem;
}

/* 16 tiles in 4 thematic rows of 4 (Zeit / Rhythmus / Sessions / Verteilung). */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (max-width: 820px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  transition: border-color 0.15s ease;
}

.stat-card:hover {
  border-color: var(--stat-hover-border);
}

.stat-card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--activity-muted);
}

.stat-card-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.stat-card-hint {
  line-height: 1.35;
  color: var(--activity-muted);
}

.heatmap-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 1.1rem;
  overflow-x: auto;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--activity-muted);
}

.heatmap-legend-scale {
  display: inline-flex;
  gap: 3px;
}

.heatmap-legend-scale::before {
  content: "";
  display: inline-flex;
  gap: 3px;
  width: 5rem;
  height: 0.8rem;
  background: linear-gradient(
    to right,
    var(--heatmap-0),
    var(--heatmap-1),
    var(--heatmap-2),
    var(--heatmap-3),
    var(--heatmap-4)
  );
  border-radius: 4px;
}

.heatmap-grid {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}

.heatmap-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 4px;
  padding-top: 1px;
  margin-right: 0.2rem;
}

.heatmap-weekday-label {
  font-size: 0.75rem;
  color: var(--activity-muted);
  line-height: 14px;
}

.heatmap-weeks {
  display: flex;
  gap: 4px;
}

.heatmap-week-col {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  gap: 4px;
  position: relative;
}

.heatmap-week-col-month-start:not(:first-child) {
  margin-left: 6px;
}

.heatmap-week-col-month-start:not(:first-child)::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: color-mix(in srgb, var(--activity-muted) 55%, var(--border));
}

.heatmap-cell {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: var(--radius-xs);
  padding: 0;
  cursor: pointer;
  background: var(--heatmap-0);
  transition: outline 0.12s ease, transform 0.12s ease;
}

.heatmap-cell-empty {
  background: transparent;
  cursor: default;
}

.heatmap-cell:not(.heatmap-cell-empty):hover {
  outline: 2px solid var(--text);
  outline-offset: 1px;
  transform: scale(1.08);
}

.heatmap-cell:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.heatmap-months {
  display: flex;
  gap: 4px;
  margin-top: 0.45rem;
  margin-left: 1.55rem;
  min-height: 1rem;
}

.heatmap-month-mark {
  width: 14px;
  font-size: 0.75rem;
  color: var(--activity-muted);
  white-space: nowrap;
  overflow: visible;
}

.heatmap-month-mark-labeled {
  font-weight: 600;
  color: var(--text);
}

.heatmap-month-mark-start {
  margin-left: 6px;
}

.multi-day-bars {
  display: flex;
  flex-direction: column;
}

.multi-day-row {
  display: grid;
  grid-template-columns: 3.75rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.55rem 0.15rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 0.15s ease;
}

.multi-day-row:hover {
  background: var(--hover-tint);
}

.multi-day-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.multi-day-row-today .multi-day-date {
  color: var(--text);
  font-weight: 600;
}

.multi-day-row-today .multi-day-bar-fill {
  background: var(--heatmap-4);
}

.multi-day-date {
  font-size: 0.8rem;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--activity-muted);
  font-variant-numeric: tabular-nums;
}

.multi-day-bar-track {
  height: 0.55rem;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.multi-day-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--heatmap-3);
  border-radius: var(--radius-pill);
  transform: scaleX(var(--bar-fill, 0));
  transform-origin: left center;
  transition: transform 0.2s ease;
}

.multi-day-meta {
  font-size: 0.8rem;
  color: var(--activity-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 540px) {
  .btn,
  .nav-link {
    min-height: 44px;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .btn-small {
    min-height: 44px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .btn-icon,
  .btn-icon-nav {
    min-width: 44px;
    min-height: 44px;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .activity-page {
    --label-name-width: 7.5rem;
  }

  .activity-day-hero-metrics {
    flex-direction: column;
    align-items: stretch;
  }

  .activity-inline-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .label-summary-meta {
    font-size: 0.75rem;
  }

  .activity-nav .btn,
  .segmented-btn {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .stats-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-row {
    flex-direction: column;
    gap: 0.4rem;
  }

  .history-actions {
    align-self: flex-end;
  }

  /* 44px minimum touch target; visual cell stays 14×14px */
  .activity-page .heatmap-cell:not(.heatmap-cell-empty) {
    box-sizing: content-box;
    padding: 15px;
    margin: -15px;
    background-clip: content-box;
  }

  .activity-page .team-mini-heatmap-grid .heatmap-cell:not(.heatmap-cell-empty) {
    padding: 17px;
    margin: -17px;
  }
}

/* Settings page */
.settings-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 9rem;
}

.settings-select,
.settings-input {
  max-width: 12rem;
}

.settings-input-wide {
  max-width: 20rem;
  flex: 1;
  min-width: 12rem;
}

.api-token-secret {
  padding: 0.75rem;
  border-radius: 6px;
  background: var(--surface-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.signature-preview-wrap {
  min-height: 2.5rem;
}

.signature-preview {
  max-width: 240px;
  max-height: 80px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--signature-surface);
}

.signature-canvas {
  width: 100%;
  max-width: 480px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--signature-surface);
  touch-action: none;
  cursor: crosshair;
}

.api-token-secret-value {
  word-break: break-all;
  font-size: 0.85rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.25rem;
}

.label-rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.label-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.label-rule-arrow {
  color: var(--muted);
}

.settings-danger-title {
  color: var(--error-text);
}

.settings-danger-card {
  border-color: rgba(201, 42, 42, 0.5);
}

.settings-danger-text {
  color: var(--error-text);
}

.admin-user-table {
  font-size: 0.85rem;
}

@media (max-width: 540px) {
  .label-rule-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .label-rule-arrow {
    display: none;
  }

  .settings-label {
    min-width: 100%;
  }
}

/* Settings page */
.settings-page .settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  max-width: 100%;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.settings-page .settings-tabs .segmented-btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
  text-align: center;
  white-space: nowrap;
}

.settings-tab-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.settings-panel {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-panel[hidden] {
  display: none !important;
}

/* Stopwatch page */
.stopwatch-page .stopwatch-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  max-width: 100%;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.stopwatch-page .stopwatch-tabs .segmented-btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
  text-align: center;
  white-space: nowrap;
}

.stopwatch-tab-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.stopwatch-panel {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stopwatch-panel[hidden] {
  display: none !important;
}

/* Admin page */
.admin-page .admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  max-width: 100%;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.admin-page .admin-tabs .segmented-btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
  text-align: center;
  white-space: nowrap;
}

.admin-tab-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.admin-panel {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-panel[hidden] {
  display: none !important;
}

.admin-card {
  padding: 1rem 1.1rem;
  overflow-x: auto;
}

.admin-card + .admin-card {
  margin-top: 0;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0;
}

.admin-toolbar .input {
  min-width: 0;
  flex: 1 1 10rem;
  max-width: 100%;
}

.admin-toolbar .input[type="color"] {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  padding: 0.15rem;
}

.admin-team-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-team-row:last-child {
  border-bottom: none;
}

.admin-inline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  white-space: nowrap;
}

.admin-modal {
  max-width: 36rem;
}

.admin-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.65rem;
}

.admin-stats-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
}

.admin-dashboard-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.admin-section-title {
  margin: 0;
}

.admin-dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .admin-dashboard-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.admin-trend-chart {
  padding-top: 0.25rem;
}

.admin-trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 9rem;
  min-width: 100%;
}

.admin-trend-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.2rem;
}

.admin-trend-bar {
  display: block;
  width: 100%;
  max-width: 2.5rem;
  min-height: 0;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.admin-trend-col:hover .admin-trend-bar {
  opacity: 0.85;
}

.admin-trend-label {
  font-size: 0.75rem;
  color: var(--activity-muted);
}

.admin-trend-meta {
  font-size: 0.75rem;
  line-height: 1.2;
}

.admin-rank-table td,
.admin-team-table td,
.admin-rank-table th,
.admin-team-table th {
  padding: 0.55rem 0.65rem;
}

.admin-page .meta-table {
  margin-top: 0;
}

.admin-page .section {
  margin-top: 0;
}

.admin-page .section + .section {
  margin-top: 1.25rem;
}

.admin-page .label-summary-row:last-child {
  border-bottom: none;
}

.admin-page #admin-dashboard-labels .label-summary-row {
  padding: 0.55rem 0;
}

.admin-page #admin-dashboard-labels {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-export-section .admin-toolbar-inline {
  margin-top: 0.65rem;
  padding: 0;
  background: transparent;
  border: none;
}

.admin-role-select {
  min-width: 6.5rem;
  padding: 0.35rem 0.5rem;
}

@media (max-width: 540px) {
  .admin-page .admin-tabs .segmented-btn,
  .settings-page .settings-tabs .segmented-btn,
  .stopwatch-page .stopwatch-tabs .segmented-btn {
    flex: 1 1 calc(50% - 0.35rem);
    min-width: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    font-size: 0.8rem;
  }

  .stopwatch-page .row-input {
    flex-direction: column;
  }

  .stopwatch-page .row-input .btn-start {
    width: 100%;
  }

  .admin-stats-grid,
  .admin-stats-grid-compact {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Team activity */
.team-member-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.65rem;
}

.team-member-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
}

.team-member-hours {
  font-size: 1.25rem;
  font-weight: 600;
}

.activity-team-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 1.5rem;
}

.activity-team-row {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
}

.activity-team-label {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-team-track {
  min-height: 2.25rem;
  position: relative;
}

.team-mini-heatmaps {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.team-mini-heatmap-col {
  min-width: 8rem;
}

.team-mini-heatmap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 12rem;
}

.team-mini-heatmap-grid .heatmap-cell {
  width: 10px;
  height: 10px;
  padding: 0;
  border: none;
  border-radius: var(--radius-2);
}

.team-label-stack-track {
  display: flex;
  align-items: stretch;
  height: 0.55rem;
  overflow: hidden;
  border-radius: var(--radius-pill);
}

.team-label-seg {
  min-width: 2px;
  height: 100%;
  display: block;
}
