:root {
  --blue: #2563eb;
  --blue-light: #93c5fd;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --hour-height: 60px;
  --timeline-left: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  gap: 8px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--blue);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

button, .btn-icon {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background .15s;
}

button:hover, .btn-icon:hover { background: var(--border); }

.btn-small {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.btn-icon {
  padding: 6px;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  padding: 8px 20px;
  font-weight: 600;
  border-radius: var(--radius);
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  background: var(--border);
  padding: 8px 20px;
  font-weight: 600;
  border-radius: var(--radius);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  padding: 8px 20px;
  font-weight: 600;
  border-radius: var(--radius);
}
.btn-danger:hover { background: #b91c1c; }

/* Timeline */
#app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

#timeline {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-height: calc(var(--hour-height) * 16);
  user-select: none;
}

.hour-row {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--hour-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
}

.hour-label {
  width: var(--timeline-left);
  padding: 4px 8px 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.hour-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-top: 10px;
}

/* Now indicator */
.now-indicator {
  position: absolute;
  left: var(--timeline-left);
  right: 0;
  height: 2px;
  background: #dc2626;
  z-index: 10;
  pointer-events: none;
}

.now-indicator::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
}

/* Time Blocks */
.time-block {
  position: absolute;
  left: calc(var(--timeline-left) + 4px);
  right: 8px;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  z-index: 5;
  overflow: hidden;
  transition: box-shadow .15s;
  display: flex;
  flex-direction: column;
  min-height: 24px;
}

.time-block:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  z-index: 6;
}

.time-block.done {
  opacity: 0.6;
}

.time-block.done .block-label::after {
  content: ' \2713';
}

.block-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-time {
  font-size: 0.7rem;
  color: rgba(255,255,255,.85);
}

.block-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}

.time-block:hover .block-actions {
  opacity: 1;
}

.block-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: rgba(255,255,255,.25);
  color: #fff;
  font-size: 0.7rem;
  padding: 0;
}

.block-action-btn:hover {
  background: rgba(255,255,255,.45);
}

/* Resize handle */
.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  background: transparent;
}

.resize-handle:hover {
  background: rgba(255,255,255,.3);
}

/* Drag preview */
.time-block.dragging {
  opacity: 0.7;
  z-index: 20;
}

/* Dialogs */
dialog {
  border: none;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

dialog::backdrop {
  background: rgba(0,0,0,.4);
}

dialog h2 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

dialog label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 4px;
}

dialog input[type="text"],
dialog input[type="time"],
dialog textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.95rem;
}

dialog textarea {
  resize: vertical;
}

#color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 8px;
}

.dialog-actions-right {
  display: flex;
  gap: 8px;
}

/* Focus Timer */
.focus-content {
  text-align: center;
}

#focus-timer-display {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 24px 0;
  color: var(--blue);
}

#focus-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Review */
#review-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* FAB */
#fab-add {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fab-add:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

/* Responsive */
@media (max-width: 600px) {
  #app-header { padding: 6px 8px; }
  .header-left h1 { font-size: 1rem; }
  #app-main { padding: 8px; }
  :root { --timeline-left: 44px; --hour-height: 50px; }
  .hour-label { font-size: 0.65rem; padding: 2px 4px 0; }
  dialog { padding: 16px; }
}

/* RTL (Hebrew) */
[dir="rtl"] .hour-label { text-align: left; }
[dir="rtl"] .time-block { left: 8px; right: calc(var(--timeline-left) + 4px); }
[dir="rtl"] .now-indicator { left: 0; right: var(--timeline-left); }
[dir="rtl"] .now-indicator::before { left: auto; right: -5px; }
[dir="rtl"] .block-actions { right: auto; left: 4px; }
[dir="rtl"] #fab-add { right: auto; left: 24px; }
