@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #12161a;
  --surface: #1a1f25;
  --surface-raised: #20262d;
  --border: #2a3138;
  --text: #e8edf0;
  --text-muted: #8a97a3;
  --accent: #e8a33d;
  --accent-dim: #6b5228;
  --ok: #4fd1a5;
  --err: #e5636b;
  --radius: 8px;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --display: 'Space Grotesk', ui-sans-serif, sans-serif;
  --body: 'Inter', ui-sans-serif, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.035) 1px, transparent 0);
  background-size: 22px 22px;
}

a { color: var(--accent); }

button {
  font-family: var(--body);
  cursor: pointer;
}

::selection { background: var(--accent-dim); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), var(--bg));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dim));
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--bg);
}

.brand-text h1 {
  font-family: var(--display);
  font-size: 17px;
  margin: 0;
  letter-spacing: 0.02em;
}
.brand-text span {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s ease, transform .1s ease;
}
.btn:hover { border-color: #3a434c; }
.btn:active { transform: translateY(1px); }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1206;
  font-weight: 600;
}
.btn-accent:hover { filter: brightness(1.06); }
.btn-danger { color: var(--err); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: calc(100vh - 68px);
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  padding: 24px;
}
.panel-left {
  border-right: 1px solid var(--border);
}

.section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 14px;
}

/* ---------- Channel cards (calendar link list) ---------- */
.channels { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.channel-card:hover { border-color: #3a434c; }
.channel-card.active { border-color: var(--accent); background: var(--surface-raised); }

.channel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.channel-name { font-weight: 600; font-size: 14px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  position: relative;
}
.status-dot.ok { background: var(--ok); }
.status-dot.error { background: var(--err); }
.status-dot.ok::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--ok);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { opacity: .6; transform: scale(.7); }
  100% { opacity: 0; transform: scale(1.8); }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.ok::after { animation: none; display: none; }
}

.channel-url {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
  word-break: break-all;
}

.channel-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

input[type="text"], input[type="url"], input[type="password"], input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: var(--body);
}
input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.alert {
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(229,99,107,0.1); border-color: rgba(229,99,107,0.35); color: var(--err); }
.alert-ok { background: rgba(79,209,165,0.1); border-color: rgba(79,209,165,0.35); color: var(--ok); }

/* ---------- Copy chip ---------- */
.copy-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
.copy-chip code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
}

/* ---------- Detail / preview panel ---------- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 12px; }
.detail-title { font-family: var(--display); font-size: 20px; margin: 0 0 4px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--text-muted);
  padding: 9px 4px; margin-right: 18px;
  font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Calendar grid ---------- */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-header h3 { font-family: var(--display); font-size: 16px; margin: 0; }
.cal-nav { display: flex; gap: 6px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-day {
  min-height: 68px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: default;
}
.cal-day.outside { opacity: 0.35; }
.cal-day.today { border-color: var(--accent); }
.cal-day .daynum { font-family: var(--mono); font-size: 11px; color: var(--text); }
.cal-day .evt-dot-row { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.cal-day .evt-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-day.has-events { cursor: pointer; }
.cal-day.has-events:hover { border-color: #3a434c; }
.cal-day.selected { background: var(--surface-raised); border-color: var(--accent); }

.event-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.event-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
}
.event-item .evt-title { font-weight: 600; font-size: 13.5px; }
.event-item .evt-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.event-item .evt-loc { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.recur-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.placeholder {
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 40px 0;
  text-align: center;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8,10,12,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  width: 100%;
  max-width: 440px;
}
.modal h2 { font-family: var(--display); font-size: 16px; margin: 0 0 16px; }

.footer-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 18px 28px;
  border-top: 1px solid var(--border);
}
