
:root {
  --bg-page: #f3f4f8;
  --glass-white: rgba(255,255,255,0.7);
  --glass-dark: rgba(44,62,80,0.78);
  --border-soft: rgba(255,255,255,0.65);
  --shadow-soft: 0 18px 45px rgba(15,23,42,0.25);
  --accent: #4ecdc4;
  --accent-2: #6b48ff;
  --text-main: #111827;
  --text-muted: #6b7280;
}

/* базовая раскладка */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top, #ffffff 0, #e5ecff 40%, #edf2ff 100%);
  color: var(--text-main);
}

/* центрирование контента */

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem 1.2rem 2.5rem;
}

/* шапка */

header {
  background: var(--glass-dark);
  color: #fff;
  border-radius: 24px;
  padding: 1.8rem 1.6rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  line-height: 1.35;
}

/* навигация + стеклянный переключатель */

nav {
  background: var(--glass-white);
  border-radius: 18px;
  padding: 0.4rem 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
  box-shadow: 0 12px 35px rgba(15,23,42,0.1);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-soft);
  margin-bottom: 0.6rem;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 0.8rem;
  padding: 0;
  margin: 0;
}

nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

nav a:hover {
  background: rgba(255,255,255,0.9);
  color: var(--text-main);
  transform: translateY(-1px);
}

nav a.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
}

/* стеклянный переключатель */

.glass-radio-group {
  --bg: rgba(255, 255, 255, 0.45);
  --text: #111827;
  display: flex;
  position: relative;
  background: var(--bg);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.4),
    0 14px 30px rgba(15,23,42,0.15);
  overflow: hidden;
  width: fit-content;
  margin-left: auto;
}

.glass-radio-group input {
  display: none;
}

.glass-radio-group label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  font-size: 13px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text);
  position: relative;
  z-index: 2;
  transition: color 0.25s ease;
  white-space: nowrap;
}

.glass-radio-group label:hover {
  color: var(--accent-2);
}

.glass-radio-group input:checked + label {
  color: #111827;
}

.glass-glider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: calc(25% - 6px);
  margin-left: 3px;
  border-radius: 999px;
  z-index: 1;
  transition:
    transform 0.5s cubic-bezier(0.37, 1.95, 0.66, 0.56),
    background 0.35s ease,
    box-shadow 0.35s ease;
  background: rgba(255,255,255,0.98);
  box-shadow:
    0 0 18px rgba(160, 216, 255, 0.55),
    0 0 6px rgba(255,255,255,0.9) inset;
}

#tab-home:checked ~ .glass-glider {
  transform: translateX(0%);
}

#tab-periodic:checked ~ .glass-glider {
  transform: translateX(100%);
}

#tab-solubility:checked ~ .glass-glider {
  transform: translateX(200%);
}

#tab-calc:checked ~ .glass-glider {
  transform: translateX(300%);
}

/* карточки секций */

section {
  background: var(--glass-white);
  border-radius: 22px;
  padding: 1.4rem 1.6rem;
  margin: 1.1rem auto;
  max-width: 1200px;
  box-shadow: 0 15px 40px rgba(15,23,42,0.12);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.7);
}

section h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

section p {
  color: var(--text-muted);
  line-height: 1.55;
}

/* таблицы */

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 16px 40px rgba(15,23,42,0.12);
}

th, td {
  border: 1px solid rgba(148,163,184,0.4);
  padding: 0.3rem 0.4rem;
  text-align: center;
  font-size: 0.75rem;
}

thead th {
  background: linear-gradient(135deg, #4b5563, #111827);
  color: #f9fafb;
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: rgba(249,250,251,0.96);
}

/* растворимость: М, Н, Р, тире */

td.M  { background:#4ecdc4; color:#fff; font-weight:600; }
td.N  { background:#ff6b6b; color:#fff; font-weight:600; }
td.P, td.R { background:#ffffff; color:#111827; font-weight:600; }
td.dash { background:#e5e7eb; color:#4b5563; }

/* модальные окна таблицы растворимости */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,0.55);
  z-index: 9500;
}

.modal-content {
  background: rgba(255,255,255,0.96);
  border-radius: 20px;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 24px 55px rgba(15,23,42,0.45);
  max-width: 520px;
  width: 90%;
}

/* подвал */

footer {
  margin-top: 2rem;
  padding: 1.2rem 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Химический калькулятор (Apple Glass) ===== */

.calc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.calc-modal {
  width: min(720px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 26px;
  padding: 1.6rem 1.8rem 1.5rem;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.98), rgba(226,232,240,0.96));
  box-shadow:
    0 26px 70px rgba(15,23,42,0.55),
    0 0 0 1px rgba(255,255,255,0.9) inset;
  position: relative;
}

.calc-title {
  margin: 0 0 0.8rem;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  color: transparent;
}

.calc-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  background: radial-gradient(circle at top left, #ffffff, #e5e7eb);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.9),
    0 12px 25px rgba(15,23,42,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.calc-close:hover {
  transform: translateY(-1px) scale(1.03) rotate(8deg);
  box-shadow:
    0 16px 30px rgba(15,23,42,0.45);
}

.calc-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.calc-mode-btn {
  flex: 1 1 calc(50% - 0.4rem);
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(255,255,255,0.9);
  color: #111827;
  text-align: center;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease, border-color 0.2s;
}

.calc-mode-btn:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.calc-mode-btn.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 25px rgba(79,70,229,0.4);
}

.calc-content {
  margin-top: 0.4rem;
}

.calc-input, .calc-select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.7);
  background: rgba(255,255,255,0.9);
  margin: 0.35rem 0;
  font-size: 0.9rem;
}

.calc-input:focus, .calc-select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(129,140,248,0.5);
}

.calc-run-btn {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #f9fafb;
  box-shadow: 0 16px 40px rgba(79,70,229,0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.calc-run-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 45px rgba(79,70,229,0.6);
}

.calc-results {
  margin-top: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  background: rgba(15,23,42,0.92);
  color: #e5e7eb;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

/* история */

.history-toggle {
  margin-top: 0.8rem;
  width: 100%;
  border-radius: 999px;
  border: none;
  background: rgba(148,163,184,0.18);
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #374151;
}

.calc-history {
  margin-top: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 16px;
  padding: 0.6rem 0.8rem;
  background: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  color: #1f2933;
  border: 1px solid rgba(148,163,184,0.55);
}

.calc-history-entry {
  padding: 0.25rem 0;
  border-bottom: 1px dashed rgba(148,163,184,0.6);
}

.calc-history-entry:last-child {
  border-bottom: none;
}

/* адаптивность */

@media (max-width: 768px) {
  nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .glass-radio-group {
    margin-left: 0;
    align-self: center;
  }
  .calc-modal {
    padding: 1.3rem 1.2rem 1.1rem;
  }
  .calc-mode-btn {
    flex-basis: 100%;
  }
}

/* Apple-style scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.75);
  border-radius: 10px;
}


/* Bigger table cells */
td, th {
  height: 60px !important;
  min-height: 60px !important;
  padding: 10px !important;
}

/* Remove table grid */
table, td, th {
  border: none !important;
}


/* Group headers visible */
.group-header, .period-header, th.group, th.period {
  color: #000 !important;
  font-weight: 700 !important;
  font-size: 18px !important;
}

/* Medium table cells */
td, th {
  height: 48px !important;
  min-height: 48px !important;
  padding: 8px !important;
}

/* Restore Apple-style scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.75);
  border-radius: 10px;
}

/* Neon gray scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #1e1e1e;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,#b3b3b3,#8d8d8d,#cfcfcf);
  border-radius: 12px;
  box-shadow: 0 0 6px rgba(200,200,200,0.6);
}


/* === Added by ChatGPT modifications === */
.solubility-table td:first-child,
.solubility-table th:first-child{
 position: sticky;
 left:0;
 background:white;
 z-index:10;
}

.calc-close, .close{
 transition:none !important;
 transform:none !important;
}
.calc-close:hover, .close:hover{
 transform:none !important;
}


/* Подсветка найденного элемента при переходе */
.highlighted-element {
  outline: 3px solid #4a90e2;
  box-shadow: 0 0 15px #4a90e2;
  border-radius: 4px;
  transition: all 0.5s ease;
}

.feedback-section {
  text-align: center;
  margin-top: 60px;
  padding: 20px;
}

.feedback-section h2 {
  color: #2c2c2c;
  font-weight: 600;
}

.feedback-section p {
  color: #555;
  margin-bottom: 20px;
}

#feedback-form {
  max-width: 480px;
  margin: 0 auto;
  background: #fafafa;
  padding: 28px;
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  border: 1px solid #e1e1e1;
  transition: 0.4s;
}

#feedback-form.sent {
  transform: scale(0.97);
  opacity: 0.3;
}

#feedback-form input,
#feedback-form textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  transition: 0.2s;
}

#feedback-form input:focus,
#feedback-form textarea:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 4px rgba(74, 144, 226, 0.4);
  outline: none;
}

#send-btn {
  width: 100%;
  padding: 12px 18px;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.3s, transform 0.2s;
}
#send-btn:hover {
  background: #3f7fd3;
  transform: scale(1.02);
}

/* Сообщения */
.feedback-success,
.feedback-error {
  display: none;
  margin: 20px auto 0;
  padding: 14px 22px;
  border-radius: 10px;
  width: fit-content;
  font-weight: 500;
  animation: fadeIn 0.4s ease;
}

.feedback-success {
  color: #155724;
  background: #d4edda;
  border: 1px solid #c3e6cb;
}

.feedback-error {
  color: #721c24;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
