@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #10171E;
  --surface:   #161f2c;
  --surface2:  #1d2b3a;
  --border:    #263547;
  --text:      #f0f2f0;
  --muted:     #7a8fa8;
  --primary:   #BAD839;
  --primary-dk:#8fa82a;
  --primary-txt:#10171E;
  --start-bg:  #BAD839;
  --start-glow:rgba(186,216,57,0.28);
  --stop-bg:   #e63946;
  --stop-glow: rgba(230,57,70,0.25);
  --radius:    14px;
  --header-h:  62px;
  --font:      'Space Grotesk', -apple-system, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #0c1118;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 16px;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
}

.header-brand svg { width: 24px; height: 24px; color: var(--primary); }

.header-clock {
  font-family: 'Courier New', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 3px;
  flex: 1;
  text-align: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  white-space: nowrap;
}

.header-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--muted);
}

.header-stats strong { color: var(--primary); font-size: 14px; }

.btn-dashboard {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 7px;
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.3px;
}

.btn-dashboard:hover {
  background: var(--primary);
  color: var(--primary-txt);
}

/* ── Main Layout ─────────────────────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Timer Section (left) ────────────────────────────────────────────────── */
.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px 30px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* ── Selectors ───────────────────────────────────────────────────────────── */
.selectors { width: 100%; max-width: 420px; display: flex; gap: 10px; }

.select-wrap { flex: 1; position: relative; }

.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  font-size: 12px;
}

.select-input {
  width: 100%;
  padding: 12px 36px 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
  border-left: 4px solid var(--primary);
}

.select-input:focus { outline: none; border-color: var(--primary); }
.select-input option { background: var(--surface2); }

/* ── Timer Button ────────────────────────────────────────────────────────── */
.timer-btn {
  position: relative;
  width:  clamp(220px, 40vmin, 340px);
  height: clamp(220px, 40vmin, 340px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: none;
  flex-shrink: 0;
}

.timer-btn:active { transform: scale(0.96); }

.timer-btn.idle {
  background: radial-gradient(circle at 35% 30%, #d4f050, #9bbb1f);
  box-shadow:
    0 0 0 10px var(--start-glow),
    0 0 0 22px rgba(186,216,57,0.10),
    0 24px 60px rgba(0,0,0,0.55);
  color: var(--primary-txt);
}

.timer-btn.running {
  background: radial-gradient(circle at 35% 30%, #ff5c6a, #c41e2d);
  box-shadow:
    0 0 0 10px var(--stop-glow),
    0 0 0 22px rgba(230,57,70,0.10),
    0 24px 60px rgba(0,0,0,0.55);
  color: #fff;
  animation: timerPulse 2.2s ease-in-out infinite;
}

@keyframes timerPulse {
  0%,100% {
    box-shadow: 0 0 0 10px var(--stop-glow),  0 0 0 20px rgba(230,57,70,0.10), 0 24px 60px rgba(0,0,0,0.55);
  }
  50% {
    box-shadow: 0 0 0 16px rgba(230,57,70,0.22), 0 0 0 30px rgba(230,57,70,0.08), 0 24px 60px rgba(0,0,0,0.55);
  }
}

.timer-icon-wrap svg {
  width: clamp(28px, 5vmin, 44px);
  height: clamp(28px, 5vmin, 44px);
  opacity: 0.9;
}

.timer-time {
  font-family: 'Courier New', monospace;
  font-size: clamp(2rem, 5.5vmin, 3.8rem);
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1;
}

.timer-action {
  font-size: clamp(0.7rem, 1.8vmin, 1rem);
  font-weight: 700;
  letter-spacing: 4px;
  opacity: 0.85;
  font-family: var(--font);
}

/* ── Description Input ───────────────────────────────────────────────────── */
.description-wrap { width: 100%; max-width: 420px; }

.description-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.description-input::placeholder { color: var(--muted); }
.description-input:focus { outline: none; border-color: var(--primary); }

/* ── Recent Section (right) ──────────────────────────────────────────────── */
.recent-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-title {
  padding: 18px 22px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-family: var(--font);
}

.today-badge {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  background: rgba(186,216,57,0.1);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(186,216,57,0.3);
}

.recent-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-list::-webkit-scrollbar { width: 4px; }
.recent-list::-webkit-scrollbar-track { background: transparent; }
.recent-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Recent Card ─────────────────────────────────────────────────────────── */
.recent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}

.recent-card:hover {
  border-color: var(--primary);
  background: var(--surface2);
}

.recent-card.active-entry {
  border-color: var(--stop-bg);
  background: rgba(230,57,70,0.06);
}

.recent-color {
  width: 4px;
  min-width: 4px;
  height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}

.recent-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.recent-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: space-between;
}

.recent-project {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-duration {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}

.recent-desc {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta { font-size: 11px; color: var(--border); }

.btn-resume {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-resume:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-txt);
  transform: scale(1.1);
}

.btn-resume:active { transform: scale(0.95); }

.empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: var(--primary-txt);
  font-weight: 700;
  padding: 11px 24px;
  border-radius: 30px;
  font-size: 13px;
  letter-spacing: 0.3px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Portrait ────────────────────────────────────────────────────────────── */
@media (orientation: portrait), (max-width: 700px) {
  html, body { overflow: auto; }
  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto; overflow: visible;
  }
  .timer-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 28px 20px;
    min-height: 55vh;
  }
  .recent-section { max-height: none; overflow: visible; }
  .recent-list { max-height: 45vh; overflow-y: auto; }
  .header-stats { display: none; }
}

@media (max-width: 480px) {
  .header-clock { font-size: 18px; }
  .header-brand span { display: none; }
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Save Running Button ─────────────────────────────────────────────────── */
.btn-save-running {
  width: 100%;
  max-width: 420px;
  padding: 12px 20px;
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 9px;
  color: var(--primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s;
}

.btn-save-running:hover {
  background: var(--primary);
  color: var(--primary-txt);
}

/* ── Edit Modal ──────────────────────────────────────────────────────────── */
.edit-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
}

.edit-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%);
  opacity: 0;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  z-index: 201;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.edit-modal.open {
  transform: translate(-50%, -50%);
  opacity: 1;
}

.edit-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.edit-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s;
}

.edit-modal-close:hover { color: var(--text); }

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.edit-field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.edit-input, .edit-select {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.edit-input:focus, .edit-select:focus {
  outline: none;
  border-color: var(--primary);
}

.edit-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.edit-select option { background: var(--surface2); }

.edit-row {
  display: flex;
  gap: 10px;
}

.edit-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.edit-btn-cancel {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.edit-btn-cancel:hover { border-color: var(--muted); color: var(--text); }

.edit-btn-save {
  padding: 10px 24px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: var(--primary-txt);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.edit-btn-save:hover { background: var(--primary-dk); }
