:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-from: #1a1830;
  --bg-to: #08080f;
  --glow: rgba(180, 175, 230, 0.18);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ece9f5;
  --text-muted: #8a86a0;
  --text-faint: #56546b;
  --accent: #c8c5e8;
  --accent-soft: rgba(200, 197, 232, 0.14);
  --danger: #e89a9a;
  --success: #a8d8c0;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-from: #f6f3ee;
  --bg-to: #e6e2dc;
  --glow: rgba(140, 130, 180, 0.12);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(20, 18, 35, 0.08);
  --border-strong: rgba(20, 18, 35, 0.16);
  --text: #1a1825;
  --text-muted: #6b6878;
  --text-faint: #a8a5b3;
  --accent: #5a5478;
  --accent-soft: rgba(90, 84, 120, 0.1);
  --danger: #b85a5a;
  --success: #4a8a6c;
  --shadow: 0 20px 60px -20px rgba(40, 30, 60, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-from) 0%, var(--bg-to) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.moon-glow {
  position: fixed;
  top: -200px;
  right: -200px;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  filter: blur(20px);
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 40px;
  max-width: 880px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 24px var(--accent), inset -3px -3px 6px rgba(0, 0, 0, 0.25);
}

.brand-name {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

.layout {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 40px 80px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.timer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 48px 40px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow);
}

.task-input {
  width: 100%;
  max-width: 420px;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 400;
  padding: 12px 4px;
  outline: none;
  transition: border-color var(--transition);
  letter-spacing: -0.01em;
}

.task-input::placeholder {
  color: var(--text-faint);
  font-weight: 300;
}

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

.timer-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 653.45;
  stroke-dashoffset: 653.45;
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 6px var(--accent));
  opacity: 0;
}

.timer-card.running .ring-progress {
  opacity: 1;
  animation: pulse 3s ease-in-out infinite;
}

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

.timer-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.timer-text {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 200;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.earned-text {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.primary-btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bg-to);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  cursor: pointer;
  transition: var(--transition);
  min-width: 160px;
}

[data-theme="light"] .primary-btn {
  color: #fff;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px -10px var(--accent);
}

.primary-btn.small {
  padding: 10px 24px;
  min-width: auto;
}

.timer-card.running .primary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.timer-card.running .primary-btn:hover {
  background: var(--surface-strong);
  box-shadow: none;
}

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

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px;
}

.section-head h2 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.totals {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.entry-list,
.totals-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.entry-list li,
.totals-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  background: var(--surface);
  transition: background var(--transition);
}

.totals-list li {
  grid-template-columns: 1fr auto auto;
}

.entry-list li:hover,
.totals-list li:hover {
  background: var(--surface-strong);
}

.entry-task {
  font-size: 15px;
  color: var(--text);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-time,
.entry-money {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.entry-money {
  color: var(--text);
  min-width: 70px;
  text-align: right;
}

.entry-actions {
  display: flex;
  gap: 4px;
}

.entry-actions .icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
}

.entry-actions .icon-btn:hover {
  background: var(--surface-strong);
}

.empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 20px;
  margin: 0;
  font-style: italic;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 220ms ease;
}

.modal-backdrop[hidden] {
  display: none;
}

[data-theme="light"] .modal-backdrop {
  background: rgba(40, 30, 60, 0.25);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: linear-gradient(180deg, var(--bg-from) 0%, var(--bg-to) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  animation: slideUp 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.field span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.field input:focus {
  border-color: var(--accent);
  background: var(--surface-strong);
}

.rate-input,
.duration-input {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: var(--transition);
}

.rate-input:focus-within,
.duration-input:focus-within {
  border-color: var(--accent);
  background: var(--surface-strong);
}

.rate-input input,
.duration-input input {
  background: transparent;
  border: none;
  padding: 12px 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.rate-input input:focus,
.duration-input input:focus {
  background: transparent;
  border: none;
}

.rate-input .prefix,
.rate-input .suffix,
.duration-input .unit {
  font-size: 14px;
  color: var(--text-muted);
  padding: 0 6px;
  font-family: var(--font-mono);
}

.duration-input input {
  width: 60px;
  text-align: center;
}

.field-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin: -10px 0 0;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  gap: 12px;
}

.ghost-btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.ghost-btn.destructive:hover {
  color: var(--danger);
  border-color: var(--danger);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}
