* { box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #4f46e5;
  --border: #334155;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.app-header {
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.app-header h1 {
  font-size: 18px;
  margin: 0;
  color: var(--text-dim);
  font-weight: 600;
}

.view {
  flex: 1;
  padding: 0 16px 24px;
}

.view.hidden { display: none; }

.running-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.running-banner.hidden { display: none; }

.running-banner-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.running-banner-info { flex: 1; min-width: 0; }

.running-category-name {
  font-size: 15px;
  color: var(--text-dim);
}

.running-elapsed {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stop-button {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.category-card {
  border: none;
  border-radius: 16px;
  padding: 20px 12px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.category-card.active {
  box-shadow: 0 0 0 3px white inset;
}

.text-button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 4px;
  margin-bottom: 8px;
}

h2 {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 20px 0 8px;
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 10px 12px;
}

.entry-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.entry-main { flex: 1; min-width: 0; }

.entry-category { font-size: 14px; font-weight: 600; }

.entry-time {
  font-size: 12px;
  color: var(--text-dim);
}

.entry-duration {
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.empty-note {
  color: var(--text-dim);
  font-size: 13px;
  padding: 12px 4px;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.nav-arrow {
  background: var(--bg-elevated);
  border: none;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 16px;
}

.current-date-label {
  font-size: 16px;
  font-weight: 600;
}

.timeline-wrap { margin-bottom: 8px; }

.timeline {
  position: relative;
  height: 36px;
  background: var(--bg-elevated);
  border-radius: 8px;
  overflow: hidden;
}

.timeline-segment {
  position: absolute;
  top: 0;
  bottom: 0;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.summary-bar-fill {
  height: 100%;
}

.summary-label {
  font-size: 13px;
  width: 72px;
  flex-shrink: 0;
}

.summary-duration {
  font-size: 13px;
  color: var(--text-dim);
  width: 64px;
  text-align: right;
  flex-shrink: 0;
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.tab-button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 14px 0;
}

.tab-button.active {
  color: var(--text);
  font-weight: 700;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-elevated);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}

.field input[type="color"] {
  padding: 4px;
  height: 44px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: #ef4444; color: white; }

.category-manage-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-manage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 10px;
}

.category-manage-item .entry-color-dot { width: 14px; height: 14px; }

.category-manage-item span { flex: 1; font-size: 14px; }

.icon-button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 4px 8px;
}
