/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* DARK THEME (Default) */
  --bg-color: #080c16;
  --bg-gradient: linear-gradient(135deg, #080c16 0%, #101626 100%);
  --card-bg: #111827;
  --card-bg-hover: #162035;
  --card-border: #1f293d;
  --card-border-glow: rgba(0, 229, 255, 0.25);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Neon Accents */
  --accent-cyan: #00e5ff;
  --accent-cyan-rgb: 0, 229, 255;
  --accent-purple: #a855f7;
  --accent-purple-rgb: 168, 85, 247;
  
  /* Cooldown states */
  --color-cooldown: #f43f5e; /* Coral-red for drop interval CD */
  --color-cooldown-rgb: 244, 63, 94;
  --color-window: #eab308; /* Amber-yellow for drop window reduced prob */
  --color-window-rgb: 234, 179, 8;
  --color-ready: #10b981; /* Emerald-green for ready */
  --color-ready-rgb: 16, 185, 129;
  
  --btn-primary-bg: linear-gradient(135deg, var(--accent-cyan) 0%, #0284c7 100%);
  --btn-primary-text: #040815;
  --btn-secondary-bg: #1e293b;
  --btn-secondary-border: #1f293d;
  --btn-secondary-text: #f8fafc;
  --btn-secondary-hover: #334155;
  
  --modal-overlay-bg: rgba(4, 7, 15, 0.85);
  --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 229, 255, 0.04);
  
  --font-sans: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Share Tech Mono', 'Courier Prime', monospace;
  
  --transition-speed: 0.2s;
}

body.light-theme {
  /* LIGHT THEME */
  --bg-color: #f1f5f9;
  --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  --card-bg: #ffffff;
  --card-bg-hover: #f8fafc;
  --card-border: #cbd5e1;
  --card-border-glow: rgba(2, 132, 199, 0.2);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-cyan: #0284c7; /* Royal blue for accessibility */
  --accent-cyan-rgb: 2, 132, 199;
  --accent-purple: #7c3aed;
  --accent-purple-rgb: 124, 58, 237;
  
  --color-cooldown: #e11d48; /* Darker red */
  --color-cooldown-rgb: 225, 29, 72;
  --color-window: #d97706; /* Dark amber */
  --color-window-rgb: 217, 119, 6;
  --color-ready: #059669; /* Forest green */
  --color-ready-rgb: 5, 150, 105;
  
  --btn-primary-bg: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #e2e8f0;
  --btn-secondary-border: #cbd5e1;
  --btn-secondary-text: #0f172a;
  --btn-secondary-hover: #cbd5e1;
  
  --modal-overlay-bg: rgba(15, 23, 42, 0.5);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  overflow-y: auto;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Screen Flash Alert Overlay */
.screen-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(var(--color-ready-rgb), 0.15);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
}

@keyframes flash-animation {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

.flash-active {
  animation: flash-animation 0.8s ease-out;
}

/* App Wrapper */
.app-wrapper {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* PiP Placeholder */
.pip-placeholder {
  background: var(--card-bg);
  border: 2px dashed var(--card-border);
  border-radius: 20px;
  padding: 40px 20px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
}

.pip-placeholder.hidden {
  display: none;
}

.pip-placeholder-content .pip-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  animation: float 3s ease-in-out infinite;
}

.pip-placeholder-content h2 {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent-cyan);
}

.pip-placeholder-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Modal Popup Onboarding */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--modal-overlay-bg);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-enter {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.modal-card h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-buttons .btn {
  flex: 1;
  font-size: 0.95rem;
  padding: 10px 16px;
}

/* Main Timer App Container */
.timer-app-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.logo-icon {
  font-size: 1.35rem;
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Base Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-speed) ease;
  user-select: none;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-cyan-rgb), 0.3);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--btn-secondary-text);
}

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

.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid var(--color-cooldown);
  color: var(--color-cooldown);
}

.btn-danger:hover {
  background: var(--color-cooldown);
  color: white;
  box-shadow: 0 0 10px rgba(var(--color-cooldown-rgb), 0.3);
}

.btn-icon-text {
  background: rgba(var(--accent-cyan-rgb), 0.08);
  border: 1px solid rgba(var(--accent-cyan-rgb), 0.2);
  color: var(--accent-cyan);
}

.btn-icon-text:hover {
  background: rgba(var(--accent-cyan-rgb), 0.15);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(var(--accent-cyan-rgb), 0.2);
}

.btn-icon-only {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.btn-icon:hover {
  background: var(--btn-secondary-hover);
}

.btn-edit {
  min-width: 70px;
}

.btn-edit.active {
  background: var(--color-cooldown);
  border-color: var(--color-cooldown);
  color: white;
  animation: pulse-pink 2s infinite;
}

@keyframes pulse-pink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--color-cooldown-rgb), 0.4); }
  50% { box-shadow: 0 0 10px 4px rgba(var(--color-cooldown-rgb), 0.2); }
}

/* Instructions Card */
.instructions-card {
  background: rgba(30, 41, 59, 0.15);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.85rem;
}

.instructions-card summary {
  font-weight: 600;
  color: var(--accent-cyan);
  cursor: pointer;
  user-select: none;
  outline: none;
}

.instructions-card summary:hover {
  color: var(--text-primary);
}

.instructions-content {
  margin-top: 8px;
  padding-left: 12px;
  color: var(--text-secondary);
}

.instructions-content ul {
  list-style-type: disc;
}

.instructions-content li {
  margin-bottom: 6px;
  line-height: 1.4;
}

/* Config Panel */
.config-panel {
  background: rgba(30, 41, 59, 0.1);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flex-grow {
  flex-grow: 1;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* Select Wrapper Custom styling */
.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper::after {
  content: "▼";
  font-size: 0.65rem;
  color: var(--text-secondary);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

select {
  width: 100%;
  padding: 8px 30px 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background-color: var(--card-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-speed) ease;
}

select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 5px rgba(var(--accent-cyan-rgb), 0.2);
}

.course-actions {
  display: flex;
  gap: 4px;
  align-self: flex-end;
}

/* Dual Interval Inputs */
.double-interval-row {
  margin-top: 10px;
}

.dual-interval-inputs {
  display: flex;
  align-items: center;
  background: var(--card-bg-hover);
  border: 1px dashed var(--card-border);
  padding: 10px 14px;
  border-radius: 12px;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.interval-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.input-number {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: bold;
  padding: 4px 6px;
  border-radius: 6px;
  width: 50px;
  text-align: center;
  outline: none;
}

.input-number:focus {
  border-color: var(--accent-cyan);
}

.total-badge {
  display: flex;
  align-items: center;
  background: rgba(var(--color-ready-rgb), 0.08);
  border: 1px solid rgba(var(--color-ready-rgb), 0.2);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--color-ready);
  font-weight: 700;
  gap: 4px;
}

.highlight-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
}

/* Timer Stages Layout */
.timer-section {
  margin-bottom: 24px;
}

.timers-list, .edit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s ease;
}

/* Stage Row (Timer card) */
.stage-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.15);
  border: 1px solid var(--card-border);
  overflow: hidden;
  transition: all 0.2s ease, background 0.3s ease, border-color 0.3s ease;
  user-select: none;
}

.stage-row:hover {
  background: rgba(30, 41, 59, 0.25);
  border-color: var(--card-border-glow);
  transform: translateX(1px);
}

/* Dynamic Progress Bar Background (Two Phases supported) */
.stage-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1s linear, background-color 0.5s ease;
  pointer-events: none;
  z-index: 1;
}

/* Phase Colors */
.stage-row.phase-cooldown .stage-progress {
  background-color: rgba(var(--color-cooldown-rgb), 0.06);
}

.stage-row.phase-window .stage-progress {
  background-color: rgba(var(--color-window-rgb), 0.06);
}

/* Left Active Shortcut Focus Indicator */
.stage-row.active-focus {
  border-left: 4px solid var(--accent-cyan);
  box-shadow: 0 0 12px rgba(var(--accent-cyan-rgb), 0.05);
}

.stage-row.active-focus::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-dot 1.5s infinite;
}

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

.stage-left-info {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.shortcut-indicator {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--card-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.stage-row.active-focus .shortcut-indicator {
  color: var(--accent-cyan);
  border-color: rgba(var(--accent-cyan-rgb), 0.3);
}

.stage-btn-trigger {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: bold;
  padding: 8px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
  transition: all 0.2s ease;
  min-width: 75px;
  text-align: center;
}

.stage-btn-trigger:hover {
  transform: scale(1.03);
}

/* Ready state difficulty colors (outline glow, transparent/dark background) */
.stage-btn-trigger.diff-normal {
  background: rgba(59, 130, 246, 0.08);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15);
}
.stage-btn-trigger.diff-normal:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: #60a5fa;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.stage-btn-trigger.diff-nightmare {
  background: rgba(168, 85, 247, 0.08);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 2px 6px rgba(168, 85, 247, 0.15);
}
.stage-btn-trigger.diff-nightmare:hover {
  background: rgba(168, 85, 247, 0.18);
  border-color: #c084fc;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.stage-btn-trigger.diff-hell {
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
}
.stage-btn-trigger.diff-hell:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: #f87171;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.stage-btn-trigger.diff-torment {
  background: rgba(245, 158, 11, 0.08);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}
.stage-btn-trigger.diff-torment:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: #fbbf24;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Light Theme overrides for readability */
body.light-theme .stage-btn-trigger.diff-normal {
  background: rgba(37, 99, 235, 0.05);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.3);
}
body.light-theme .stage-btn-trigger.diff-normal:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: #1d4ed8;
}

body.light-theme .stage-btn-trigger.diff-nightmare {
  background: rgba(124, 58, 237, 0.05);
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.3);
}
body.light-theme .stage-btn-trigger.diff-nightmare:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: #7c3aed;
}

body.light-theme .stage-btn-trigger.diff-hell {
  background: rgba(220, 38, 38, 0.05);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.3);
}
body.light-theme .stage-btn-trigger.diff-hell:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: #dc2626;
}

body.light-theme .stage-btn-trigger.diff-torment {
  background: rgba(217, 119, 6, 0.05);
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.3);
}
body.light-theme .stage-btn-trigger.diff-torment:hover {
  background: rgba(217, 119, 6, 0.1);
  border-color: #d97706;
}

/* Phase state changes on stage buttons (Must override difficulty styles) */
.stage-row.phase-cooldown .stage-btn-trigger {
  background: #334155 !important;
  color: var(--text-secondary) !important;
  border: none !important;
  box-shadow: none !important;
}

.stage-row.phase-window .stage-btn-trigger {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
  color: var(--color-window) !important;
  border: 1px solid var(--color-window) !important;
  box-shadow: 0 0 6px rgba(var(--color-window-rgb), 0.15) !important;
}

/* Stage Right display */
.stage-right {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.timer-wrapper-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  min-width: 70px;
  text-align: right;
  transition: all 0.2s ease;
}

/* Phase states on display */
.timer-display.phase-cd {
  color: var(--color-cooldown);
}

.timer-display.phase-win {
  color: var(--color-window);
}

.timer-display.ready {
  color: var(--color-ready);
  text-shadow: 0 0 10px rgba(var(--color-ready-rgb), 0.5);
  animation: blink 1.2s infinite;
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.15rem;
}

.timer-phase-status {
  font-size: 0.65rem;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

.timer-phase-status.phase-cd {
  background: rgba(var(--color-cooldown-rgb), 0.1);
  color: var(--color-cooldown);
}

.timer-phase-status.phase-win {
  background: rgba(var(--color-window-rgb), 0.1);
  color: var(--color-window);
}

.timer-phase-status.ready {
  background: rgba(var(--color-ready-rgb), 0.1);
  color: var(--color-ready);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-reset {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-reset:hover {
  background: var(--btn-secondary-hover);
  color: var(--text-primary);
}

/* GRID LAYOUT FOR CARDS (WOW element) */
.timers-list.layout-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.timers-list.layout-grid .stage-row {
  flex-direction: column;
  padding: 14px 10px;
  gap: 8px;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 155px;
  height: auto;
}

.timers-list.layout-grid .stage-row.active-focus {
  border-left: 1px solid var(--card-border);
  border-top: 4px solid var(--accent-cyan);
}

.timers-list.layout-grid .stage-row.active-focus::before {
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
}

.timers-list.layout-grid .stage-left-info {
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.timers-list.layout-grid .stage-right {
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.timers-list.layout-grid .timer-wrapper-block {
  align-items: center;
}

.timers-list.layout-grid .timer-display {
  text-align: center;
  min-width: 0;
  font-size: 1.25rem;
}

.timers-list.layout-grid .btn-reset {
  width: 100%;
  max-width: 70px;
  text-align: center;
}

/* Edit Mode Layout */
.edit-list-header h3 {
  font-size: 1.05rem;
  color: var(--text-primary);
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--card-border);
  margin-bottom: 10px;
}

.edit-stages-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.edit-row {
  display: flex;
  flex-direction: column;
  background: rgba(30, 41, 59, 0.15);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 8px;
  transition: background 0.3s;
}

.edit-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.edit-row .drag-handle {
  color: var(--text-muted);
  user-select: none;
  cursor: grab;
  font-size: 0.95rem;
}

.input-stage-name {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  width: 90px;
  outline: none;
}

.input-stage-name:focus {
  border-color: var(--accent-cyan);
}

.clear-time-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.clear-time-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  user-select: none;
}

.input-clear-time {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 6px 4px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 50px;
  text-align: center;
  outline: none;
  transition: border-color var(--transition-speed);
}

.input-clear-time:focus {
  border-color: var(--accent-cyan);
}

.stage-clear-time-display {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(30, 41, 59, 0.25);
  border: 1px dashed var(--card-border);
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  user-select: none;
  transition: background 0.3s, border-color 0.3s;
}

body.light-theme .stage-clear-time-display {
  background: rgba(15, 23, 42, 0.05);
  border-color: var(--card-border);
}

/* Clearing Phase Styles (Auto rotation countdown) */
.stage-row.phase-clearing .stage-progress {
  background-color: rgba(6, 182, 212, 0.08);
  animation: pulse-cyan-bg 2s infinite;
}

.stage-row.phase-clearing .stage-btn-trigger {
  background: rgba(6, 182, 212, 0.1) !important;
  color: #22d3ee !important;
  border: 1px dashed #22d3ee !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.3) !important;
}

.timer-display.phase-clearing {
  color: #22d3ee;
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.timer-phase-status.phase-clearing {
  background: rgba(6, 182, 212, 0.1);
  color: #22d3ee;
}

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

.custom-time-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: 8px;
}

.edit-row-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

/* Custom Time Nested Inputs */
.custom-time-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 23, 42, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  margin-left: 18px;
  width: calc(100% - 18px);
}

.custom-time-inputs.disabled {
  display: none;
}

.time-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.time-field-row span {
  min-width: 50px;
}

.input-stage-time {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--accent-cyan);
  padding: 4px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 44px;
  text-align: center;
  outline: none;
}

.btn-row-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.btn-row-action:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
  color: var(--text-primary);
}

.btn-row-action:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-row-delete {
  color: var(--color-cooldown);
}

.btn-row-delete:hover {
  background: rgba(244, 63, 94, 0.1) !important;
}

.edit-actions {
  margin-top: 10px;
}

.btn-dashed-add {
  width: 100%;
  border: 1px dashed var(--card-border-glow);
  background: rgba(var(--accent-cyan-rgb), 0.03);
  color: var(--accent-cyan);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-dashed-add:hover {
  background: rgba(var(--accent-cyan-rgb), 0.08);
  border-color: var(--accent-cyan);
}

/* Footer & Settings Group */
.app-footer {
  border-top: 1px solid var(--card-border);
  padding-top: 20px;
  transition: border-top-color 0.3s;
}

.settings-group {
  background: rgba(30, 41, 59, 0.1);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  transition: border-color 0.3s;
}

.settings-header h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  font-weight: 700;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.setting-item:last-of-type {
  margin-bottom: 16px;
}

.setting-label {
  font-weight: 500;
}

/* Custom Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--btn-secondary-bg);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--card-border);
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: rgba(var(--color-ready-rgb), 0.15);
  border-color: var(--color-ready);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--color-ready);
  box-shadow: 0 0 5px var(--color-ready);
}

/* Custom Volume Slider */
.volume-control {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.volume-slider-container {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
}

.input-range {
  flex-grow: 1;
  height: 6px;
  background: var(--btn-secondary-bg);
  border-radius: 3px;
  outline: none;
  appearance: none;
  cursor: pointer;
}

.input-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  cursor: pointer;
  transition: transform 0.1s;
}

.input-range::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.vol-icon {
  font-size: 0.9rem;
  user-select: none;
}

.volume-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  min-width: 38px;
  text-align: right;
}

.footer-buttons {
  display: flex;
  gap: 8px;
}

.footer-buttons .btn {
  flex: 1;
}

.attribution {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.attribution a {
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.attribution a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.hidden {
  display: none !important;
}

/* Responsive Overrides (For Tiny PiP Windows / Small screens) */
@media (max-width: 440px) {
  body {
    padding: 0;
  }
  .timer-app-container {
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 12px;
  }
  .instructions-card {
    display: none; /* Hide instructions in small screens / PiP to save space */
  }
  .app-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
  }
  .app-header h1 {
    font-size: 1.1rem;
  }
  .logo-icon {
    font-size: 1.1rem;
  }
  .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  .stage-row {
    padding: 8px 12px;
  }
  .timer-display {
    font-size: 1.15rem;
    min-width: 60px;
  }
  .timer-display.ready {
    font-size: 1.05rem;
  }
  .stage-btn-trigger {
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 65px;
  }
  .config-panel {
    padding: 10px;
    margin-bottom: 12px;
  }
  .form-row {
    margin-bottom: 8px;
  }
  .dual-interval-inputs {
    padding: 6px 10px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .total-badge {
    align-self: flex-end;
  }
  .timers-list.layout-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .timers-list.layout-grid .stage-row {
    min-height: 145px;
    padding: 10px 6px;
  }
}
