:root {
  --primary-color: #4a90e2;
  --primary-hover: #357abd;
  --bg-color: #f0f2f5;
  --sidebar-bg: #ffffff;
  --sidebar-width: 380px;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  height: 100vh;
  width: 100vw;
  display: flex;
  overflow: hidden;
  background-color: var(--bg-color);
}

/* --- 布局容器 --- */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: row;
}

/* 左侧控制栏 */
.sidebar {
  width: var(--sidebar-width);
  min-width: 300px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid #e1e4e8;
  padding: 30px 25px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 4px 0 15px rgba(0,0,0,0.02);
  z-index: 20;
  overflow-y: auto;
}

/* 右侧主视图 */
.main-content {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background-color: var(--bg-color);
  overflow: hidden;
}

/* --- UI 组件样式 --- */
h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  color: #1E293A;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.description {
  font-size: 14px;
  color: #7f8c8d;
  line-height: 1.5;
  margin-bottom: 15px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: #95a5a6;
  text-transform: uppercase;
  letter-spacing: 1px;
}

textarea, input[type="text"], select {
  width: 100%;
  box-sizing: border-box;
  padding: 15px;
  border: 2px solid #ecf0f1;
  border-radius: 10px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  color: #1E293A;
  background: #fdfdfd;
  transition: all 0.3s ease;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

input[type="text"], select {
  padding: 12px;
  font-family: "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2395a5a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 16px;
  cursor: pointer;
}

textarea:focus, input[type="text"]:focus, select:focus {
  border-color: var(--primary-color);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

/* Attention Pulse Animation */
@keyframes pulse-border {
  0% {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4);
  }
  70% {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 6px rgba(74, 144, 226, 0);
  }
  100% {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0 rgba(74, 144, 226, 0);
  }
}

.attention-pulse {
  animation: pulse-border 2s infinite;
  border-color: var(--primary-color) !important;
}

/* Logo Animation */
@keyframes logo-float {
  0% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-10px);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
}

.logo-animate {
  transform-origin: center;
  transform-box: fill-box;
  animation: logo-float 4s ease-in-out infinite;
}

/* Logo Text Animation */
.logo-text {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  overflow: hidden;
  vertical-align: bottom;
  line-height: 1;
}

.logo-text .char {
  position: relative;
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.76, 0, 0.24, 1);
  transition-delay: calc(var(--i) * 0.03s);
}

.logo-text .char::after {
  content: attr(data-char);
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  color: var(--primary-color);
}

.logo-text:hover .char {
  transform: translateY(100%);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

button {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px rgba(74, 144, 226, 0.25);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(74, 144, 226, 0.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background-color: white;
  border: 2px solid #ecf0f1;
  color: #7f8c8d;
}
.btn-secondary:hover {
  border-color: #bdc3c7;
  color: #1E293A;
  background-color: #fbfbfb;
}

/* Export Buttons Row */
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-export {
  flex: 1;
  background-color: #1E293A;
  color: #fff;
  font-size: 13px;
  padding: 10px;
}
.btn-export:hover {
  background-color: #1E293A;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.footer-controls {
  margin-top: auto; 
  padding-top: 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-text {
  background: none;
  border: none;
  color: #bdc3c7;
  font-size: 12px;
  font-weight: 400;
  padding: 5px;
}
.btn-text:hover {
  color: #7f8c8d;
  text-decoration: underline;
}

/* --- Button Icons --- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  flex-shrink: 0;
}

/* --- SVG Adapter --- */
#svg {
  width: auto;
  height: auto;
  max-width: 98%;
  max-height: 98%;
  display: block;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* --- 响应式适配 --- */
@media (max-width: 900px) {
  .app-container { flex-direction: column; }
  .sidebar {
    width: 100%; max-height: 45vh;
    border-right: none; border-bottom: 1px solid #e1e4e8;
    padding: 20px;
    box-sizing: border-box;
  }
  textarea { min-height: 80px; }
  .main-content { height: 55vh; }
}

/* --- Toggle Switch --- */
.switch-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #f0f0f0;
  margin-top: 15px;
}
.switch-label {
  font-size: 14px;
  color: #1E293A;
  font-weight: 600;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }

/* Tooltip Styles */
.tooltip-container {
  position: relative;
  display: inline-block;
  margin-left: 5px;
  cursor: help;
}

.help-icon {
  width: 16px;
  height: 16px;
  background-color: #bdc3c7; /* Gray circle */
  color: #2c3e50; /* Dark gray question mark */
  border-radius: 50%;
  text-align: center;
  line-height: 16px;
  font-size: 12px;
  font-weight: bold;
}

.tooltip-text {
  visibility: hidden;
  width: 220px;
  background-color: #34495e;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 8px 12px;
  position: absolute;
  z-index: 100;
  bottom: 125%; /* Position above */
  left: 50%;
  margin-left: -110px; /* Center the tooltip */
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 12px;
  line-height: 1.4;
  font-weight: normal;
  text-transform: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  pointer-events: none;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #34495e transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* --- D3 Styles --- */
.highlight rect, .highlight circle, .highlight path, .highlight line {
  stroke: #e74c3c !important;
  stroke-width: 4 !important;
  filter: drop-shadow(0 0 4px rgba(231, 76, 60, 0.6));
}
.st35 { fill: #ffe8c0; }
.st34 { fill: #cecece; }
.st39 { fill: #fbcccd; }
.st40 { fill: #dad7ec; }
.st38 { fill: #c9e5c7; }
.enzyme rect { rx: 6; ry: 6; stroke: #444; stroke-width: 1; cursor: default; }
.label { fill: #222; font-size: 14px; font-family: Arial, sans-serif; }
.big-label { fill: #000; font-size: 18px; font-weight: 700; }
.small-label { fill: #555; font-size: 11px; }
.pill { rx: 16; ry: 16; stroke: none; opacity: 0.9; }

/* --- Grayscale Mode --- */
#svg.grayscale-active { background-color: #fafafa; }
#svg.grayscale-active > g > g:not(.highlight):not(.pill-group),
#svg.grayscale-active > g > path,
#svg.grayscale-active > g > line,
#svg.grayscale-active > g > circle,
#svg.grayscale-active > g > text {
  filter: grayscale(100%);
  transition: all 0.4s ease;
}
#svg.grayscale-active > g > g.highlight {
  filter: none;
  transition: all 0.4s ease;
}
