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

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --active-bg: #eef2ff;
  --active-border: #c7d2fe;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.username {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.btn-text {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0;
}

.btn-text:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.date-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-picker label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.date-picker input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

.active-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--active-bg);
  border: 1px solid var(--active-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.active-panel.hidden {
  display: none;
}

.active-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.active-label {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.active-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.active-timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.control-panel {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.control-panel input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 1rem;
  background: var(--surface);
  transition: border-color 0.15s;
}

.control-panel input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.control-panel input:disabled {
  background: #f9fafb;
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-start {
  background: var(--primary);
  color: #fff;
}

.btn-start:hover {
  background: var(--primary-hover);
}

.btn-stop {
  background: var(--danger);
  color: #fff;
}

.btn-stop:hover {
  background: var(--danger-hover);
}

.records-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.records-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.total-time {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.entry-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.entry-list .empty-hint {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

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

.entry-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.entry-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-time-range {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.entry-duration {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-left: 16px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  z-index: 100;
  transition: opacity 0.3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 6px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.field span {
  font-size: 0.875rem;
  font-weight: 500;
}

.field input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--surface);
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn-block {
  width: 100%;
  margin-top: 4px;
}

.auth-hint {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    align-items: stretch;
  }

  .user-bar {
    justify-content: space-between;
  }

  .control-panel {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .active-timer {
    font-size: 1.25rem;
  }
}
