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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e40;
  --text: #f0f0f8;
  --muted: #7070a0;
  --accent: #38d9a9;
  --accent-dim: #1a5c4a;
  --danger: #ff6b6b;
  --danger-dim: #5c1a1a;
  --warning: #ffd43b;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
header {
  padding: calc(20px + env(safe-area-inset-top)) 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

header h1 span {
  color: var(--accent);
}

.header-date {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  flex: 1;
  text-align: center;
}

.btn-settings {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

/* Timer section */
.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 32px;
  gap: 32px;
}

.timer-display {
  font-size: 64px;
  font-weight: 200;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  opacity: 0.4;
  transition: opacity 0.3s, color 0.3s;
  line-height: 1;
}

.timer-display.running {
  opacity: 1;
  color: var(--accent);
}

.start-time-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.5px;
  height: 18px;
  text-align: center;
}

/* Main button */
.btn-main {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--accent-dim);
  box-shadow: 0 0 0 6px rgba(56, 217, 169, 0.08), inset 0 1px 0 rgba(255,255,255,0.08);
  outline: none;
  transition: background 0.25s, box-shadow 0.25s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.btn-main::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.3;
  transition: opacity 0.25s;
}

.btn-main:not(.active):hover {
  background: rgba(56, 217, 169, 0.25);
  box-shadow: 0 0 0 8px rgba(56, 217, 169, 0.12), inset 0 1px 0 rgba(255,255,255,0.08);
}

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

.btn-main .btn-icon {
  display: block;
  width: 28px;
  height: 28px;
  position: relative;
}

.btn-icon-play::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 22px solid #fff;
  margin-left: 5px;
  margin-top: 1px;
}

.btn-icon-stop::after {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 3px;
  margin: 4px auto 0;
}

.btn-main.active {
  background: var(--danger-dim);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.08), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: pulse 2s ease-in-out infinite;
}

.btn-main.active::before {
  border-color: var(--danger);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.08), inset 0 1px 0 rgba(255,255,255,0.08); }
  50% { box-shadow: 0 0 0 14px rgba(255, 107, 107, 0.04), inset 0 1px 0 rgba(255,255,255,0.08); }
}

/* Log section */
.log-section {
  flex: 1;
  padding: 0 16px 24px;
  overflow-y: auto;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px;
  margin-bottom: 4px;
}

.log-header h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-export {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent-dim);
  border-radius: 20px;
  padding: 5px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.btn-export:active { background: var(--accent-dim); }

.btn-export.secondary {
  color: var(--muted);
  border-color: var(--border);
}

.btn-export.secondary:active { background: var(--surface2); }

.btn-clear {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: none;
  border: 1px solid var(--danger-dim);
  border-radius: 20px;
  padding: 5px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.btn-clear:active { background: var(--danger-dim); }

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

/* Log cards */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.month-group {
  margin-bottom: 8px;
}

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

.month-header {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 8px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}

.btn-period-export {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}

.btn-period-export:active {
  border-color: var(--accent);
  color: var(--accent);
}

.month-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
  flex: 1;
}

.month-meta {
  font-size: 12px;
  color: var(--muted);
}

.month-chevron {
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
}

.month-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-card-day {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 1px;
}

.log-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 6px 8px;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}

.log-card:active {
  border-color: var(--accent);
}

.btn-delete-entry {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
  align-self: center;
}

.btn-delete-entry:active {
  color: var(--danger);
}

.log-card-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.log-card-hours {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  text-align: right;
}

.log-card-hours span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.log-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.log-card-time {
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--muted);
}

.tag.lunch { color: var(--warning); background: rgba(255, 212, 59, 0.1); }
.tag.wfh { color: var(--accent); background: rgba(56, 217, 169, 0.1); }
.tag.office { color: #a78bfa; background: rgba(167, 139, 250, 0.1); }

.log-card .btn-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  display: none;
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 24px;
}

.modal h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.modal-session-info {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}

.modal-question {
  margin-bottom: 20px;
}

.modal-question label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Toggle group */
.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle-btn {
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.toggle-btn:active { transform: scale(0.97); }

.toggle-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.btn-add-entry {
  display: block;
  width: 100%;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px dashed var(--border);
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, color 0.2s;
}

.btn-add-entry:active {
  border-color: var(--accent);
  color: var(--accent);
}

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-input {
  flex: 1;
}

.time-sep {
  color: var(--muted);
  font-size: 16px;
}

.notes-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 12px 14px;
  resize: none;
  outline: none;
  transition: border-color 0.18s;
}

.notes-input:focus {
  border-color: var(--accent);
}

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

.log-card-notes {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
}

.btn-modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

.btn-confirm {
  width: 100%;
  margin-top: 24px;
  padding: 18px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #0a1a14;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-confirm:active { opacity: 0.85; transform: scale(0.98); }

.btn-reset {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid var(--danger-dim);
  background: none;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, transform 0.1s;
}

.btn-reset:active { background: var(--danger-dim); transform: scale(0.98); }
