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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e1e4ed;
  --text-dim: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --success: #00b894;
  --error: #e74c3c;
  --warning: #f39c12;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header { text-align: center; margin-bottom: 2rem; }

h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle { color: var(--text-dim); font-size: 0.95rem; margin-top: 0.3rem; }

h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.hint { color: var(--text-dim); font-size: 0.85rem; }

label { display: block; font-size: 0.9rem; margin-bottom: 0.3rem; color: var(--text-dim); }

textarea, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

textarea:focus, input:focus { outline: none; border-color: var(--accent); }

.file-upload {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

input[type="file"] { display: none; }

.file-label {
  padding: 0.45rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.2s;
}

.file-label:hover { border-color: var(--accent); }
.file-names { color: var(--text-dim); font-size: 0.85rem; }

.sim-options { margin-bottom: 0.75rem; }
.sim-options label { display: inline-flex; align-items: center; gap: 0.5rem; }
.sim-options input[type="number"] { width: 80px; margin-bottom: 0; }

.btn {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #3a3d4a; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-small { background: var(--border); color: var(--text-dim); padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-small:hover { background: #3a3d4a; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Log Panel */
.log-card { position: sticky; top: 0; z-index: 10; }

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.log-actions { display: flex; gap: 0.5rem; }

.log-panel {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

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

.log-time { color: #555; margin-right: 0.5rem; }
.log-info { color: var(--text-dim); }
.log-success { color: var(--success); }
.log-error { color: var(--error); }
.log-warn { color: var(--warning); }
.log-step { color: var(--accent); font-weight: 600; }

/* Progress indicator */
.log-spinner::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Info box */
.info-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Result box */
.result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.7;
  max-height: 500px;
  overflow-y: auto;
}

/* Projects list */
.projects-list {
  max-height: 200px;
  overflow-y: auto;
}

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.project-item:last-child { border-bottom: none; }

.project-name { color: var(--text); font-weight: 500; }
.project-status { font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 10px; }
.project-status.created { background: var(--border); color: var(--text-dim); }
.project-status.ontology_generated { background: rgba(108,92,231,0.2); color: var(--accent); }
.project-status.graph_building { background: rgba(243,156,18,0.2); color: var(--warning); }
.project-status.graph_completed { background: rgba(0,184,148,0.2); color: var(--success); }
.project-status.failed { background: rgba(231,76,60,0.2); color: var(--error); }

.project-actions { display: flex; gap: 0.3rem; }
.project-actions .btn { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

.hidden { display: none !important; }

footer { text-align: center; margin-top: 2rem; color: var(--text-dim); font-size: 0.8rem; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .container { padding: 1rem; }
  h1 { font-size: 1.5rem; }
  .log-panel { max-height: 150px; }
}
