:root {
  /* Light Theme Palette */
  --light-bg: #FFFFFF; /* Pure White */
  --light-content-bg: #F8FAFC; /* Very Light Gray */
  --light-primary: #3B82F6; /* Bright Blue */
  --light-primary-dark: #2563EB; /* Darker Blue */
  --light-secondary: #8B5CF6; /* Purple */
  --light-text: #1E293B; /* Dark Slate */
  --light-text-soft: #64748B; /* Medium Slate */
  --light-text-muted: #94A3B8; /* Light Slate */
  --light-border: #E2E8F0; /* Light Border */
  --light-success: #10B981; /* Emerald */
  --light-warning: #F59E0B; /* Amber */
  --light-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --light-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --light-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  /* Dark Theme Palette */
  --dark-bg: #0A0A0A; /* Near Black */
  --dark-content-bg: #1A1A1A; /* Dark Gray */
  --dark-primary: #6366F1; /* Brighter Indigo for contrast */
  --dark-primary-dark: #4F46E5; /* Original Indigo */
  --dark-secondary: #8B5CF6; /* Brighter Purple */
  --dark-text: #F5F5F5; /* Off-white */
  --dark-text-soft: #A3A3A3; /* Medium Gray */
  --dark-text-muted: #525252; /* Darker Gray */
  --dark-border: #262626; /* Subtle border */
  --dark-success: #22C55E; /* Brighter Green */
  --dark-warning: #F59E0B; /* Same Orange */
  --dark-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
  --dark-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.2), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --dark-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

  /* Default to dark theme */
  --bg: var(--dark-bg);
  --content-bg: var(--dark-content-bg);
  --primary: var(--dark-primary);
  --primary-dark: var(--dark-primary-dark);
  --secondary: var(--dark-secondary);
  --text: var(--dark-text);
  --text-soft: var(--dark-text-soft);
  --text-muted: var(--dark-text-muted);
  --border: var(--dark-border);
  --success: var(--dark-success);
  --warning: var(--dark-warning);
  --shadow-sm: var(--dark-shadow-sm);
  --shadow: var(--dark-shadow);
  --shadow-lg: var(--dark-shadow-lg);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease-in-out;
}

/* Light theme */
html[data-theme="light"] {
  --bg: var(--light-bg);
  --content-bg: var(--light-content-bg);
  --primary: var(--light-primary);
  --primary-dark: var(--light-primary-dark);
  --secondary: var(--light-secondary);
  --text: var(--light-text);
  --text-soft: var(--light-text-soft);
  --text-muted: var(--light-text-muted);
  --border: var(--light-border);
  --success: var(--light-success);
  --warning: var(--light-warning);
  --shadow-sm: var(--light-shadow-sm);
  --shadow: var(--light-shadow);
  --shadow-lg: var(--light-shadow-lg);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

header {
  background: var(--content-bg);
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: var(--transition);
}

.logo:hover {
  color: var(--primary);
}

.nav-links {
    display: flex !important;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-links > li > a {
  text-decoration: none;
  color: var(--text); /* Changed from var(--text-soft) to var(--text) for better contrast */
  font-weight: 500;
  padding: 0.35em 0.85em;
  border-radius: 4px;
  transition: var(--transition);
}

.nav-links > li > a:hover {
  color: var(--primary);
  background: var(--border); /* Use theme variable for hover background */
}

/* Dropdown Menu Styles (Moved from HTML files) */
.nav-dropdown {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.dropdown-menu {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 172px;
    background: var(--content-bg); /* Use theme variable */
    border: 1px solid var(--border); /* Use theme variable */
    box-shadow: var(--shadow); /* Use theme variable */
    border-radius: var(--radius);
    z-index: 9999;
    padding: 0.5em 0;
    margin-top: 2px;
}

.nav-dropdown:hover > .dropdown-menu,
.nav-dropdown:focus-within > .dropdown-menu {
    display: block !important;
}

.dropdown-menu.show {
    display: block !important;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--content-bg);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-width: 40px;
  user-select: none;
}

.theme-toggle:hover {
  background: var(--border);
  color: var(--text);
}

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

.dropdown-menu li {
  list-style: none;
}

.dropdown-menu a {
  display: block;
  padding: 0.53em 1.24em;
  color: var(--text-soft); /* Use theme variable */
  text-decoration: none;
  font-size: 1em;
  border-radius: 4px;
  white-space: nowrap;
}

/* This is the fix for the missing toggle icon */
.theme-toggle::before {
  content: '☀';
  font-size: 1.2rem;
  font-weight: bold;
}

html[data-theme="light"] .theme-toggle::before {
  content: '☽';
  font-size: 1.2rem;
  font-weight: bold;
}

.dropdown-menu a:hover {
  background: var(--border); /* Use theme variable */
  color: var(--primary);
}

main {
  padding: 4rem 0;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1rem 0;
  color: var(--text);
}

h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  margin-bottom: 1.5rem;
  text-align: center;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  text-align: center;
  margin-bottom: 3rem;
}

.subtitle {
  text-align: center;
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  margin-bottom: 2.5rem;
  color: var(--text-soft);
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
}

.tool-section {
  background: var(--content-bg);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: none; /* Remove shadow, use border */
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  box-sizing: border-box;
  min-height: 0;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-soft) !important; /* Softer label color */
}

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg); /* Darker background for inputs */
  color: var(--text) !important;
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); /* Adjusted focus ring for dark theme */
}

textarea {
  min-height: 150px;
  resize: vertical;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

/* General button styling */
button {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

button:hover {
  background-color: var(--border);
  border-color: var(--border);
}

/* Keep CTA button colored for emphasis on homepage */
.cta-button {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.cta-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.copy-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  z-index: 10;
}

.copy-btn:hover {
  background: var(--border);
  color: var(--text);
}

.output-section {
  margin-top: 2rem;
  position: relative;
}

.output-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
  color: var(--text-soft) !important;
}

.output-area {
  background: var(--bg);
  min-height: 150px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  color: var(--text) !important;
}

.hero {
  padding: 4rem 0;
  text-align: center;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 4rem;
}

.tool-card {
  background: var(--content-bg);
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: left;
  transition: var(--transition);
  border: 1px solid var(--border);
  box-shadow: none; /* Remove shadow */
}

.tool-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2); /* Add a subtle shadow on hover */
}

.tool-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
  color: var(--primary);
}

.tool-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.tool-card h3 a {
  text-decoration: none;
  color: var(--text) !important;
}

.tool-card h3 a:hover {
  color: var(--primary) !important;
}

.tool-card p {
  color: var(--text-soft) !important;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.inline-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.inline-row > div {
  flex-grow: 1;
}

.inline-row > div:first-child {
  flex-grow: 0;
  flex-basis: 150px;
}

footer {
  background: var(--content-bg);
  color: var(--text-soft);
  padding: 4rem 0 2rem;
  text-align: left;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.footer-section h4 {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: 1.1rem;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-soft);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* JSON Validator specific styles */
.validator-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  align-items: start;
  height: 100%;
  box-sizing: border-box;
}

.panel {
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 0;
}

.panel-header {
  padding: 1rem 1.5rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.panel-content {
  padding: 1.5rem;
  flex-grow: 1;
  overflow-y: auto;
  box-sizing: border-box;
  min-height: 0;
}

.panel-content textarea {
  height: 500px;
  margin-bottom: 0;
}

#schemaBuilder {
  height: 500px;
}

.schema-field {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.schema-field > input[type="text"] {
  margin-bottom: 0;
}

.field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field-row select {
  flex-grow: 1;
  margin-bottom: 0;
}

.field-row button {
  flex-shrink: 0;
}

.field-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-option label {
  margin-bottom: 0;
}

.field-option select {
    width: auto;
    flex-grow: 1;
    margin-bottom: 0;
}

.add-field-btn {
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  border: 2px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
  transition: var(--transition);
}

.add-field-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary-dark);
}

.validator-controls {
  margin-bottom: 2rem;
}

.controls-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid transparent;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-dark);
}
.btn-secondary {
    background-color: var(--content-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background-color: var(--bg);
}
.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.validation-results .success {
  color: var(--success);
  padding: 1rem;
  background-color: rgba(34, 197, 94, 0.1);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
}

.validation-results .error {
  color: #F87171; /* Light Red */
  padding: 0.5rem 0;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.7);
}

.modal-content {
  background-color: var(--content-bg);
  margin: 15% auto;
  padding: 2rem;
  border: 1px solid var(--border);
  width: 80%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  position: relative;
}

.close {
  color: var(--text-soft);
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: var(--text);
}

.saved-schema {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.saved-schema-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.saved-schema-name {
    font-weight: 600;
}
.saved-schema-description {
    color: var(--text-soft);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.schema-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .validator-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  .two-column {
    grid-template-columns: 1fr;
  }
  main {
    padding: 2rem 0;
  }
  h1 {
    font-size: 2.25rem;
  }
  h2 {
    font-size: 1.75rem;
  }
  .tool-section {
    padding: 1.5rem;
  }
}

/* Breadcrumb Navigation */
.breadcrumb {
  background: var(--content-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.breadcrumb-list {
  display: flex;
  list-style: none !important;
  margin: 0;
  padding: 0;
  gap: 0.5rem;
  align-items: center;
}

.breadcrumb-item {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.breadcrumb-item:not(.active) a {
  color: var(--text-soft);
  text-decoration: none;
  transition: var(--transition);
}

.breadcrumb-item:not(.active) a:hover {
  color: var(--primary);
}

.breadcrumb-item.active {
  color: var(--text);
  font-weight: 500;
}

.breadcrumb-item:not(:last-child)::after {
  content: '/';
  margin-left: 0.5rem;
  color: var(--text-muted);
}