/* ======================================== */
/* General Styles & Base Elements         */
/* ======================================== */
html, body {
  height: 100%; /* Ensure body can take full height if needed */
  margin: 0;
}
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f4f6f8;
  color: #333;
  padding: 0;
  line-height: 1.6;
  display: flex; /* Use flexbox for overall layout */
  flex-direction: column; /* Stack header, main content vertically */
}

.container { /* Used by detail page */
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem 1rem; /* Added top padding */
  flex-grow: 1; /* Allow container to grow */
}

/* ======================================== */
/* Header (Index Page)                   */
/* ======================================== */
header#index-header { /* Specific ID for index header */
  background: #2c3e50;
  color: white;
  padding: 1rem 2rem; /* Slightly reduced padding */
  text-align: left;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex-shrink: 0; /* Prevent header from shrinking */
}

header#index-header h1 {
  margin: 0;
  font-size: 1.6rem; /* Slightly smaller */
  cursor: pointer;
  display: inline-block; /* Allow clicking only on text */
}

/* ======================================== */
/* Homepage Centered Search Layout        */
/* ======================================== */
body.homepage { /* Add class to body in index.html */
   justify-content: center; /* Center content vertically */
}

main#index-main { /* Specific ID for index main content area */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Center search vertically */
  flex-grow: 1; /* Allow main to take up remaining space */
  padding: 2rem 1rem;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

#search-container { /* Repurposed for centering */
  padding: 0; /* Remove padding */
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  background: none; /* Remove background */
  box-shadow: none; /* Remove shadow */
  position: relative;
  width: 100%;
  max-width: 650px; /* Limit search width */
  margin-bottom: 1.5rem; /* Space below search bar */
}

#search-container input {
  padding: 0.9rem 1.2rem; /* Larger padding */
  font-size: 1.15rem; /* Larger font */
  width: 100%;
  color: #333;
  background: #fff; /* White background */
  border: 1px solid #dfe1e5; /* Google-like border */
  border-radius: 24px; /* Rounded corners */
  box-sizing: border-box;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 1px 6px rgba(32,33,36,0.1); /* Subtle shadow */
}

#search-container input:hover,
#search-container input:focus {
  border-color: #d2d3d6;
  box-shadow: 0 1px 8px rgba(32,33,36,0.15);
}

#search-container input:focus {
  outline: none;
}

#search-container input::placeholder {
  color: #999;
}

#suggestions {
  list-style: none;
  margin: 8px 0 0 0; /* Adjust margin */
  padding: 0;
  max-height: 250px; /* Allow more suggestions */
  overflow-y: auto;
  background: white;
  border: 1px solid #dfe1e5;
  border-radius: 0 0 24px 24px; /* Match bottom rounding */
  width: 100%;
  max-width: 650px; /* Match input max-width */
  z-index: 100; /* Ensure it's above other content */
  position: absolute;
  top: 100%;
  left: 0; /* Align left */
  box-shadow: 0 4px 6px rgba(32,33,36,0.15);
  box-sizing: border-box;
  text-align: left; /* Align suggestion text left */
}
/* Hide suggestions border top when input is focused for seamless look */
#search-container input:focus + #suggestions {
    border-top-color: transparent;
    margin-top: -1px; /* Overlap slightly */
    border-radius: 0 0 24px 24px;
}


#suggestions li {
  padding: 0.8rem 1.2rem; /* Match input padding */
  border: none; /* Remove internal borders */
  cursor: pointer;
  color: #333;
  transition: background-color 0.2s ease;
  font-size: 1rem;
}

#suggestions li:hover,
#suggestions li.active {
  background: #f1f3f4; /* Light gray hover */
}

#suggestions li:last-child {
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
}


#suggestions li.disabled {
  color: #70757a;
  cursor: default;
}

/* *** ADDED: Style for highlighted text in suggestions *** */
#suggestions li strong {
  font-weight: bold; /* Make matched part bold */
  color: #1a0dab; /* Or choose a different highlight color */
}


/* Initial Results/Toolbar state on Homepage */
main#results,
section#toolbar {
    display: none; /* Initially hide results and toolbar */
}

/* State after a search is performed */
body.results-active main#results,
body.results-active section#toolbar {
    display: block; /* Show results */
}
body.results-active section#toolbar {
    display: flex; /* Show toolbar as flex */
}

/* Adjust main layout when results are active */
body.results-active {
   justify-content: flex-start; /* Align header to top */
}
body.results-active main#index-main {
    justify-content: flex-start; /* Align content to top */
    padding-top: 1rem; /* Add some top padding */
}
body.results-active #search-container {
    max-width: 750px; /* Slightly wider search when results shown */
    margin-bottom: 1rem;
}


/* ======================================== */
/* Toolbar / Filters (Index - Styling remains mostly same) */
/* ======================================== */
.toolbar {
  /* display: none; <- Now controlled by body.results-active */
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 1rem 2rem; /* Reduced padding */
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem; /* Space below toolbar */
  border-radius: 8px;
  max-width: 1100px; /* Match results width */
  margin-left: auto;
  margin-right: auto;
}

.filter-group {
  display: flex;
  align-items: center;
}

.filter-group label {
  margin-right: 0.6rem;
  font-weight: 600; /* Bolder label */
  color: #4a5568;
  font-size: 0.9rem;
}

.filter-group select {
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  color: #333;
  cursor: pointer;
  transition: border-color 0.3s ease;
  min-width: 160px;
}

.filter-group select:focus {
  outline: none;
  border-color: #007bff;
}


/* ======================================== */
/* Main Content Area (Shared)             */
/* ======================================== */
/* Removed the specific 'main' selector, relying on IDs */
#results, #material-content-container {
  max-width: 1100px;
  margin: 0 auto; /* Toolbar/Search handles top margin */
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  #results, #material-content-container {
    padding: 0 2rem;
  }
}


/* ======================================== */
/* Material Card (Index Results)          */
/* ======================================== */
.material-card {
  background: white;
  border: 1px solid #dfe1e5; /* Match search border */
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.25s ease, transform 0.2s ease;
  cursor: pointer;
}

.material-card:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.material-card h2 {
  margin-top: 0;
  margin-bottom: 0.6rem;
  font-size: 1.4rem; /* Slightly smaller */
  color: #1a0dab; /* Google-like link color */
  font-weight: 500;
}

.material-card p {
  margin-bottom: 0.4rem;
  color: #4d5156; /* Google-like text color */
  font-size: 0.95rem;
}

.material-card strong {
  font-weight: normal; /* Remove default bold */
  color: #4d5156;
}

.material-card .tags {
  margin-top: 1rem;
}

.material-card .tag {
  display: inline-block;
  margin: 0.3rem 0.4rem 0.3rem 0;
  padding: 0.3rem 0.7rem;
  background: #e9ecef; /* Lighter tag background */
  color: #495057; /* Darker tag text */
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  border: 1px solid #dee2e6; /* Subtle border */
}

.material-card .tag:hover {
  background: #d1d5db;
  color: #1f2937;
  border-color: #adb5bd;
}

/* *** ADDED: Style for highlighting matches within result cards *** */
.material-card .highlight {
  background-color: #fff3cd; /* Light yellow highlight */
  font-weight: 600; /* Slightly bolder */
  /* padding: 0 1px; */ /* Optional subtle padding */
  /* border-radius: 2px; */ /* Optional rounded corners */
  color: #5c3d03; /* Darker text for yellow background */
}


/* No Results Message Styling (Index) */
main#results:empty::after {
  content: "No materials found matching your search and filters.";
  display: block;
  padding: 3rem 1rem;
  text-align: center;
  color: #70757a; /* Darker gray */
  font-size: 1.1rem;
}
/* Placeholder for initial state (before search) */
main#results > p.initial-message {
    padding: 3rem 1rem;
    text-align: center;
    color: #70757a;
    font-size: 1.1rem;
}


/* ======================================== */
/* Detail Page Back Link                  */
/* ======================================== */
.back-link {
  display: inline-block;
  margin: 1rem 0 0 0; /* Adjust margin */
  padding: 0.5rem 1rem;
  color: #007bff;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  font-size: 0.95rem;
}

.back-link:hover {
  background-color: #e9ecef;
  text-decoration: underline;
}

/* ======================================== */
/* Material Detail Page Sections & Styling */
/* (Rest remains largely the same)        */
/* ======================================== */

/* --- Detail Header --- */
.detail-header {
  background: #f8f9fa;
  color: #343a40;
  padding: 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid #dee2e6;
  text-align: center;
}
.detail-header h1 {
  margin-bottom: 0.5rem;
  font-size: 2.2rem;
  font-weight: 600;
  color: #2c3e50;
  cursor: default;
}
.detail-header .formula {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 1.1rem;
  color: #495057;
  margin-top: 0.5rem;
}


/* --- Detail Tags Section --- */
#section-tags {
   background: none;
   border: none;
   box-shadow: none;
   padding: 0 1rem 1.5rem 1rem;
   margin: 0 auto 1.5rem auto;
   max-width: 1100px;
   border-bottom: 1px solid #eee;
   box-sizing: border-box;
}
#section-tags h2 { display: none; }
.tags-list { text-align: left; }
.tags-list .tag {
  display: inline-block;
  margin: 0.3rem 0.4rem 0.3rem 0;
  padding: 0.4rem 0.8rem;
  background: #6c757d;
  color: white;
  border-radius: 15px;
  font-size: 0.9rem;
  cursor: default;
}

/* --- General Detail Section Styling --- */
#material-content-container .material-section {
  background: #ffffff;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

#material-content-container .material-section h2 {
  font-size: 1.6rem;
  font-weight: 600;
  color: #0056b3;
  margin-top: 0;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e9ecef;
  display: flex;
  align-items: center;
}
/* Ensure links within H2 inherit color/style */
#material-content-container .material-section h2 a {
    color: inherit;
    text-decoration: none;
}
#material-content-container .material-section h2 a:hover {
    text-decoration: underline;
}

#material-content-container .material-section#section-safety h2 span[aria-hidden="true"] {
    margin-right: 0.75rem;
    font-size: 1.8rem;
    color: #dc3545;
}

/* --- Overview Section Specific --- */
#material-content-container #section-overview .description {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #495057;
  margin-bottom: 1.5rem;
}

#material-content-container #section-overview .image-placeholder {
  background-color: #e9ecef;
  color: #6c757d;
  text-align: center;
  padding: 4rem 1rem;
  border-radius: 6px;
  font-style: italic;
  margin-top: 1rem;
}

/* --- Property List Styling --- */
.property-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.5rem 2.5rem;
  padding: 0;
  margin-top: 0.5rem;
  list-style: none;
}

.property-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease-in-out;
}

.property-item:hover { background-color: #fcfcfc; }

.property-item.comparison-na-message dd {
    grid-column: 1 / -1;
    text-align: left;
}

.property-key {
  font-weight: 500;
  color: #495057;
  text-align: right;
  padding-right: 0.8rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.property-value {
  color: #212529;
  font-size: 1rem;
  word-break: break-word;
  line-height: 1.5;
  font-weight: 400;
}

.property-value .unit {
    font-size: 0.9em;
    color: #6c757d;
    margin-left: 0.25em;
}
.property-value .notes,
.property-value .notes-only {
    display: block;
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.2rem;
    font-style: italic;
}
.property-value sub {
    font-size: 0.75em;
    line-height: 0;
}

.property-value.na-value,
span.na-value {
  color: #999;
  font-style: italic;
}

.property-value ul.property-list-items {
  margin: 0;
  padding-left: 1.2rem;
  list-style-type: disc;
}
.property-value ul.property-list-items li { margin-bottom: 0.25rem; }

.property-item.key-property .property-key {
   font-weight: 600;
   color: #0056b3;
}
.property-item.key-property .property-value { font-weight: 500; }

/* --- Specific Section Adjustments --- */
#material-content-container #section-safety .property-list {
  grid-template-columns: 1fr;
  gap: 0;
}
#material-content-container #section-safety .property-item {
    grid-template-columns: 110px 1fr;
    background-color: #fff3cd;
    border-radius: 4px;
    padding: 0.8rem 1rem;
    border-bottom: none;
    margin-bottom: 0.75rem;
    transition: none;
}
#material-content-container #section-safety .property-item:hover { background-color: #fff3cd; }
#material-content-container #section-safety .property-key {
    color: #856404;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
}
#material-content-container #section-safety .property-value {
    color: #856404;
    font-size: 0.95rem;
    font-weight: 400;
}
#material-content-container #section-safety .property-item.key-property .property-value { font-weight: 500; }

#reference-list, #vendor-list {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
    list-style: disc;
}
#reference-list li, #vendor-list li { margin-bottom: 0.5rem; }
#reference-list li.ref-notes, #vendor-list li.vendor-notes {
    list-style: none;
    margin-left: -1.5rem;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}


/* ======================================== */
/* Periodic Table Styles (UPDATED LAYOUT) */
/* ======================================== */

#section-periodic-table h2 { margin-bottom: 1rem; }

/* The main wrapper using CSS Grid */
.periodic-table-wrapper {
  display: grid;
  /* Define 19 columns: 1 for period labels + 18 element groups */
  grid-template-columns: minmax(20px, auto) repeat(18, minmax(45px, 1fr));
  /* Define 11 rows: 1 group label + 7 periods + 1 gap + 2 f-block rows */
  grid-template-rows: minmax(20px, auto) repeat(7, minmax(45px, auto)) 20px repeat(2, minmax(45px, auto));
  gap: 3px;
  padding: 10px;
  background-color: #f0f2f5; /* Slightly different background */
  border-radius: 6px;
  max-width: 100%;
  overflow-x: auto;
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
  margin-top: 1rem;
  position: relative; /* Keep relative for potential absolute children like tooltip */
}

/* Remove scrollbar visibility but keep functionality */
.periodic-table-wrapper::-webkit-scrollbar { display: none; }
.periodic-table-wrapper { -ms-overflow-style: none; scrollbar-width: none; }

/* Style for Group/Period Labels */
.pt-label {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: #4a5568;
  font-size: 0.7rem;
  background-color: transparent;
  border-radius: 2px;
}
/* Group labels are positioned via inline styles (grid-row: 1; grid-column: 2 to 19) */
/* Period labels are positioned via inline styles (grid-row: 2 to 8; grid-column: 1) */

/* Element Tile Styling */
.pt-element {
  border: 1px solid #cbd5e0;
  padding: 5px 3px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  line-height: 1.1;
  background-color: #fff;
  min-height: 45px;
  box-sizing: border-box;
  position: relative;
  cursor: default;
  transition: transform 0.1s ease-out, box-shadow 0.15s ease-out, border-color 0.15s ease-out;
  border-radius: 3px;
  /* Grid positioning done via inline styles */
}

.pt-element:hover {
    border-color: #a0aec0;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.pt-number {
  font-size: 0.65rem;
  position: absolute;
  top: 3px;
  left: 4px;
  color: #718096;
}

.pt-mass {
  font-size: 0.6rem;
  color: #4a5568;
  display: block;
  margin-top: 1px;
  line-height: 1;
}

/* Placeholder style for Lanthanide/Actinide gaps in main table */
.pt-placeholder {
  background-color: #e2e8f0;
  border: 1px dashed #a0aec0;
  font-size: 0.8em;
  color: #718096;
  align-items: center;
  /* Grid positioning done via inline styles */
}
.pt-placeholder .pt-number,
.pt-placeholder .pt-mass { display: none; }

/* Label for the Lanthanide/Actinide rows below */
.pt-series-label {
   font-weight: bold;
   background-color: transparent;
   border: none;
   text-align: right;
   padding-right: 8px;
   font-size: 0.75rem;
   align-items: center;
   color: #4a5568;
   /* Grid positioning done via inline styles */
}
.pt-series-label .pt-number,
.pt-series-label .pt-mass { display: none; }

/* --- Element Category Colors (Subtle Pastels) --- */
.pt-element.alkali-metal           { background-color: #ffecdd; border-color: #ffdab9; }
.pt-element.alkaline-earth-metal   { background-color: #fff2cc; border-color: #ffe6b3; }
.pt-element.lanthanide             { background-color: #fde2ff; border-color: #fcc2ff; }
.pt-element.actinide               { background-color: #ffd1dc; border-color: #ffb3c6; }
.pt-element.transition-metal       { background-color: #e0f2fe; border-color: #bae6fd; }
.pt-element.post-transition-metal  { background-color: #e2e8f0; border-color: #cbd5e0; }
.pt-element.metalloid              { background-color: #d1fae5; border-color: #a7f3d0; }
.pt-element.polyatomic-nonmetal    { background-color: #ccfbf1; border-color: #99f6e4; }
.pt-element.diatomic-nonmetal      { background-color: #ccfbf1; border-color: #99f6e4; }
.pt-element.noble-gas              { background-color: #f3e8ff; border-color: #e9d5ff; }
.pt-element.unknown                { background-color: #f1f5f9; border-color: #e2e8f0; }
.pt-element.halogen                { background-color: #fef9c3; border-color: #fef08a; }


/* --- Highlight Style (More prominent) --- */
.pt-element.highlighted-element {
  border: 2px solid #1e3a8a;
  transform: scale(1.06);
  box-shadow: 0 0 8px rgba(30, 58, 138, 0.5);
  z-index: 10;
  color: #000;
}
.pt-element.highlighted-element .pt-mass { font-weight: 500; }

/* --- Custom Tooltip Style --- */
.pt-tooltip {
    position: absolute;
    display: none;
    background-color: rgba(17, 24, 39, 0.96);
    color: #f8f9fa;
    padding: 10px 14px;
    border-radius: 5px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-line;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    max-width: 280px;
    border: 1px solid #4b5563;
}
.pt-tooltip strong { color: #93c5fd; font-weight: 600; }
.pt-tooltip br { content: " "; display: block; margin-top: 0.3em; }


/* ======================================== */
/* Responsive Adjustments                 */
/* ======================================== */
@media (max-width: 1000px) {
  /* Detail Page adjustments */
  #material-content-container .property-list {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  /* Periodic Table Responsive */
  .periodic-table-wrapper {
      grid-template-columns: minmax(15px, auto) repeat(18, minmax(38px, 1fr));
      /* Rows: 1 group + 7 periods + 1 gap + 2 f-block = 11 */
      grid-template-rows: minmax(15px, auto) repeat(7, minmax(38px, auto)) 15px repeat(2, minmax(38px, auto));
      font-size: 0.7rem;
      gap: 2px;
      padding: 8px;
  }
  .pt-element { min-height: 38px; font-size: 0.7rem; border-radius: 2px;}
  .pt-number { font-size: 0.55rem; }
  .pt-mass { font-size: 0.5rem; }
  .pt-label { font-size: 0.6rem; }
}

@media (max-width: 768px) {
  /* Detail Page adjustments */
  #material-content-container .property-item {
    grid-template-columns: 130px 1fr;
    padding: 0.6rem 0;
  }
  #material-content-container #section-safety .property-item {
    grid-template-columns: 100px 1fr;
  }
  .detail-header h1 { font-size: 1.8rem; }
  #material-content-container .material-section h2 { font-size: 1.4rem; }
  #material-content-container .material-section { padding: 1rem 1.5rem; }

  /* Periodic Table Responsive */
  .periodic-table-wrapper {
      grid-template-columns: minmax(15px, auto) repeat(18, minmax(32px, 1fr));
      /* Rows: 1 group + 7 periods + 1 gap + 2 f-block = 11 */
      grid-template-rows: minmax(15px, auto) repeat(7, minmax(32px, auto)) 10px repeat(2, minmax(32px, auto));
      font-size: 0.6rem;
      padding: 5px;
  }
   .pt-element { min-height: 32px; font-size: 0.65rem; padding: 3px 1px;}
   .pt-number { font-size: 0.5rem; top: 2px; left: 2px;}
   .pt-mass { font-size: 0.45rem; }
   .pt-label { font-size: 0.55rem; }

  /* Index page adjustments */
  header#index-header, .toolbar, #results, #search-container {
      padding-left: 1rem;
      padding-right: 1rem;
  }
  /* Adjust search input width */
  #search-container { max-width: 95%; }
  #search-container input { max-width: 100%; }
  #suggestions { max-width: 100%; }
}

@media (max-width: 576px) {
    /* Detail Page adjustments */
    #material-content-container .property-item {
      grid-template-columns: 100px 1fr;
      gap: 0.5rem;
    }
    #material-content-container .property-key {
       font-size: 0.85rem;
       padding-right: 0.5rem;
    }
    #material-content-container .property-value { font-size: 0.9rem; }
    #material-content-container #section-safety .property-item {
      grid-template-columns: 85px 1fr;
    }
    .container { padding-left: 0.5rem; padding-right: 0.5rem; }
    .detail-header { padding: 1.5rem 1rem; }
    #section-tags { padding-left: 0.5rem; padding-right: 0.5rem; }
    #material-content-container .material-section { padding: 1rem; }
    .back-link { margin-left: 0.5rem; }

     /* Periodic Table Responsive */
    .periodic-table-wrapper {
        grid-template-columns: minmax(12px, auto) repeat(18, minmax(25px, 1fr)); /* Further shrink */
        /* Rows: 1 group + 7 periods + 1 gap + 2 f-block = 11 */
        grid-template-rows: minmax(12px, auto) repeat(7, minmax(25px, auto)) 8px repeat(2, minmax(25px, auto)); /* Adjusted gap row */
        gap: 1px;
        font-size: 0.5rem; /* Even smaller font */
        padding: 3px;
    }
     .pt-element { min-height: 25px; padding: 1px; line-height: 1.1; font-size: 0.55rem; }
     .pt-number { font-size: 0.4rem; top: 1px; left: 1px; }
     .pt-mass { font-size: 0.35rem; margin-top: 0; }
     .pt-series-label { font-size: 0.45rem; padding-right: 3px;}
     .pt-label { font-size: 0.5rem;}
     .pt-element.highlighted-element { border-width: 1px; }


    /* Index page adjustments */
     header#index-header, .toolbar, #results, #search-container {
      padding-left: 0.5rem;
      padding-right: 0.5rem;
     }
     header#index-header h1 { font-size: 1.4rem;} /* Smaller */
     #search-container input { font-size: 1rem;}
     .filter-group { flex-direction: column; align-items: stretch; gap: 0.5rem;}
     .filter-group label { margin-bottom: 0.2rem; margin-right: 0;}
     .filter-group select { width: 100%; }
     .toolbar { gap: 1rem; }
     main#index-main { padding: 1rem 0.5rem; } /* Reduce padding */
}

/* ======================================== */
/* MVP Professional Refresh (2026-04)      */
/* ======================================== */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --border: #dbe2ea;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --focus: #2563eb;
}

body {
  background: linear-gradient(180deg, #edf2f8 0%, var(--bg) 180px);
  color: var(--text-primary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

header#index-header {
  background: #10243a;
  padding: 1rem 2rem 1.25rem;
}

.header-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: #ccdae8;
}

#search-panel {
  max-width: 900px;
  width: min(900px, 100%);
  margin: 0 auto 1.2rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: left;
}

#search-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
}

.search-panel-description {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

#search-container {
  max-width: 100%;
  margin-bottom: 0;
}

#search-container input {
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 1rem;
}

#search-container input:focus-visible,
.filter-group select:focus-visible,
.material-card:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#suggestions {
  border-radius: 10px;
  margin-top: 6px;
}

body.results-active #search-panel {
  margin-top: 0.5rem;
}

.toolbar {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.filter-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.filter-group label {
  margin-right: 0;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-group select {
  min-width: 210px;
  border-color: var(--border);
}

#results-region {
  max-width: 1100px;
  width: 100%;
}

.results-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
  margin: 0 auto 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.results-meta p { margin: 0; font-size: 0.9rem; }
.results-meta span { color: var(--text-primary); }

#results {
  display: grid;
  gap: 1rem;
}

.material-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
}

.material-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.material-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.material-card-title {
  margin: 0;
  font-size: 1.2rem;
  color: #0f4ea6;
}

.material-card-formula {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.field-label {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-right: 0.45rem;
}

.material-card-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.3rem 0.9rem;
  margin: 0.9rem 0 0.55rem;
}

.material-card-meta p,
.material-card-summary { margin: 0; }

.material-card-summary {
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.quick-signals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin: 0.9rem 0 0.3rem;
}

.signal {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fbff;
}

.signal dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.signal dd { margin: 0.1rem 0 0; font-weight: 600; color: #0f3568; }

.initial-message {
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.initial-message.error-state {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

/* Detail page polish + machine-friendly structure */
.detail-header {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

#material-content-container .material-section,
#section-periodic-table,
#section-tags {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

#material-content-container .material-section h2 {
  color: #0f4ea6;
  font-size: 1.3rem;
}

.property-item {
  grid-template-columns: 180px minmax(0, 1fr);
  border-bottom: 1px solid #edf2f7;
}

.property-key {
  text-align: left;
  font-weight: 600;
}

.property-value {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  #search-panel { padding: 1rem; }
  .material-card-header { flex-direction: column; align-items: flex-start; }
  .property-item { grid-template-columns: 1fr; gap: 0.35rem; }
}

.section-intro { margin: -0.25rem 0 1rem; color: var(--text-secondary); font-size: 0.92rem; }

