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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e1e4e8;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid #21262d;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, #58a6ff, #bc8cff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: #8b949e;
  margin-top: 0.3rem;
  font-size: 0.95rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  color: #f0f6fc;
}

.panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .panel {
    grid-template-columns: 1fr;
  }
}

textarea {
  width: 100%;
  min-height: 220px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e1e4e8;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.75rem;
  resize: vertical;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: #30363d #0d1117;
}

textarea:focus {
  outline: none;
  border-color: #58a6ff;
}

textarea::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

textarea::-webkit-scrollbar-track {
  background: #0d1117;
  border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

.btn {
  cursor: pointer;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  background: #21262d;
  color: #c9d1d9;
}

.btn:hover {
  background: #30363d;
}

.btn.primary {
  background: #238636;
  border-color: #2ea043;
  color: #fff;
}

.btn.primary:hover {
  background: #2ea043;
}

.btn.secondary {
  background: #1f6feb;
  border-color: #388bfd;
  color: #fff;
}

.btn.secondary:hover {
  background: #388bfd;
}

.btn.op {
  flex: 1;
  min-width: 130px;
  text-align: center;
}

.btn.op.active {
  background: #238636;
  border-color: #2ea043;
  color: #fff;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ops-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.regex-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}

.regex-input input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e1e4e8;
  padding: 0.5rem 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

.regex-input input:focus {
  outline: none;
  border-color: #58a6ff;
}

.svg-container {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  border-radius: 6px;
  border: 1px solid #21262d;
  overflow: auto;
  position: relative;
}

.svg-container .placeholder {
  color: #484f58;
  font-size: 0.9rem;
}

.svg-container svg {
  max-width: 100%;
  height: auto;
}

.error-box {
  background: #3d1418;
  border: 1px solid #da3633;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  color: #f85149;
  font-size: 0.9rem;
}

.result-json {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 400px;
  margin-bottom: 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #30363d #0d1117;
}

.result-json::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.result-json::-webkit-scrollbar-track {
  background: #0d1117;
  border-radius: 4px;
}

.result-json::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

.result-json::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

.info {
  color: #8b949e;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

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

.card-header h2 {
  margin-bottom: 0;
}

.copy-epsilon {
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  color: #d29922;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  user-select: none;
}

.copy-epsilon:hover {
  background: #21262d;
}

.copy-epsilon .hint {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.7rem;
  color: #8b949e;
}

.info-box {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  background: #151d28;
  border: 1px solid #1f6feb;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  color: #8b949e;
  line-height: 1.4;
}

.info-box .info-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1f6feb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 1px;
}

.info-box code {
  color: #d29922;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.er-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.er-input-row label {
  white-space: nowrap;
  color: #8b949e;
  font-size: 0.85rem;
  min-width: 90px;
}

.er-input-row input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e1e4e8;
  padding: 0.5rem 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

.er-input-row input:focus {
  outline: none;
  border-color: #58a6ff;
}

.compare-result {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.compare-result.eq {
  background: #0a3d1a;
  border: 1px solid #2ea043;
  color: #3fb950;
}

.compare-result.neq {
  background: #3d1418;
  border: 1px solid #da3633;
  color: #f85149;
}

/* Overlay toolbar */
.toolbar-overlay {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.svg-container:hover .toolbar-overlay,
.result-json:hover .toolbar-overlay {
  opacity: 1;
}

.btn-icon {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 4px;
  background: rgba(33, 38, 45, 0.85);
  color: #c9d1d9;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: #30363d;
  color: #f0f6fc;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #238636;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 999;
  animation: fadeIn 0.2s;
}

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

/* Zoom modal */
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.15s;
}

.zoom-overlay svg {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  background: #0d1117;
  border-radius: 8px;
  padding: 1rem;
}

.svg-container {
  cursor: zoom-in;
}
