:root {
  /* Premium Palette - Deep Slate & Vibrant Accents */
  --bg-dark: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  
  /* Glass Cards - cleaner, more premium */
  --card-bg: rgba(30, 41, 59, 0.7); /* Slate-800 with opacity */
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(255, 255, 255, 0.15);
  --card-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
  --card-blur: 20px;
  
  /* Brand Colors */
  --primary: #6366f1; /* Indigo-500 */
  --primary-hover: #4f46e5; /* Indigo-600 */
  --accent: #ec4899; /* Pink-500 */
  --success: #10b981;
  
  /* Typography */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  /* Text */
  --text-main: #f8fafc; /* Slate-50 */
  --text-secondary: #94a3b8; /* Slate-400 */
  --text-muted: #64748b; /* Slate-500 */
  
  /* Input Elements */
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-focus-border: var(--primary);
  
  /* Spacing & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px; 
  --radius-xl: 12px; /* Sharper looks */
  
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-dark); /* Fallback */
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 40%),
    var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh; /* Allow growth */
  overflow-y: auto; /* Enable vertical scroll */
  line-height: 1.6;
  padding: 0;
  margin: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.container {
  width: 100%;
  max-width: 1600px; /* Constrained width for large screens */
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
}

/* Header */
.header {
  text-align: center;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
  flex-shrink: 0;
}

.title {
  font-family: var(--font-heading);
  font-size: 3.5rem; /* Larger, more impactful */
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  text-shadow: 0 0 30px rgba(255,255,255,0.1);
}

.subtitle {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.9;
}

/* Main Layout - Split View */
.main-layout {
  display: flex;
  flex-direction: column;
  flex: 1; /* Take remaining height */
  min-height: 0; /* Critical for nested scroll */
  gap: var(--space-lg);
}

@media (min-width: 1024px) {
  .main-layout {
    flex-direction: row !important; /* Force horizontal layout */
    align-items: flex-start;
    justify-content: center;
    gap: 48px; /* Standardize gap */
    padding-bottom: 32px;
    width: 100%;
    max-width: 1400px; /* Constrain max width for readability */
    margin: 0 auto;
  }

  .config-panel {
    width: 480px;
    flex-shrink: 0;
    height: auto; /* Grow with content */
    overflow: visible; /* Use global scroll */
    padding-right: 0;
    
    border-right: none;
    background: transparent;
  }

  .preview-panel {
    flex: 1; /* Take remaining width */
    max-width: 700px; /* Don't get too wide */
    
    /* Sticky magic */
    position: sticky;
    top: 20px; /* Gap from top of viewport */
    height: auto; /* Fit content */
    max-height: 95vh; /* Prevent overflowing viewport if possible */
    
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align top */
    overflow: visible; 
  }
}

/* Mobile Adjustments */
@media (max-width: 1023px) {
  body {
      height: auto;
      overflow: auto; /* Scroll normally on mobile */
  }
  .container {
      height: auto;
      display: block;
      padding: var(--space-md);
  }
  .main-layout {
      overflow: visible;
  }
  .config-panel {
      width: 100%;
      height: auto;
      overflow: visible;
  }
  .preview-panel {
      height: auto;
      margin-top: var(--space-xl);
  }
}

/* Cards */
.card-glass {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-glass:hover {
  border-color: var(--card-border-hover);
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

/* Typography in Panels */
.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.group-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.05);
}

/* Form Controls */
.settings-group {
    margin-bottom: var(--space-xl);
}

.control-item {
  margin-bottom: var(--space-md);
}

/* Fix for Select Arrow padding */
select.input-glass {
  padding-right: 32px; /* Ensure space for arrow */
}

.control-item label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

/* Inputs */
.input-glass {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
}

.input-glass:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}

.input-glass:focus {
  background: rgba(15, 23, 42, 0.9);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Custom Select Arrow */
select.input-glass {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  padding-right: 48px;
  cursor: pointer;
}

/* Colors Row */
.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.color-row:last-child {
    border-bottom: none;
}
.color-row label {
    margin: 0;
    font-size: 0.95rem;
}

.color-swatch-wrapper {
    position: relative;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--primary);
}

/* Color Picker Popover */
.picker-popover {
    position: fixed;
    z-index: 1000;
    background: var(--card-bg);
    backdrop-filter: blur(var(--card-blur));
    -webkit-backdrop-filter: blur(var(--card-blur));
    border: 1px solid var(--card-border);
    padding: 15px;
    border-radius: var(--radius-xl);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 15px;
    animation: popIn 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.picker-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.hex-input {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: white;
    font-family: monospace;
    font-size: 14px;
    text-align: center;
    text-transform: uppercase;
}

.btn-done {
    background: var(--primary);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-done:hover {
    background: var(--primary-hover);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #4338ca);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 18px;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 8px 20px -5px rgba(79, 70, 229, 0.4);
  position: relative;
  overflow: hidden;
}

.btn-primary:after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.btn-primary:hover:after {
    opacity: 1;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px -8px rgba(79, 70, 229, 0.5);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-add {
    margin-top: 12px;
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.2);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-add:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-remove {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.btn-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}

/* Grid Utilities */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* Important Dates Row */
.date-row {
    display: flex;
    gap: 8px;
    background: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: var(--radius-md);
    align-items: center;
}

/* Compact inputs for Date Row */
.date-row .input-glass {
    padding: 8px 8px !important; /* Reduce padding for compact row */
    height: 36px; /* Fixed height match remove button */
    font-size: 0.9rem;
    background-position: right 4px center !important; /* Adjust arrow position */
}

/* Preview Section */
.preview-wrapper {
    /* Removed old wrapper styles to let it float */
    position: relative;
    padding: 20px;
}

/* Phone Frame - The Hero */
.phone-frame {
    position: relative;
    width: 320px; /* Slightly wider for modern feel */
    height: 650px;
    background: #0f172a; /* Dark blue-black frame */
    border-radius: 55px; /* Modern Squircle Approx */
    box-shadow: 
        0 0 0 4px #1e293b, /* Matte outer rim */
        0 0 0 5px #000,    /* Gloss black edge */
        inset 0 0 20px rgba(0,0,0,0.8), /* Inner depth */
        0 50px 100px -20px rgba(0,0,0,0.7); /* Deep drop shadow */
    padding: 8px;
    box-sizing: border-box;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 2px solid #334155; /* Metallic subtle frame */
    margin: 0 auto;
    
    /* Responsive Scale for smaller height screens */
    transform-origin: center center;
}

/* Scale down on short screens */
@media (max-height: 850px) and (min-width: 1024px) {
    .phone-frame {
        transform: scale(0.9);
    }
}
@media (max-height: 750px) and (min-width: 1024px) {
    .phone-frame {
        transform: scale(0.8);
    }
}

.phone-screen {
    width: 100%;
    height: 100%;
    background: var(--phone-bg, #000000);
    border-radius: 48px; /* Matching Inner Radius */
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Dynamic Island */
.frame-island::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    border-radius: 20px;
    background: #000;
    z-index: 20;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1); /* Subtle outline */
}

/* Notch */
.frame-notch::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 160px;
    height: 32px;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
    background: #000;
    z-index: 20;
}

/* Button Hints */
.phone-frame::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 180px;
    width: 6px;
    height: 80px;
    background: #334155;
    border-radius: 4px;
    box-shadow: -2px 0 4px rgba(0,0,0,0.2);
}

/* Copy Feedback */
#copy-feedback {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    margin-top: 16px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .title { font-size: 2.5rem; }
    .card-glass { padding: var(--space-md); }
    .phone-frame { width: 300px; height: 620px; border-radius: 48px; }
    .phone-screen { border-radius: 38px; }
}

/* Calendar Preview Content Overrides */
/* Ensure the injected preview respects the clean loop */
#calendar-preview {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui !important; /* Keep iOS system look for preview */
}
