:root {
  --bg: #0a0a12;
  --bg-soft: #0f0f1a;
  --card: #14141f;
  --card-border: rgba(255, 255, 255, 0.07);
  --text: #f1f1f6;
  --muted: #8b8b9e;
  --accent-a: #7c3aed;
  --accent-b: #06b6d4;
  --green: #22c55e;
  --green-dark: #16a34a;
  --red: #ef4444;
  --red-dark: #dc2626;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(6, 182, 212, 0.14), transparent 55%),
    var(--bg);
}

.hidden { display: none !important; }

/* ---------- Gate ---------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(10px);
}

.gate-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: white;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}

.logo-icon {
  width: 60%;
  height: 60%;
}

.gate h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.gate input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.gate input:focus { border-color: var(--accent-b); }

.gate-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}

/* ---------- App shell ---------- */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: white;
  flex-shrink: 0;
}

.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; }
.topbar .muted { margin: 2px 0 0; font-size: 13px; }

/* ---------- Tab switcher ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 6px;
  cursor: pointer;
  position: relative;
  margin-right: 18px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); }
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
}

/* ---------- Grid of channel cards: one channel per row, full width ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.01));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--card-border);
}

.card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  flex-shrink: 0;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.card-header .tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--card-border);
  padding: 3px 8px;
  border-radius: 999px;
}

.row {
  display: grid;
  grid-template-columns: 170px 160px 1fr 300px;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
}
.row:last-child { border-bottom: none; }

.row-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.row-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.row-date {
  font-size: 11px;
  color: var(--muted);
}

.handle-chip {
  justify-self: start;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(34, 197, 94, 0.16));
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #eafff2;
  font-family: "Inter", monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.handle-chip:hover {
  border-color: var(--green);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.28), rgba(34, 197, 94, 0.28));
}
.handle-chip:active { transform: translateY(1px); }
.handle-chip.copied {
  border-color: var(--green);
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}

.row-open {
  grid-template-columns: 170px 1fr 160px;
}

.link-chip {
  justify-self: stretch;
  width: 100%;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--card-border);
  color: var(--blue);
}
.link-chip:hover { border-color: var(--blue); background: rgba(59, 130, 246, 0.08); }
.link-chip:disabled {
  color: var(--muted);
  cursor: default;
}
.link-chip:disabled:hover { border-color: var(--card-border); background: rgba(255, 255, 255, 0.04); }

.row input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.row input[type="text"]:focus { border-color: var(--accent-b); background: rgba(255,255,255,0.05); }
.row input[type="text"].has-link { border-color: rgba(34, 197, 94, 0.4); }
.row input[type="text"].saving {
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(234, 179, 8, 0.06);
}

.row-actions {
  display: flex;
  gap: 10px;
}

.row-actions .btn {
  flex: 1;
  text-align: center;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.btn-block { width: 100%; padding: 11px 14px; font-size: 14px; }

.btn-primary { background: linear-gradient(135deg, var(--accent-a), var(--accent-b)); }

.btn-save { background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.btn-clear { background: linear-gradient(135deg, var(--red), var(--red-dark)); }
.btn-open { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); }
.btn-danger { background: linear-gradient(135deg, var(--red), var(--red-dark)); padding: 10px 18px; }
.btn-save-all { background: linear-gradient(135deg, var(--green), var(--green-dark)); padding: 10px 18px; }

.topbar-actions {
  display: flex;
  gap: 12px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(34, 197, 94, 0.5); }
.toast.error { border-color: rgba(239, 68, 68, 0.5); }

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
}
