:root {
  --bg-main: #0b0f0e;
  --bg-surface: #131917;
  --bg-card: #161e1b;
  --bg-input: #1a2420;
  --border-color: #232d28;
  --border-focus: #10b981;
  --text-main: #f3f7f5;
  --text-muted: #889991;
  --text-dim: #5c6b64;
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.25);
  --accent-hover: #059669;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

[hidden] {
  display: none !important;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TYPOGRAPHY & BRANDING
   ========================================================================== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: #ffffff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: #0b0f0e;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-icon svg {
  stroke: #0b0f0e;
}

.highlight {
  color: var(--accent);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

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

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
button, input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
}

input, textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

label:first-child {
  margin-top: 0;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

button.primary {
  background: var(--accent);
  color: #0b0f0e;
}

button.primary:hover:not(:disabled) {
  background: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

button.secondary {
  background: #202a25;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

button.secondary:hover:not(:disabled) {
  background: #2a3832;
  border-color: #3b4d45;
}

button.text-button {
  background: transparent;
  color: var(--accent);
  padding: 6px 10px;
}

button.text-button:hover:not(:disabled) {
  color: #34d399;
  text-decoration: underline;
}

button.full {
  width: 100%;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-action {
  display: flex;
  gap: 8px;
}

.input-action input, .input-action select {
  flex: 1;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 14px 0;
  user-select: none;
}

.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
}

/* ==========================================================================
   LOADING SCREEN
   ========================================================================== */
.session-loading {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 12px;
}

.loading-icon-wrapper {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-monogram {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.glow-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

.session-loading strong {
  font-size: 22px;
  font-family: var(--font-display);
}

.session-loading p {
  color: var(--text-muted);
  font-size: 13px;
}

.loading-line {
  width: 140px;
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.loading-line::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: loadline 1.2s infinite ease-in-out;
}

@keyframes loadline {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

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

/* ==========================================================================
   PUBLIC GUEST HERO & HOME
   ========================================================================== */
.public-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-auth-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.public-main {
  max-width: 760px;
  margin: 40px auto 80px;
  padding: 0 20px;
  text-align: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 20px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.hero-heading {
  font-size: 54px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}

.hero-heading em {
  font-style: italic;
  color: var(--accent);
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.public-lead {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 36px;
}

.public-shortener {
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid #28332e;
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
}

.result-box {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.public-benefits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 48px;
  text-align: left;
}

.benefit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
}

.benefit-card:hover {
  border-color: #3b4d45;
  transform: translateY(-2px);
}

.benefit-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  display: block;
}

.benefit-card h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.benefit-card p {
  font-size: 13px;
  color: var(--text-muted);
}

.public-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 13px;
}

/* ==========================================================================
   AUTH SCREEN (LOGIN / SETUP)
   ========================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-story {
  background: linear-gradient(145deg, #101614 0%, #0b0f0e 100%);
  border-right: 1px solid var(--border-color);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.story-main {
  max-width: 440px;
}

.story-main h1 {
  font-size: 44px;
  line-height: 1.1;
  margin-bottom: 16px;
}

.story-main h1 em {
  color: var(--accent);
}

.story-main p {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.link-art {
  background: #151d19;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: monospace;
  font-size: 15px;
}

.link-art strong {
  color: var(--accent);
}

.link-art b {
  color: #fff;
}

.link-art i {
  margin-left: 8px;
  color: var(--accent);
  font-style: normal;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
}

.back-btn {
  margin-bottom: 20px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  margin-bottom: 24px;
}

.auth-tabs button {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  font-size: 13px;
}

.auth-tabs button.active {
  background: var(--bg-card);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.auth-foot {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ==========================================================================
   APP SHELL / WORKSPACE
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-caption {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-top: 28px;
  margin-bottom: 10px;
  padding-left: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.nav-item:hover {
  background: var(--bg-card);
  color: #fff;
}

.nav-item.active {
  background: #1b2621;
  color: var(--accent);
  font-weight: 600;
}

.nav-item b {
  margin-left: auto;
  background: #25332c;
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.version {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  padding-left: 4px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0f0e;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.account strong {
  display: block;
  font-size: 13px;
  color: #fff;
}

.account small {
  color: var(--text-dim);
  font-size: 11px;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main-content {
  padding: 28px 40px 100px;
  max-width: 1200px;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb strong {
  color: #fff;
}

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

.domain-chip {
  background: #18221d;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--accent);
  font-family: monospace;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-heading h1 {
  font-size: 32px;
  line-height: 1.15;
}

/* Quick Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.stat-box span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 26px;
  font-family: var(--font-display);
  color: #fff;
}

.stat-word {
  color: var(--accent) !important;
}

/* Live Clicks */
.live-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
  0% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.4; transform: scale(0.9); }
}

.live-feed-list {
  margin-top: 14px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.link-row:hover {
  border-color: #3b4d45;
}

.link-icon {
  font-size: 16px;
  color: var(--accent);
}

.link-info {
  flex: 1;
  overflow: hidden;
}

.link-info strong {
  display: block;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-info small {
  font-size: 12px;
  color: var(--text-dim);
  font-family: monospace;
}

.badge {
  font-size: 11px;
  background: #1d2722;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.new-click {
  border-color: var(--accent);
  animation: flash 1s ease;
}

@keyframes flash {
  0% { background: rgba(16, 185, 129, 0.15); }
  100% { background: var(--bg-input); }
}

/* ==========================================================================
   LINK LIBRARY
   ========================================================================== */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.filters-inline {
  display: flex;
  gap: 10px;
  width: 60%;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 13px;
}

.advanced-load {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.advanced-load select {
  margin-top: 8px;
}

/* ==========================================================================
   EDITOR GRID
   ========================================================================== */
.editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 18px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.step {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.slug-field {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.slug-field span {
  padding: 10px 12px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-dim);
  background: #151d19;
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
}

.slug-field input {
  border: none;
  background: transparent;
  border-radius: 0;
}

.upload-label {
  display: block;
  cursor: pointer;
}

.upload-label small {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
}

/* Social Preview Card */
.social-preview-mock {
  background: #1a221f;
  border: 1px solid #293630;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1200 / 630;
  background: #111714;
  overflow: hidden;
}

.cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-dim);
}

.cover-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-copy {
  padding: 16px;
}

.preview-copy small {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.preview-copy h3 {
  font-size: 16px;
  line-height: 1.3;
  margin-bottom: 6px;
}

.preview-copy p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.preview-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
}

.share-card a {
  display: block;
  color: var(--accent);
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 10px 0;
  text-decoration: none;
}

.storage-note {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.storage-note strong {
  color: #fff;
  display: block;
  margin-bottom: 4px;
}

/* Save Bar */
.save-bar {
  position: sticky;
  bottom: 16px;
  background: #131b17;
  border: 1px solid #293830;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.6);
  z-index: 100;
}

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

/* Targeting Rule */
.rule {
  margin-top: 12px;
  border-color: #2b3932;
  background: #151d19;
}

.rule .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.small-actions {
  display: flex;
  gap: 6px;
}

.small-actions button {
  padding: 4px 10px;
  font-size: 12px;
  background: #1f2a24;
  border: 1px solid var(--border-color);
}

.danger-btn {
  color: var(--danger) !important;
}

/* Users Grid */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.user-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Toast Status */
.toast-status {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #151d19;
  border: 1px solid var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 24px rgba(0,0,0,0.6);
  z-index: 2000;
  font-size: 13px;
  animation: slideUp 0.2s ease;
}

.toast-status[data-error="true"] {
  border-color: var(--danger);
  color: #fca5a5;
}

.toast-status:empty {
  display: none;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dialog */
dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 24px;
  max-width: 420px;
  width: 90%;
  margin: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

dialog::backdrop {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
}

/* Responsive */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .editor-grid { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { display: none; }
  .public-benefits { grid-template-columns: 1fr; }
}
