:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #4f46e5;
  --secondary: #10b981;
  --border: #e5e7eb;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
  --radius: 12px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.logo {
  font-size: 28px;
}

.app-name {
  font-size: 20px;
  font-weight: 700;
}

.tagline {
  font-size: 13px;
  color: var(--muted);
}

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

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.workspace-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s ease;
}

.workspace-list li:hover {
  background: #f3f4f6;
}

.workspace-list li.active {
  background: #eef2ff;
  color: var(--primary);
  font-weight: 600;
}

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

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

.main {
  padding: 20px 24px 48px;
  overflow-y: auto;
}

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

.workspace-name {
  border: none;
  background: transparent;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
}

.workspace-name:focus {
  outline: 2px solid var(--primary);
}

.workspace-meta {
  color: var(--muted);
  font-size: 14px;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.sort-select:hover {
  border-color: var(--primary);
}

.sort-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.timers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.timer-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  border: 2px solid transparent;
  transition: transform 0.3s ease;
}

.timer-card.highlight {
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* Alarm notification card */
.alarm-layer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: center;
  justify-content: center;
  align-content: center;
  padding: 32px;
  pointer-events: none;
  z-index: 9991;
}

.alarm-card {
  position: relative;
  z-index: 9999;
  cursor: pointer;
  pointer-events: auto;
  padding: 40px 30px;
  border-radius: 20px;
  border: 3px solid;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  animation: alarm-pulse 0.6s infinite, pulsing 1.5s infinite;
  user-select: none;
  width: 380px;
  max-width: calc(100vw - 40px);
  min-height: 200px;
  justify-content: center;
  transition: transform 0.3s ease; /* Smooth transition for movement */
  flex: 1 1 320px;
  max-width: min(420px, calc(100vw - 72px));
  width: clamp(280px, 32vw, 380px);
}

.alarm-name {
  font-size: 32px;
  font-weight: 700;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  letter-spacing: 1px;
}

.alarm-duration {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.alarm-dismiss {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 10px;
  opacity: 0.8;
  animation: blink 1.5s infinite;
}

/* Alarm overlay backdrop */
.alarm-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9990;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.alarm-backdrop.fade-out {
  animation: fade-out 0.3s ease forwards;
}

@keyframes blink {
  0%, 49%, 100% {
    opacity: 0.8;
  }
  50%, 99% {
    opacity: 0.3;
  }
}

@keyframes pulsing {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.timer-card.highlight {
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.timer-name {
  font-size: 18px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
}

.timer-name:focus,
.timer-input:focus,
select:focus {
  outline: 2px solid var(--primary);
}

.timer-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.timer-input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 14px;
}

.color-input {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
}

.color-input:focus {
  outline: 2px solid var(--primary);
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.timer-display {
  font-size: 44px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 1px;
}

.progress {
  position: relative;
  height: 10px;
  background: #eef2ff;
  border-radius: 999px;
  overflow: hidden;
}

.progress .bar {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.2s linear;
}

.timer-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  font-size: 14px;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.25);
}

button.secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(16, 185, 129, 0.25);
}

button.ghost {
  background: #eef2ff;
  color: #4338ca;
}

button.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  display: none;
}

.toggle .slider {
  width: 46px;
  height: 26px;
  background: #e5e7eb;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle .slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .slider {
  background: var(--primary);
}

.toggle input:checked + .slider::after {
  transform: translateX(20px);
}

.alarm-container {
  width: 100%; /* Ensure the container takes full width */
  max-width: 1200px; /* Optional: limit the maximum width */
  margin: 0 auto; /* Center the container */
  display: flex;
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically */
  flex-wrap: wrap; /* Allow wrapping to prevent overlap */
  gap: 20px; /* Space between cards */
}

@media (max-width: 900px) {
  :root {
    font-size: 15px;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    order: 2;
  }
  .main {
    order: 1;
  }
  .workspace-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .workspace-buttons {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}
