:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text: #e0e0e0;
  --text-dim: #8a8a9a;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: #2a2a3e;
  --radius: 8px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.shell { display: flex; min-height: 100vh; }

nav.sidebar {
  width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
}

nav.sidebar .brand {
  padding: 0 1.25rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

nav.sidebar a {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  transition: all 0.15s;
}

nav.sidebar a:hover,
nav.sidebar a.active {
  color: var(--text);
  background: rgba(233, 69, 96, 0.1);
  border-left: 3px solid var(--accent);
}

nav.sidebar .spacer { flex: 1; }

main.content {
  flex: 1;
  margin-left: 220px;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

h1 { font-size: 1.6rem; margin-bottom: 1.5rem; font-weight: 600; }
h2 { font-size: 1.2rem; margin-bottom: 1rem; font-weight: 600; }

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

.card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-danger  { background: rgba(231,76,60,0.15);  color: var(--danger); }
.badge-warning { background: rgba(243,156,18,0.15); color: var(--warning); }
.badge-info    { background: rgba(233,69,96,0.15);  color: var(--accent); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td { padding: 0.6rem 0.75rem; text-align: left; }
th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
tr { border-bottom: 1px solid var(--border); }
tr:hover { background: rgba(255,255,255,0.02); }

/* Forms */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

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

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

textarea { resize: vertical; min-height: 100px; font-family: monospace; }

input[type="color"] {
  width: 50px;
  height: 36px;
  padding: 2px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

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

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}
.btn-danger:hover { background: rgba(231,76,60,0.15); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

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

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-success { background: rgba(46,204,113,0.1); border: 1px solid rgba(46,204,113,0.3); color: var(--success); }
.alert-danger  { background: rgba(231,76,60,0.1);  border: 1px solid rgba(231,76,60,0.3);  color: var(--danger); }
.alert-warning { background: rgba(243,156,18,0.1); border: 1px solid rgba(243,156,18,0.3); color: var(--warning); }

/* Log output */
pre.log {
  background: #0a0a14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: "Fira Code", "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}
.status-dot.idle    { background: var(--text-dim); }
.status-dot.running { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot.success { background: var(--success); }
.status-dot.failed  { background: var(--danger); }

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

/* Draft preview */
.draft-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.draft-card img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
}

.draft-copy { font-size: 0.85rem; }
.draft-copy h4 { margin-bottom: 0.5rem; color: var(--accent); }
.draft-copy pre {
  background: var(--bg-input);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* Auth pages */
.auth-container {
  max-width: 380px;
  margin: 10vh auto;
  padding: 2rem;
}

.auth-container h1 {
  text-align: center;
  color: var(--accent);
}

.auth-container .btn { width: 100%; }

/* Secrets table */
.secret-row {
  display: grid;
  grid-template-columns: 200px 1fr 80px;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.5rem;
}

.secret-row input { margin-bottom: 0; }

/* Channel cards (draft preview) */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.channel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  border-bottom: 1px solid var(--border);
}

.channel-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.channel-body {
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Draft summary cards (run detail) */
.draft-summary {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  transition: border-color 0.15s;
  text-decoration: none;
  color: var(--text);
}

.draft-summary:hover {
  border-color: var(--accent);
  color: var(--text);
}

.draft-summary img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
}

.draft-summary .draft-meta h4 {
  margin-bottom: 0.3rem;
  color: var(--text);
}

.draft-summary .draft-meta p {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0;
}

/* Custom run form tabs */
.mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mode-tabs label {
  flex: 1;
  padding: 0.6rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0;
  transition: all 0.15s;
}

.mode-tabs label:last-child { border-right: none; }

.mode-tabs input[type="radio"] { display: none; }
.mode-tabs input[type="radio"]:checked + label {
  background: var(--accent);
  color: #fff;
}

.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* Responsive basics */
@media (max-width: 768px) {
  nav.sidebar { display: none; }
  main.content { margin-left: 0; padding: 1rem; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .draft-card { grid-template-columns: 1fr; }
  .channel-grid { grid-template-columns: 1fr; }
  .draft-summary { grid-template-columns: 80px 1fr; }
}
