:root {
  --bg: #111827;
  --bg-alt: #1f2937;
  --fg: #f1f5f9;
  --accent: #10b981;
  --accent-alt: #0d9467;
  --border: #334155;
  --warn: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

.light {
  --bg: #f9fafb;
  --bg-alt: #ffffff;
  --fg: #1f2937;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

h1, h2 {
  margin: 0 0 12px;
  font-weight: 600;
  letter-spacing: .5px;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 20px 60px;
  display: grid;
  gap: 28px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background: var(--bg-alt);
  padding: 22px 24px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(16,185,129,.08), transparent 60%);
  pointer-events: none;
}

.diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.diagram .node {
  background: rgba(16,185,129,.12);
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  min-width: 90px;
  text-align: center;
  font-weight: 600;
}

.diagram .arrow {
  font-size: 18px;
  opacity: .7;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  opacity: .85;
}

input {
  background: var(--bg);
  color: var(--fg);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border .2s, background .2s;
}

.light input {
  background: var(--bg-alt);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(16,185,129,.07);
}

button {
  cursor: pointer;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  letter-spacing: .5px;
  transition: background .25s, transform .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover {
  background: var(--accent-alt);
}

button:active {
  transform: translateY(2px);
}

#toggleTheme {
  background: var(--accent);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  padding: 0;
}

.status {
  min-height: 44px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
  white-space: pre-line;
  background: rgba(255,255,255,.03);
}

.result {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  padding: 12px;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid #1e293b;
}

.light .result {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.tips {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.tips li {
  line-height: 1.4;
}

.footer {
  margin-top: auto;
  padding: 16px 28px;
  font-size: 12px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  text-align: center;
  letter-spacing: .6px;
}

@media (prefers-color-scheme: light) {
  body:not(.dark):not(.light) {
    background: #f9fafb;
    color: #1f2937;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-alt);
}