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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  padding: 20px;
  margin: 0 auto;
}

header { margin-bottom: 24px; }
h1 { font-size: 24px; color: #f0f6fc; }
.subtitle { color: #8b949e; font-size: 14px; margin-top: 4px; }
h2 { font-size: 16px; color: #f0f6fc; margin-bottom: 12px; }

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Summary stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item { background: #0d1117; border-radius: 4px; padding: 12px; }
.stat-value { font-size: 22px; font-weight: 600; color: #f0f6fc; }
.stat-label { font-size: 12px; color: #8b949e; margin-top: 2px; }

/* Summary bar */
.summary-bar {
  height: 28px;
  display: flex;
  border-radius: 4px;
  margin-bottom: 12px;
}

.summary-bar .summary-bar-segment:first-child { border-radius: 4px 0 0 4px; }
.summary-bar .summary-bar-segment:last-child { border-radius: 0 4px 4px 0; }

.summary-bar-segment {
  height: 100%;
  position: relative;
  min-width: 1px;
  transition: opacity 0.15s;
  cursor: default;
}

.summary-bar-segment:hover { opacity: 0.85; }

.summary-bar-segment .bar-tip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.summary-bar-segment:hover .bar-tip { display: block; }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.legend-group { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.legend-group-header { font-weight: 600; color: #f0f6fc; white-space: nowrap; }
.legend-group-total { font-weight: 400; color: #8b949e; }
.legend-group-items { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.legend-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend-color { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* Controls */
.controls-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.controls-row label { font-size: 13px; color: #8b949e; }
.controls-row select {
  background: #0d1117;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  margin-left: 4px;
}

/* Timeline container */
#timeline-container {
  display: flex;
  position: relative;
}

#time-gutter {
  width: 80px;
  flex-shrink: 0;
  position: relative;
}

.time-label {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: #484f58;
  white-space: nowrap;
  transform: translateY(-50%);
  user-select: none;
}

.time-label.day-label {
  color: #8b949e;
  font-weight: 600;
  font-size: 12px;
}

#lanes-area {
  flex: 1;
  position: relative;
  min-height: 100px;
}

/* Day separator lines */
.day-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #21262d;
  pointer-events: none;
  z-index: 0;
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #161b22;
  pointer-events: none;
  z-index: 0;
}

/* Session column (absolutely positioned) */
.session-col {
  position: absolute;
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  outline: 1px solid rgba(255,255,255,0.06);
  transition: outline-color 0.15s;
  z-index: 1;
}

.session-col:hover {
  outline-color: #58a6ff;
  z-index: 2;
}

.session-col.selected {
  outline-color: #58a6ff;
  z-index: 3;
}

/* Segment within a column */
.seg {
  width: 100%;
  min-height: 0.5px;
}

/* Tooltip */
.hover-tooltip {
  position: fixed;
  background: #1c2128;
  border: 1px solid #58a6ff;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  max-width: 320px;
  line-height: 1.5;
  display: none;
}

.hover-tooltip.visible { display: block; }
.hover-tooltip .tt-title { color: #f0f6fc; font-weight: 600; margin-bottom: 4px; }
.hover-tooltip .tt-row { color: #8b949e; }
.hover-tooltip .tt-row span { color: #c9d1d9; }
.hover-tooltip .tt-seg { margin-top: 6px; padding-top: 6px; border-top: 1px solid #30363d; }
.hover-tooltip .tt-seg-label { font-weight: 600; color: #c9d1d9; }

/* Session detail panel */
.session-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 480px;
  height: 100vh;
  background: #161b22;
  border-left: 2px solid #58a6ff;
  overflow-y: auto;
  z-index: 500;
  padding: 20px;
  transition: transform 0.2s ease;
}

.session-panel.hidden { transform: translateX(100%); }

.panel-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
}

.panel-close:hover { border-color: #58a6ff; }
.panel-title { font-size: 16px; color: #f0f6fc; margin-bottom: 4px; }
.panel-subtitle { font-size: 12px; color: #8b949e; margin-bottom: 16px; }

.panel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.panel-stat { background: #0d1117; border-radius: 4px; padding: 8px 10px; }
.panel-stat-value { font-size: 16px; font-weight: 600; color: #f0f6fc; }
.panel-stat-label { font-size: 11px; color: #8b949e; }
.panel-section-title { font-size: 13px; color: #f0f6fc; margin: 12px 0 8px; font-weight: 600; }

.panel-turn {
  background: #0d1117;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
}

.panel-turn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #8b949e;
  margin-bottom: 6px;
  cursor: pointer;
}

.panel-turn-header strong { color: #c9d1d9; }

.panel-turn-bar {
  height: 16px;
  display: flex;
  border-radius: 2px;
  overflow: hidden;
}

.panel-turn-bar-seg { height: 100%; min-width: 1px; }

.panel-turn-segs {
  display: none;
  margin-top: 8px;
  font-size: 11px;
  font-family: monospace;
  color: #8b949e;
  border-top: 1px solid #21262d;
  padding-top: 6px;
}

.panel-turn.expanded .panel-turn-segs { display: block; }

.panel-seg-line { padding: 1px 0; display: flex; gap: 8px; }
.panel-seg-type { width: 120px; flex-shrink: 0; }
.panel-seg-time { width: 90px; flex-shrink: 0; }
.panel-seg-dur { width: 60px; text-align: right; flex-shrink: 0; }

/* Gap indicator between activity periods */
.gap-indicator {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #484f58;
  border-top: 1px dashed #21262d;
  border-bottom: 1px dashed #21262d;
  pointer-events: none;
  z-index: 0;
}

.loading { text-align: center; padding: 40px; color: #8b949e; }
