/* Base variables as fallback; specific themes override below */
:root {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ghost: #e2e8f0;
  --ghost-hover: #cbd5e1;
}

/* Default gradient theme */
html[data-theme="gradient"] {
  --bg: #f8fafc;           /* soft off-white */
  --bg-soft: #f1f5f9;      /* misty grey */
  --card: #ffffff;         /* pure card surface */
  --text: #0f172a;         /* rich charcoal */
  --muted: #64748b;        /* calm slate */
  --primary: #3b82f6;      /* vibrant blue */
  --primary-hover: #2563eb;/* deeper blue */
  --ghost: #e2e8f0;        /* airy grey */
  --ghost-hover: #cbd5e1;  /* gentle hover */
}

/* Light theme (flat look) */
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ghost: #eef2f7;
  --ghost-hover: #e4e9f2;
}

/* Dark theme */
html[data-theme="dark"] {
  --bg: #0f172a;           /* midnight navy */
  --bg-soft: #1e293b;      /* subtle charcoal */
  --card: #1e293b;         /* sleek card */
  --text: #f1f5f9;         /* crisp white */
  --muted: #94a3b8;        /* muted silver */
  --ghost: #334155;        /* muted slate */
  --ghost-hover: #475569;  /* soft hover */
}

/* Ocean theme */
html[data-theme="ocean"] {
  --bg: #e0f2fe;           /* sky tint */
  --bg-soft: #bae6fd;      /* light ocean */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #0ea5e9;
  --primary: #06b6d4;      /* cyan */
  --primary-hover: #0891b2;/* deep cyan */
  --ghost: #e0f2fe;
  --ghost-hover: #bae6fd;
}

/* Sunset theme */
html[data-theme="sunset"] {
  --bg: #fff7ed;           /* peach */
  --bg-soft: #fde68a;      /* amber */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #ea580c;        /* warm orange */
  --primary: #f97316;      /* orange */
  --primary-hover: #ea580c;/* deeper orange */
  --ghost: #fff1e6;
  --ghost-hover: #ffe4c7;
}

/* Forest theme */
html[data-theme="forest"] {
  --bg: #dcfce7;           /* mint */
  --bg-soft: #a7f3d0;      /* light green */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #16a34a;        /* deep green */
  --primary: #22c55e;      /* green */
  --primary-hover: #16a34a;/* deeper green */
  --ghost: #e7ffe9;
  --ghost-hover: #d1fadf;
}

/* Rose theme */
html[data-theme="rose"] {
  --bg: #ffe4e6;           /* blush */
  --bg-soft: #fecdd3;      /* soft rose */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #e11d48;        /* rose */
  --primary: #f43f5e;      /* vibrant rose */
  --primary-hover: #e11d48;/* deep rose */
  --ghost: #fff1f2;
  --ghost-hover: #ffe4e6;
}

/* Slate theme (neutral) */
html[data-theme="slate"] {
  --bg: #f1f5f9;           /* light slate */
  --bg-soft: #e2e8f0;      /* soft slate */
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;        /* slate */
  --primary: #64748b;      /* neutral accent */
  --primary-hover: #475569;/* deeper slate */
  --ghost: #eceff4;
  --ghost-hover: #e1e6ee;
}

/* Header theme selector styling */
.theme-select {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--ghost-hover);
  background: var(--ghost);
  color: var(--text);
}

:root {
    /* Fresh, vibrant palette */
    --bg: #0b1020;           /* deep navy */
    --bg-soft: #10172a;      /* softer navy */
    --card: #ffffff;         /* cards on light theme */
    --text: #0e1a2b;         /* dark text on light surfaces */
    --muted: #64748b;        /* slate */
    --primary: #7c3aed;      /* purple */
    --primary-hover: #6d28d9;/* darker purple */
    --ghost: #f1f5f9;        /* light slate */
    --ghost-hover: #e2e8f0;  /* hover slate */
}

html[data-theme="dark"] {
    --bg: #0b1020;           /* deep navy */
    --bg-soft: #10172a;      /* softer navy */
    --card: #0b1220;         /* dark cards */
    --text: #e2e8f0;         /* light text */
    --muted: #94a3b8;        /* slate-muted */
    --ghost: #0f172a;        /* ghost dark */
    --ghost-hover: #1f2937;  /* ghost hover dark */
}

.header-actions {
    margin-top: 0.5rem;
}

/* Utility: visually hidden (for sr-only labels) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Adjust body gradient to respect theme */
body {
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
}

.header {
    width: 100%;
    max-width: 1100px;
    padding: 2rem 1rem 0.5rem 1rem;
    margin: 0 auto;
    color: #fff;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.75rem 1rem; /* row/column gap for wrap */
}
/* Arrange brand, tagline, and actions for better UX */
.brand { order: 0; }
.tagline { order: 0; text-align: center; margin: 0.5rem auto; }
.header-actions { order: 0; margin: 0.5rem auto; }

@media (min-width: 768px) {
  .header {
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .header-actions { 
    margin: 0 auto; 
    order: 0; 
    justify-content: center;
    align-items: center;
  }
}
/* Prevent overflow of actions on small screens */
.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Improve status pill semantics and visibility */
.status {
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    background-color: var(--ghost);
    color: var(--text);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 2.25rem; /* more prominent */
    font-weight: 800;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-text {
    letter-spacing: 0.15px; /* slightly tighter for script fonts */
    color: var(--text); /* adapt to theme for proper contrast */
    text-shadow: none;
    font-family: cursive; /* handwriting-style via generic cursive fallback */
}

html[data-theme="dark"] .brand-text {
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

@media (max-width: 640px) {
  .brand {
    font-size: 1.8rem;
  }
  .brand-logo {
    width: 36px;
    height: 36px;
  }
}
.tagline {
    flex: 1 1 100%; /* occupy a full row under the brand for perfect placement */
    font-size: 1.05rem;
    line-height: 1.5;
    letter-spacing: 0.2px;
    color: var(--muted); /* theme-aware secondary text for better visibility */
    margin-top: 0.25rem;
    text-shadow: none;
}

html[data-theme="dark"] .tagline {
    color: var(--muted);
    text-shadow: 0 1px 1.5px rgba(0,0,0,0.25); /* subtle lift on dark background */
}

.container {
    background-color: var(--card);
    padding: 1.5rem;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 1100px;
    margin: 1rem auto;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: stretch; /* ensure panels have equal height for similar dimensions */
    justify-items: stretch;
}

.grid > .panel {
    height: 100%;
}

.panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    display: flex;              /* ensure inner elements are placed correctly */
    flex-direction: column;     /* stack content in order */
    gap: 0.75rem;               /* balanced spacing between children */
}

.panel > * {                    /* normalize child spacing */
    margin: 0;
}

/* keep header layout consistent within the panel */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.label {
    display: block;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

/* Ensure consistent sizing and prevent overflow misalignment */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Prevent panels and form controls from exceeding their containers */
.panel, textarea, select {
    max-width: 100%;
}

/* Ensure textarea aligns properly within its panel */
textarea {
    display: block;
}

/* Hide any accidental overflow from internal content */
.panel {
    overflow: hidden;
}

textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px; /* restore rounded corners */
    margin-bottom: 1rem;
    font-size: 1rem;
    resize: vertical;
}

.controls {
    display: block;
}

.controls .control { /* full-width block and natural spacing */
    width: 100%;
    margin-bottom: 1rem;
}
.control select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    font-size: 1rem;
    background-color: #fff;
}

.toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
}

.hint {
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

button.primary {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    background-color: var(--primary);
    color: #fff;
    cursor: pointer;
}

button.primary:hover {
    background-color: var(--primary-hover);
}

button.primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

button.ghost {
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    font-size: 1rem;
    background-color: var(--ghost);
    color: var(--text);
    cursor: pointer;
}

button.ghost:hover {
    background-color: var(--ghost-hover);
}

.output {
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: 10px;
    min-height: 120px;
    border: 1px solid #e5e7eb;
}

.result-list {
    margin: 0;
    padding-left: 1.25rem;
}

.footer {
    width: 100%;
    max-width: 1100px;
    text-align: right;
    color: #cbd5e1;
    padding: 0.5rem 1rem 1.5rem 1rem;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
    .actions {
        flex-wrap: wrap;
    }
}

/* Table styles for batch alignment */
.result-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.result-table th, .result-table td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0.6rem;
    vertical-align: top;
}
.result-table th {
    background: #f3f4f6;
    text-align: left;
}
.result-table tr:nth-child(even) td {
    background: #fafafa;
}

/* Smooth theme transitions */
html, body, .container, .panel, textarea, select, button, .output {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Elevated panel hover for subtle depth */
.panel:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Improved focus visibility and accessibility */
textarea:focus-visible, select:focus-visible, button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Harmonize output surface with theme variables */
.output {
    background-color: var(--ghost);
    color: var(--text);
}

/* Button hover and active subtle animations */
button.primary:hover, button.ghost:hover {
    transform: translateY(-1px);
}
button.primary:active, button.ghost:active {
    transform: translateY(0);
}

