.profile-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.profile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.profile-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 600;
}

.profile-brand .brand-logo {
  height: 34px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.profile-topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-topnav a,
.profile-topnav-btn {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.profile-topnav a:hover,
.profile-topnav-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.profile-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  min-height: calc(100vh - 68px);
}

.profile-sidebar {
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #404040);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 14px;
  animation: scaleIn 0.45s ease both;
}

.profile-sidebar h1 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.profile-email {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}

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

.profile-nav-btn {
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.profile-nav-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.profile-nav-btn.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.profile-content {
  padding: 32px 28px 48px;
  animation: fadeInUp 0.5s ease both;
}

.profile-panel {
  display: none;
}

.profile-panel.active {
  display: block;
}

.profile-panel h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.profile-lead {
  margin: 0 0 22px;
  color: var(--text-secondary);
}

.profile-form {
  max-width: 480px;
  display: grid;
  gap: 14px;
}

.profile-form-divider {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.profile-form h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.btn {
  justify-self: start;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.profile-alert {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid var(--error-border);
  font-size: 0.9rem;
}

.profile-alert.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}

.profile-session-list {
  display: grid;
  gap: 8px;
  max-width: 640px;
}

.profile-template-list {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.profile-template-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
}

.profile-template-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.profile-template-title {
  margin: 0;
  font-size: 0.95rem;
}

.profile-template-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.profile-template-prompt {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.btn-link-danger {
  border: none;
  background: transparent;
  color: var(--error);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.btn-link-danger:hover {
  background: var(--error-soft);
}

.profile-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.profile-session-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.profile-session-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.profile-session-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.profile-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-width: 720px;
}

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

.usage-card-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-card-value {
  margin-top: 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.usage-card-bar {
  margin-top: 10px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  overflow: hidden;
}

.usage-card-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .profile-shell {
    grid-template-columns: 1fr;
  }

  .profile-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .profile-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
