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

:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: #e5e5e5;
  --accent: #2563eb;
  --highlight: #f0f0f0;
  --panel-bg: #fff;
  --timer-active: #059669;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.container {
  width: 100%;
  max-width: 500px;
  padding: 40px 20px;
  min-height: 100vh;
  /* Center in the space left of the panel */
  margin-left: max(20px, calc((50vw - 500px) / 2));
  margin-right: 50vw;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

header h1 {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.5px;
  cursor: help;
  position: relative;
}

header h1:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 12px;
  width: 400px;
  padding: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 50;
  cursor: default;
}

.tooltip p {
  margin-bottom: 12px;
}

.tooltip p:last-child {
  margin-bottom: 0;
  font-style: italic;
  color: var(--text-muted);
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

section {
  margin-bottom: 40px;
}

h2 {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.today-total {
  font-weight: 400;
  margin-left: 8px;
}

.task-list {
  list-style: none;
  min-height: 40px;
}

.task-item {
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.1s;
  user-select: none;
}

.task-item:hover {
  background: var(--highlight);
}

.task-item.selected {
  background: var(--highlight);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.task-item.completed .task-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-item.dragging {
  opacity: 0.5;
}

.task-item.drag-over {
  border-top: 2px solid var(--accent);
}

.task-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.task-checkbox:hover {
  border-color: var(--text);
}

.task-item.completed .task-checkbox {
  background: var(--text-muted);
  border-color: var(--text-muted);
}

.task-item.completed .task-checkbox::after {
  content: '✓';
  color: white;
  font-size: 10px;
}

.task-text {
  flex: 1;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.timer-display {
  font-variant-numeric: tabular-nums;
  color: var(--timer-active);
  font-weight: 500;
}

.total-time {
  font-variant-numeric: tabular-nums;
}

.new-task-input {
  position: fixed;
  bottom: 40px;
  left: max(20px, calc((50vw - 500px) / 2));
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
  box-sizing: border-box;
}

.new-task-input input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel-bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.new-task-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-input {
  position: fixed;
  bottom: 40px;
  left: max(20px, calc((50vw - 500px) / 2));
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
  box-sizing: border-box;
}

.modal-input-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.modal-input input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel-bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.modal-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-input-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Task Detail Panel */
.task-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 50vw;
  max-width: 700px;
  min-width: 400px;
  height: 100vh;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.focus-checklist {
  display: none;
  padding: 16px 24px;
  background: #f0fdf4;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}

body.focus-mode .focus-checklist.has-items {
  display: block;
}

.focus-checklist-title {
  font-weight: 500;
  color: var(--timer-active);
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.focus-checklist-items {
  color: #166534;
}

.focus-checklist-item::before {
  content: '✓ ';
  opacity: 0.5;
}

.panel-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 24px;
}

.panel-content {
  flex: 1;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  padding: 24px 24px 12px 24px;
}

.panel-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
}

.panel-stats {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 24px 16px 24px;
  border-bottom: 1px solid var(--border);
}

.log-section {
  overflow-y: auto;
  padding: 0 24px;
}

.log-section h3 {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--panel-bg);
}

.log-entries {
}

.new-log-entry {
  padding: 16px 24px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel-bg);
}

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: baseline;
}

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

.log-entry-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.log-entry-content {
  font-size: 14px;
  white-space: pre-wrap;
}

.log-entry.timer-event {
  color: var(--text-muted);
  font-style: italic;
}

.log-entry.timer-event .log-entry-content {
  font-size: 13px;
}

.new-log-entry textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
}

.new-log-entry textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.new-log-entry button {
  padding: 8px 16px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.new-log-entry button:hover {
  opacity: 0.9;
}

/* Command Palette */
.command-palette {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 480px;
  background: var(--panel-bg);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: none;
  z-index: 200;
  overflow: hidden;
}

.command-palette.open {
  display: block;
}

.palette-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.palette-header input {
  width: 100%;
  padding: 8px 0;
  border: none;
  font-size: 16px;
  font-family: inherit;
  background: transparent;
}

.palette-header input:focus {
  outline: none;
}

.palette-commands {
  list-style: none;
  max-height: 480px;
  overflow-y: auto;
}

.palette-commands li {
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.palette-commands li:hover,
.palette-commands li.highlighted {
  background: var(--highlight);
}

.cmd-name {
  font-size: 14px;
}

.cmd-shortcut {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: none;
  z-index: 150;
}

.overlay.open {
  display: block;
}

/* Empty states */
.task-list:empty::after {
  content: 'No tasks';
  display: block;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

#today-list:empty::after {
  content: 'Drag tasks here or press t';
}

#inbox-list:empty::after {
  content: 'Press n to add a task';
}

#history-list:empty::after {
  content: 'Completed tasks will appear here';
}

.history-date-header {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 16px 12px 4px 12px;
}

/* Focus mode - when timer is running */
body.focus-mode .task-item {
  opacity: 0.15;
  transition: opacity 0.3s;
}

body.focus-mode .task-item.has-timer {
  opacity: 1;
  background: var(--highlight);
}

body.focus-mode h2,
body.focus-mode header .hint {
  opacity: 0.15;
  transition: opacity 0.3s;
}

body.focus-mode .task-list:empty::after {
  opacity: 0.15;
}

/* Responsive */
@media (max-width: 480px) {
  .task-detail-panel {
    width: 100%;
    right: -100%;
  }

  .command-palette {
    max-width: calc(100% - 32px);
  }
}
