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

:root {
  --coral: #f97066;
  --coral-light: #fecaca;
  --coral-dark: #e85a4f;
  --bg: #fafafa;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ---- Login View ---- */
.view {
  min-height: 100vh;
}

#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(249, 112, 102, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(249, 112, 102, 0.05) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 44px 48px;
  max-width: 440px;
  width: 100%;
  margin: 20px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease-out;
}

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

.login-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.login-card > p {
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 36px;
  font-size: 15px;
}

.signin-btn {
  display: inline-block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: 8px;
}

.signin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.signin-btn:active {
  transform: translateY(0);
}

.status-text {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.source-link {
  display: block;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.source-link:hover {
  color: var(--coral-dark);
}

/* ---- Loading View ---- */
#view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--bg);
}

.loading-card {
  text-align: center;
  animation: fadeUp 0.3s ease-out;
}

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

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

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

/* ---- Dashboard ---- */
#view-dashboard {
  min-height: 100vh;
  background: var(--bg);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dashboard-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-dot {
  width: 8px;
  height: 8px;
  background: var(--coral);
  border-radius: 50%;
  display: inline-block;
}

.logout-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #d1d5db;
}

.dashboard-main {
  max-width: 640px;
  margin: 28px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 48px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

/* ---- Profile Card ---- */
.profile-card {
  padding: 28px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 3px solid var(--card-bg);
  box-shadow: 0 0 0 2px var(--coral-light), var(--shadow);
}

.profile-info h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.username {
  color: var(--coral-dark);
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

.email {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.bio {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
  font-size: 14px;
}

.bio:empty {
  display: none;
}

.profile-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.meta-item {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.meta-item:empty {
  display: none;
}

.social-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.social-links a {
  font-size: 12px;
  font-weight: 500;
  color: var(--coral-dark);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--coral-light);
  transition: background 0.15s ease, color 0.15s ease;
}

.social-links a:hover {
  background: var(--coral);
  color: white;
}

/* ---- Badges ---- */
.badges-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.badge-tier-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-tier-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.badge-tier-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 20px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.badge-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.badge-chip-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.badge-chip-emoji {
  font-size: 16px;
  line-height: 1;
}

.badge-chip-name {
  white-space: nowrap;
}

/* ---- Achievements ---- */
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.achievement-item:hover {
  border-color: var(--border);
}

.achievement-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.achievement-info {
  flex: 1;
  min-width: 0;
}

.achievement-info strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.achievement-info span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.achievement-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.achievement-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--coral-dark));
  border-radius: 2px;
  transition: width 0.5s ease-out;
}

.achievement-complete {
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  background: #f0fdf4;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---- Portfolio ---- */
.portfolio-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portfolio-item {
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.portfolio-item:hover {
  border-color: var(--border);
}

.portfolio-item h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.portfolio-item h4 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.portfolio-item h4 a:hover {
  color: var(--coral-dark);
}

.portfolio-item p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- Linked Accounts ---- */
.linked-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.linked-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.linked-account:hover {
  border-color: var(--border);
}

.linked-account .provider-icon {
  width: 32px;
  height: 32px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.linked-account .provider {
  font-weight: 600;
  text-transform: capitalize;
  font-size: 14px;
}

.linked-account .provider-detail {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- Placeholder ---- */
.placeholder {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  padding: 12px 0;
}

/* ---- Error Toast ---- */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Mobile Responsive ---- */
@media (max-width: 640px) {
  .login-card {
    padding: 40px 24px 36px;
    margin: 16px;
    border-radius: 12px;
  }

  .login-card h1 {
    font-size: 22px;
  }

  .login-card > p {
    font-size: 14px;
    margin-bottom: 28px;
  }

  .dashboard-header {
    padding: 12px 16px;
  }

  .dashboard-header h1 {
    font-size: 16px;
  }

  .dashboard-main {
    margin: 16px auto;
    padding: 0 12px;
    gap: 12px;
  }

  .card {
    padding: 18px;
    border-radius: 12px;
  }

  .profile-card {
    padding: 20px;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .avatar {
    width: 64px;
    height: 64px;
  }

  .profile-info h2 {
    font-size: 20px;
  }

  .profile-meta {
    justify-content: center;
  }

  .social-links {
    justify-content: center;
  }

  .badge-tier-badges {
    justify-content: flex-start;
  }

  .badge-chip {
    padding: 5px 10px 5px 6px;
    font-size: 12px;
    gap: 5px;
  }

  .badge-chip-icon {
    width: 18px;
    height: 18px;
  }

  .badge-chip-emoji {
    font-size: 14px;
  }

  .achievement-item {
    padding: 12px;
    gap: 10px;
  }

  .achievement-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .achievement-info strong {
    font-size: 13px;
  }

  .achievement-info span {
    font-size: 11px;
  }

  .achievement-complete {
    font-size: 10px;
    padding: 2px 8px;
  }

  .portfolio-item {
    padding: 12px;
  }

  .portfolio-item h4 {
    font-size: 13px;
  }

  .portfolio-item p {
    font-size: 12px;
  }

  .linked-account {
    padding: 10px 12px;
    font-size: 13px;
  }

  .linked-account .provider-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .linked-account .provider {
    font-size: 13px;
  }

  .linked-account .provider-detail {
    font-size: 12px;
  }

  .error-toast {
    bottom: 16px;
    padding: 10px 20px;
    font-size: 13px;
    border-radius: 10px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .login-card {
    padding: 32px 20px 28px;
  }

  .badge-chip {
    padding: 4px 8px 4px 5px;
    font-size: 11px;
    gap: 4px;
  }

  .badge-chip-icon {
    width: 16px;
    height: 16px;
  }

  .badge-chip-emoji {
    font-size: 12px;
  }
}
