:root {
  --blue: #2563eb;
  --blue-soft: #60a5fa;
  --bg: #eef3ff;
  --card: rgba(255,255,255,.85);
  --text: #0f172a;
  --muted: #64748b;
  --radius: 22px;
  --danger: #ef4444;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

a, button {
  -webkit-tap-highlight-color: transparent;
}

.kubbuk-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: inline-block;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, var(--bg), #fff);
  overflow-x: hidden;
  overflow-y: auto;
}

canvas#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.card {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--card);
  backdrop-filter: blur(18px);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 30px 60px rgba(37,99,235,.25);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeUp .5s ease-out;
}

.card::-webkit-scrollbar {
  width: 0px;
}

@media (min-width: 768px) {
  .container {
    padding: 32px;
    align-items: center;
  }

  .card {
    max-width: 420px;
    max-height: 90vh;
    padding: 30px;
    gap: 22px;
  }
}

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

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

.profile {
  text-align: center;
}

.avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--blue), var(--blue-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 15px 30px rgba(37,99,235,.4);
  cursor: pointer;
  transition: transform 0.2s;
}

.avatar:hover {
    transform: scale(1.05);
}

.avatar img {
    width: 60%;
    height: 60%;
    object-fit: contain;
}

.profile h1 {
  margin: 0;
  color: var(--text);
}

.profile p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}


/* Empty state */
#links:empty::after {
  display: block;
  content: '';
}

.link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fbff, #eaf1ff);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(37,99,235,.15);
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
  margin: 0 8px 12px 8px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.link-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
}

.link-content:visited {
    color: inherit;
}

.link-content:focus,
.link-content:focus-visible {
    outline: none;
}

.link-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.link-icon {
    font-size: 20px;
    width: 30px;
    text-align: center;
}

.link-icon .fa-instagram { color: #E1306C; }
.link-icon .fa-facebook { color: #1877F2; }
.link-icon .fa-twitter { color: #1DA1F2; }
.link-icon .fa-linkedin { color: #0A66C2; }
.link-icon .fa-github { color: #181717; }
.link-icon .fa-youtube { color: #FF0000; }
.link-icon .fa-tiktok { color: #000000; }
.link-icon .fa-whatsapp { color: #25D366; }
.link-icon .fa-telegram { color: #0088cc; }
.link-icon .fa-discord { color: #5865F2; }
.link-icon .fa-spotify { color: #1DB954; }
.link-icon .fa-twitch { color: #9146FF; }
.link-icon .fa-pinterest { color: #E60023; }
.link-icon .fa-reddit { color: #FF4500; }
.link-icon .fa-snapchat { color: #FFFC00; }
.link-icon .fa-medium { color: #000000; }
.link-icon .fa-vimeo { color: #1ab7ea; }
.link-icon .fa-behance { color: #1769ff; }
.link-icon .fa-dribbble { color: #ea4c89; }
.link-icon .fa-fan { color: #00AFF0; }
.link-icon .fa-globe { color: var(--blue); }

.link-icon .kubbuk-icon {
    width: 20px;
    height: 20px;
}

.link-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.link-title {
    font-size: 16px;
    font-weight: 600;
}

.link-url {
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 0 15px;
    white-space: nowrap;
}

.drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 16px;
    padding-right: 10px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.drag-handle:hover {
    opacity: 1;
}

@media (hover: hover) {
  .link:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px rgba(37,99,235,.35);
  }
}

.link-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--muted);
    padding: 5px;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--blue);
}

.btn-icon.delete:hover {
    color: var(--danger);
}

.link.dragging {
    opacity: 0.5;
    transform: scale(0.98);
    box-shadow: 0 5px 15px rgba(37,99,235,0.1);
}

.link.drag-over {
    border: 2px dashed var(--blue);
}

.legal {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.05);
  width: 100%;
  display: block;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.05);
}

.actions button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.5);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.actions button:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.actions button.primary-action {
    background: var(--blue);
    color: white;
    box-shadow: 0 4px 12px rgba(37,99,235,0.2);
}

.actions button.primary-action:hover {
    background: var(--blue-soft);
    box-shadow: 0 6px 16px rgba(37,99,235,0.3);
}

.actions button.primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-soft));
    color: white;
    box-shadow: 0 4px 12px rgba(37,99,235,0.25);
    border: 1px solid rgba(255,255,255,0.1);
}

.actions button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37,99,235,0.35);
    filter: brightness(1.05);
    background: linear-gradient(135deg, var(--blue), var(--blue-soft));
}

.actions button.danger-action {
    color: white;
    background: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.actions button.danger-action:hover {
    background: #f87171;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3);
}

button {
  background: none;
  border: none;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  padding: 10px;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
    background: rgba(37,99,235,0.08);
}

button.primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-soft));
    color: white;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.25);
    border: 1px solid rgba(255,255,255,0.1);
}

button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37,99,235,0.35);
    filter: brightness(1.05);
}

button.primary:active {
    transform: translateY(0);
}

/* Share Button Green */
.actions button.share-action {
    color: white;
    background: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.actions button.share-action:hover {
    background: #34d399;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px;
}

.icon-option {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f1f5f9;
    cursor: pointer;
    font-size: 18px;
    color: var(--muted);
    transition: all 0.2s;
}

.icon-option:hover, .icon-option.selected {
    background: var(--blue);
    color: white;
    transform: scale(1.1);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.5);
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
}

input:focus {
    border-color: var(--blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-overlay.active {
    display: flex;
    opacity: 1;
}
.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s;
}
.modal-overlay.active .modal-content {
    transform: translateY(0);
}
.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
}

.show-more-btn {
    width: 100%;
    margin-top: 15px;
    background: linear-gradient(135deg, var(--blue), var(--blue-soft));
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 12px rgba(37,99,235,0.25);
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    z-index: 10;
}

.show-more-btn:hover, 
.show-more-btn:focus, 
.show-more-btn:active, 
.show-more-btn:visited {
    background: linear-gradient(135deg, var(--blue), var(--blue-soft));
    color: white;
}

@media (hover: hover) {
    .show-more-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(37,99,235,0.35);
        filter: brightness(1.05);
    }
}

.show-more-btn:active {
    transform: scale(0.98);
}

/* ======================= HIDDEN LINKS TRANSITION ======================= */
.hidden-links-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    opacity: 0;
    transition:
        grid-template-rows 0.3s ease-out,
        opacity 0.25s ease-out;
}

.hidden-links-wrapper.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
    transition:
        grid-template-rows 0.3s ease-out,
        opacity 0.2s ease-in;
}

.hidden-links-content {
    min-height: 0;
    width: 100%;
    padding-bottom: 4px;
}

/* Aparición escalonada de cada link al expandir */
.hidden-links-wrapper.expanded .hidden-links-content .link {
    animation: linkReveal 0.28s ease-out both;
}
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(1) { animation-delay: 0.07s; }
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(2) { animation-delay: 0.12s; }
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(3) { animation-delay: 0.17s; }
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(4) { animation-delay: 0.22s; }
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(5) { animation-delay: 0.27s; }
.hidden-links-wrapper.expanded .hidden-links-content .link:nth-child(n+6) { animation-delay: 0.3s; }
