@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border-color: rgba(255,255,255,0.08);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --danger: #ff4466;
  --success: #44ffaa;
  --warning: #ffaa44;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ===== Background Ambience ===== */
.bg-orbs {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.bg-orbs .orb {
  position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.12;
  animation: orbFloat 20s ease-in-out infinite;
}
.bg-orbs .orb:nth-child(1) { width: 500px; height: 500px; background: #6366f1; top: -10%; left: -5%; animation-delay: 0s; }
.bg-orbs .orb:nth-child(2) { width: 400px; height: 400px; background: #ec4899; bottom: -10%; right: -5%; animation-delay: -7s; }
.bg-orbs .orb:nth-child(3) { width: 350px; height: 350px; background: #14b8a6; top: 40%; left: 50%; animation-delay: -14s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ===== App Shell ===== */
.app { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 24px 20px 80px; }

/* ===== Header ===== */
.header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  padding: 20px 24px; margin-bottom: 28px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius); backdrop-filter: blur(20px);
}
.header-title { display: flex; align-items: center; gap: 12px; }
.header-title .icon { font-size: 28px; }
.header-title h1 {
  font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #6366f1, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0; transition: var(--transition);
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(99,102,241,0.45); transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white; box-shadow: 0 4px 16px rgba(239,68,68,0.25);
}
.btn-danger:hover { box-shadow: 0 6px 24px rgba(239,68,68,0.4); transform: translateY(-1px); }

.btn-ghost {
  background: rgba(255,255,255,0.06); color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: var(--radius-xs); }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 1.1rem;
}
.btn-icon.sm { width: 34px; height: 34px; font-size: 0.95rem; }

/* ===== Timer Grid ===== */
.timer-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }

/* ===== Timer Card ===== */
.timer-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius); padding: 24px;
  backdrop-filter: blur(16px); transition: var(--transition);
  position: relative; overflow: hidden;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.timer-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--timer-color);
  border-radius: var(--radius) var(--radius) 0 0;
}
.timer-card:hover { background: var(--bg-card-hover); transform: translateY(-2px); box-shadow: var(--shadow); }
.timer-card.completed {
  opacity: 0.5; filter: grayscale(0.6);
}
.timer-card.completed::before { background: var(--text-muted); }
.timer-card.on-break::before {
  background: repeating-linear-gradient(90deg, var(--timer-color) 0 10px, transparent 10px 20px);
  animation: breakStripe 1s linear infinite;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
}
@keyframes breakStripe {
  to { background-position: 20px 0; }
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-name {
  font-size: 1rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card-name .color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 8px var(--timer-color);
}
.card-badge {
  font-size: 0.7rem; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px;
}
.card-badge.running { background: rgba(34,197,94,0.15); color: #4ade80; }
.card-badge.paused { background: rgba(250,204,21,0.15); color: #facc15; }
.card-badge.completed { background: rgba(120,120,140,0.15); color: #888; }
.card-badge.break { background: rgba(56,189,248,0.15); color: #38bdf8; }
.card-badge.idle { background: rgba(160,160,180,0.1); color: #777; }

/* Ring */
.timer-ring-wrap {
  display: flex; justify-content: center; align-items: center;
  margin-bottom: 20px; position: relative;
}
.timer-ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.timer-ring .ring-bg {
  fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 6;
}
.timer-ring .ring-progress {
  fill: none; stroke: var(--timer-color); stroke-width: 6;
  stroke-linecap: round; transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 6px var(--timer-color));
}
.timer-time-display {
  position: absolute; text-align: center;
}
.timer-time-display .time {
  font-family: 'JetBrains Mono', monospace; font-size: 1.5rem; font-weight: 500;
  color: var(--text-primary);
}
.timer-time-display .label {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 2px;
}

/* Controls */
.card-controls {
  display: flex; gap: 8px; justify-content: center; align-items: center;
}
.card-actions {
  display: flex; justify-content: space-between; align-items: center; margin-top: 16px;
}
.expand-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 4px 8px;
  border-radius: var(--radius-xs); transition: var(--transition);
}
.expand-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.delete-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.85rem; padding: 4px 8px;
  border-radius: var(--radius-xs); transition: var(--transition);
}
.delete-btn:hover { color: var(--danger); }

/* Break info */
.break-info {
  font-size: 0.75rem; color: var(--text-muted); text-align: center;
  margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: var(--transition);
  padding: 20px;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius); padding: 32px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal h2 { font-size: 1.3rem; margin-bottom: 24px; font-weight: 700; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--text-muted); font-size: 1.4rem;
  cursor: pointer; transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

/* Form */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem; transition: var(--transition);
  outline: none;
}
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-input::placeholder { color: var(--text-muted); }

.time-inputs { display: flex; gap: 12px; }
.time-inputs .form-group { flex: 1; }
.time-inputs .form-input { text-align: center; }

.color-options { display: flex; gap: 10px; flex-wrap: wrap; }
.color-option {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: var(--transition); position: relative;
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: white; box-shadow: 0 0 12px var(--c); }
.color-option.custom-color {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: white; text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* Break toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.toggle-switch {
  width: 48px; height: 26px; background: rgba(255,255,255,0.1);
  border-radius: 20px; border: none; cursor: pointer; position: relative;
  transition: var(--transition);
}
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: var(--transition);
}
.toggle-switch.active { background: #6366f1; }
.toggle-switch.active::after { left: 25px; }

.break-config { overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.break-config.show { max-height: 200px; }
.break-fields { display: flex; gap: 12px; padding-top: 12px; }
.break-fields .form-group { flex: 1; }

.form-actions { display: flex; gap: 12px; margin-top: 28px; }
.form-actions .btn { flex: 1; justify-content: center; padding: 12px; }

/* ===== Alarm Modal ===== */
.alarm-modal .modal { text-align: center; max-width: 400px; }
.alarm-icon { font-size: 3.5rem; margin-bottom: 12px; animation: alarmPulse 0.6s ease-in-out infinite alternate; }
@keyframes alarmPulse {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.1) rotate(5deg); }
}
.alarm-title { font-size: 1.2rem; margin-bottom: 8px; }
.alarm-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; }
.alarm-continue {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 16px;
}
.alarm-continue .form-input { width: 70px; text-align: center; }
.alarm-actions { display: flex; gap: 12px; }
.alarm-actions .btn { flex: 1; justify-content: center; }

/* ===== Focus Mode ===== */
.focus-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg-primary);
  display: flex; opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease;
}
.focus-overlay.active { opacity: 1; visibility: visible; }

.focus-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px;
  position: relative;
}
.focus-close {
  position: absolute; top: 24px; left: 24px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-color);
  color: var(--text-secondary); font-size: 1.2rem;
  width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.focus-close:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.focus-name {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 40px;
  display: flex; align-items: center; gap: 12px;
}
.focus-name .color-dot { width: 14px; height: 14px; border-radius: 50%; }

.focus-ring { width: 280px; height: 280px; transform: rotate(-90deg); margin-bottom: 24px; }
.focus-ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 5; }
.focus-ring .ring-progress {
  fill: none; stroke-width: 5; stroke-linecap: round;
  filter: drop-shadow(0 0 10px var(--timer-color));
  transition: stroke-dashoffset 0.5s ease;
}
.focus-time {
  font-family: 'JetBrains Mono', monospace; font-size: 3.5rem; font-weight: 500;
  margin-bottom: 8px;
}
.focus-label { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 32px; }
.focus-controls { display: flex; gap: 12px; }

/* Tasks sidebar */
.focus-sidebar {
  width: 340px; border-left: 1px solid var(--border-color);
  background: rgba(255,255,255,0.02); display: flex; flex-direction: column;
  padding: 24px;
}
.sidebar-title {
  font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.task-input-row { display: flex; gap: 8px; margin-bottom: 16px; }
.task-input-row .form-input { flex: 1; padding: 10px 14px; font-size: 0.85rem; }
.task-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.03); font-size: 0.85rem;
  transition: var(--transition); animation: cardIn 0.3s ease both;
}
.task-item:hover { background: rgba(255,255,255,0.06); }
.task-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid var(--text-muted); background: none;
  cursor: pointer; flex-shrink: 0; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; color: transparent;
}
.task-check.checked {
  background: var(--success); border-color: var(--success); color: #000;
}
.task-text { flex: 1; }
.task-item.done .task-text { text-decoration: line-through; color: var(--text-muted); }
.task-delete {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.85rem; opacity: 0; transition: var(--transition);
}
.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--danger); }

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .app { padding: 16px 12px 60px; }
  .header { padding: 16px; flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: center; }
  .timer-grid { grid-template-columns: 1fr; }
  .focus-overlay { flex-direction: column; }
  .focus-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border-color); max-height: 40vh; }
  .focus-time { font-size: 2.5rem; }
  .focus-ring { width: 200px; height: 200px; }
}

/* ===== Toast ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  color: var(--text-primary); font-size: 0.85rem;
  box-shadow: var(--shadow); animation: toastIn 0.3s ease both;
  display: flex; align-items: center; gap: 8px;
}
.toast.leaving { animation: toastOut 0.3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ===== Edit & Share Buttons on Card ===== */
.card-actions-left { display: flex; gap: 6px; align-items: center; }
.card-actions-right { display: flex; gap: 6px; align-items: center; }
.edit-btn, .share-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.85rem; padding: 4px 8px;
  border-radius: var(--radius-xs); transition: var(--transition);
}
.edit-btn:hover { color: #60a5fa; background: rgba(96,165,250,0.1); }
.share-btn:hover { color: #a78bfa; background: rgba(167,139,250,0.1); }

/* ===== Share Modal ===== */
.share-modal .modal { text-align: center; max-width: 440px; }
.share-url-box {
  display: flex; gap: 8px; margin-top: 16px;
}
.share-url-input {
  flex: 1; padding: 10px 14px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
  outline: none;
}
.share-url-input:focus { border-color: #8b5cf6; }
.btn-copy {
  padding: 10px 16px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: white; font-weight: 600; font-family: inherit; font-size: 0.8rem;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn-copy:hover { box-shadow: 0 4px 16px rgba(139,92,246,0.4); }
.btn-copy.copied { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* ===== Shared Timer View (fullscreen) ===== */
.shared-view {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px;
}
.shared-view .shared-name {
  font-size: 1.6rem; font-weight: 700; margin-bottom: 40px;
  display: flex; align-items: center; gap: 14px;
}
.shared-view .shared-name .color-dot { width: 16px; height: 16px; border-radius: 50%; }
.shared-view .focus-ring { width: 320px; height: 320px; }
.shared-view .shared-time {
  font-family: 'JetBrains Mono', monospace; font-size: 4rem; font-weight: 500;
  margin-bottom: 8px;
}
.shared-view .shared-label {
  color: var(--text-muted); font-size: 0.9rem; margin-bottom: 36px;
}
.shared-view .shared-controls { display: flex; gap: 14px; }
.shared-view .shared-badge {
  position: absolute; top: 24px; right: 24px;
  font-size: 0.75rem; padding: 6px 14px; border-radius: 20px;
  background: rgba(139,92,246,0.15); color: #a78bfa;
  font-weight: 600; letter-spacing: 0.5px;
}

@media (max-width: 768px) {
  .shared-view .focus-ring { width: 220px; height: 220px; }
  .shared-view .shared-time { font-size: 2.8rem; }
}
