* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #6b7280;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --text-dark: #1f2937;
  --text-light: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  color: var(--text-dark);
  min-height: 100vh;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.beaker-icon, .failure-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.modal-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-dark);
}

.modal-header p {
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.safety-alert {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.warning-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.alert-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.safety-alert p {
  color: #b45309;
  font-size: 13px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-light);
  border-color: var(--secondary);
}

.btn-danger {
  background: var(--danger);
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  border: 2px solid var(--border);
  color: var(--text-dark);
  background: transparent;
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-light);
}

.btn-small {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-danger-small {
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-small:hover:not(:disabled) {
  background: #fee2e2;
}

/* Header */
.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  font-size: 24px;
  margin-right: 8px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.app-subtitle {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.goggles-btn {
  padding: 8px 12px;
  border-radius: 9999px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  color: var(--danger);
  border-color: #fecaca;
  background: #fee2e2;
  animation: pulse 2s infinite;
}

.goggles-btn.active {
  color: var(--success);
  border-color: #d1fae5;
  background: #ecfdf5;
  animation: none;
}

/* Main Layout */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.container.hidden {
  display: none;
}

.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
}

.experiment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.experiment-btn {
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 600;
}

.experiment-btn:hover {
  background: var(--bg-light);
  border-color: var(--border);
}

.experiment-btn.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.1);
}

.experiment-btn .name {
  display: block;
  margin-bottom: 4px;
}

.experiment-btn .desc {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 400;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.experiment-btn.active .desc {
  color: var(--primary);
  opacity: 0.8;
}

/* Search Elements */
.search-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-group input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-white);
}

.search-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.search-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.search-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--text-dark);
}

.search-card span {
  display: block;
  font-size: 12px;
  color: var(--text-light);
}

.search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.search-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.search-hint {
  color: var(--text-light);
  font-size: 13px;
}

/* Notebook */
.notebook-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notebook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notebook-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
}

.time-display {
  font-size: 12px;
  color: var(--text-light);
}

.notebook-content {
  flex: 1;
  background: var(--bg-light);
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  max-height: 300px;
}

.notebook-placeholder {
  text-align: center;
  color: var(--text-light);
  font-style: italic;
}

.notebook-entry {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}

.notebook-entry.success {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--success);
}

.notebook-entry.warning {
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid var(--warning);
}

.notebook-entry.danger {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--danger);
}

.notebook-entry.info {
  background: rgba(107, 114, 128, 0.1);
  border-left: 3px solid var(--secondary);
}

.timestamp {
  color: var(--text-light);
  font-size: 10px;
  margin-right: 8px;
}

/* Workspace */
.workspace {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.placeholder-icon {
  font-size: 96px;
  opacity: 0.3;
}

.placeholder-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-light);
}

.placeholder-subtitle {
  font-size: 14px;
  color: #9ca3af;
}

.workspace-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 24px;
  padding: 24px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.workspace-content.hidden {
  display: none;
}

/* Reagents Section */
.reagents-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 8px;
}

.reagent-panel {
  background: var(--bg-white);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reagent-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  text-align: center;
}

.reagent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.reagent-bottle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  border: none;
}

.reagent-bottle:hover:not(:disabled) {
  background: var(--bg-light);
}

.reagent-bottle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.reagent-bottle:active:not(:disabled) {
  transform: scale(0.95);
}

.bottle-visual {
  width: 48px;
  height: 64px;
  border-radius: 6px 6px 12px 12px;
  border: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottle-visual::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: #e5e7eb;
  border-bottom: 1px solid var(--border);
}

.bottle-visual::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 2px;
  right: 2px;
  height: 12px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
}

.bottle-label {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--text-dark);
}

/* Bench Section */
.bench-section {
  background: var(--bg-white);
  border-radius: 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.controls-top {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin-bottom: 16px;
}

.tube-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.reaction-chamber {
  position: relative;
  width: 80px;
  height: 240px;
  transform: scale(1.2);
}

.chamber-body {
  width: 100%;
  height: 100%;
  border-radius: 0 0 50% 50%;
  border: 3px solid var(--border);
  background: transparent;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.chamber-contents {
  width: 100%;
  height: 0;
  background: transparent;
  transition: height 0.5s ease, background-color 1s ease;
  border-radius: 20px 20px 0 0;
  position: relative;
}

.chamber-contents::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: inherit;
  border-radius: inherit;
}

.chamber-bubbles {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 1px, transparent 1px);
  background-size: 4px 4px;
  animation: bubble 2s infinite;
  display: none;
}

.bubble {
  position: absolute;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: bubble-rise 2s infinite ease-out;
}

@keyframes bubble-rise {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-40px);
    opacity: 0;
  }
}

.chamber-flame {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 30px;
  background: linear-gradient(to top, #ff6b35, #f7931e, #ffff00);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flicker 0.5s infinite alternate;
  display: none;
}

.chamber-lid {
  width: 100%;
  height: 20px;
  background: #6b7280;
  border: 3px solid #4b5563;
  border-radius: 0 0 8px 8px;
}

.chamber-stand {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
}

.stand-base {
  width: 80px;
  height: 20px;
  background: #4b5563;
  border-radius: 4px;
}

.controls-bottom {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin-top: 16px;
}

/* Procedure Section */
.procedure-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.procedure-steps {
  list-style-position: inside;
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.procedure-steps li {
  color: var(--text-light);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes bubble {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0; }
}

@keyframes flicker {
  0% { transform: translateX(-50%) scaleY(1); }
  100% { transform: translateX(-50%) scaleY(1.1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .sidebar {
    order: 2;
    padding: 16px;
  }

  .workspace-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 16px;
  }

  .reagents-section {
    order: 1;
  }

  .bench-section {
    order: 2;
  }

  .section:last-child {
    order: 3;
  }
}