@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --portal-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --portal-radius: 10px;
  --portal-radius-pill: 999px;
  --portal-input-h: 46px;
  --portal-sidebar-bg: #0a0a10;
  --portal-sidebar-text: #ffffff;
  --portal-sidebar-muted: rgba(255, 255, 255, 0.58);
  --portal-glass-bg: rgba(255, 255, 255, 0.06);
  --portal-glass-border: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] {
  --portal-main-bg: #ffffff;
  --portal-surface: #ffffff;
  --portal-text: #0a0a0a;
  --portal-muted: #6b7280;
  --portal-border: #e5e7eb;
  --portal-link: #2563eb;
  --portal-control-bg: #f9fafb;
  --portal-svc-bg: #fafafa;
  --portal-svc-hover: #f3f4f6;
  --portal-code-bg: #f3f4f6;
  --portal-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --portal-seg-active-bg: #0a0a0a;
  --portal-seg-active-text: #ffffff;
  --portal-input-bg: #ffffff;
  --portal-btn-primary-bg: #0a0a0a;
  --portal-btn-primary-hover: #262626;
}

[data-theme="dark"] {
  --portal-main-bg: #0f1219;
  --portal-surface: #161b28;
  --portal-text: #e8eefc;
  --portal-muted: #9aa8c4;
  --portal-border: rgba(120, 160, 220, 0.18);
  --portal-link: #7aa7ff;
  --portal-control-bg: rgba(255, 255, 255, 0.06);
  --portal-svc-bg: rgba(255, 255, 255, 0.04);
  --portal-svc-hover: rgba(91, 140, 255, 0.1);
  --portal-code-bg: rgba(255, 255, 255, 0.08);
  --portal-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  --portal-seg-active-bg: #ffffff;
  --portal-seg-active-text: #0a0a0a;
  --portal-input-bg: rgba(5, 8, 14, 0.55);
  --portal-btn-primary-bg: #ffffff;
  --portal-btn-primary-hover: #e5e7eb;
}

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

html,
body.portal-page {
  margin: 0;
  min-height: 100%;
  font-family: var(--portal-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.portal-boot .portal-shell {
  visibility: hidden;
}

.hidden {
  display: none !important;
}

.portal-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

.portal-sidebar {
  position: relative;
  flex: 0 0 42%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 4vh, 2.75rem) clamp(1.25rem, 3.5vw, 3rem);
  color: var(--portal-sidebar-text);
  background: var(--portal-sidebar-bg);
  overflow: hidden;
  isolation: isolate;
}

.portal-sidebar::after {
  content: "";
  position: absolute;
  inset: -45%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 42% at 30% 28%, rgba(99, 130, 210, 0.5) 0%, transparent 58%),
    radial-gradient(ellipse 48% 46% at 72% 68%, rgba(72, 88, 160, 0.45) 0%, transparent 56%),
    radial-gradient(ellipse 38% 32% at 52% 48%, rgba(140, 120, 210, 0.22) 0%, transparent 62%),
    linear-gradient(145deg, rgba(18, 22, 36, 0.9) 0%, rgba(10, 10, 16, 0.4) 100%);
  animation: portal-gradient-flow 24s ease-in-out infinite alternate;
}

@keyframes portal-gradient-flow {
  0% {
    transform: translate(0%, 0%) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(-5%, 6%) rotate(4deg) scale(1.06);
  }
  100% {
    transform: translate(6%, -4%) rotate(-3deg) scale(1.08);
  }
}

.portal-sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.36;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  mix-blend-mode: overlay;
}

.portal-brand-top {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.portal-logo {
  display: block;
  line-height: 0;
  text-decoration: none;
}

.portal-logo img {
  display: block;
  height: 28px;
  width: auto;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  height: 1.5rem;
  padding: 0 0.72rem;
  border: 1px solid var(--portal-glass-border);
  border-radius: var(--portal-radius-pill);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--portal-sidebar-muted);
  background: var(--portal-glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.portal-hero {
  position: relative;
  z-index: 2;
  margin-top: auto;
  padding-top: 2rem;
  max-width: 22rem;
}

.portal-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 2.2vh, 1.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.portal-hero p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--portal-sidebar-muted);
}

.portal-hero strong {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.portal-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--portal-main-bg);
  color: var(--portal-text);
}

.portal-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem clamp(1.25rem, 3vw, 2.25rem);
  border-bottom: 1px solid var(--portal-border);
  background: var(--portal-surface);
}

.portal-topbar__user {
  min-width: 0;
}

.portal-topbar__user h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.portal-topbar__email {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.84rem;
  color: var(--portal-muted);
  word-break: break-all;
}

.portal-topbar__date {
  font-size: 0.8rem;
  color: var(--portal-muted);
}

.portal-topbar__date strong {
  color: var(--portal-text);
  font-weight: 600;
}

.portal-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.portal-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-pill);
  background: var(--portal-control-bg);
}

.portal-lang__btn,
.portal-theme__btn {
  border: none;
  background: transparent;
  padding: 0.32rem 0.62rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--portal-muted);
  border-radius: var(--portal-radius-pill);
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.portal-lang__btn:hover,
.portal-theme__btn:hover {
  color: var(--portal-text);
}

.portal-lang__btn.is-active,
.portal-theme__btn.is-active {
  background: var(--portal-seg-active-bg);
  color: var(--portal-seg-active-text);
}

.portal-lang__btn:focus-visible,
.portal-theme__btn:focus-visible {
  outline: 2px solid var(--portal-link);
  outline-offset: 2px;
}

.portal-btn-logout {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: transparent;
  color: var(--portal-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.portal-content {
  flex: 1 1 auto;
  padding: clamp(1.15rem, 3vw, 2rem) clamp(1.25rem, 3vw, 2.25rem) 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.portal-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: clamp(1.15rem, 2.5vw, 1.5rem);
  box-shadow: var(--portal-shadow);
}

.portal-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-card .portal-lead {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--portal-muted);
}

.portal-card .portal-lead code {
  font-size: 0.82em;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  background: var(--portal-code-bg);
  color: var(--portal-text);
}

.portal-field {
  margin-bottom: 0.85rem;
}

.portal-field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--portal-muted);
}

.portal-field input {
  width: 100%;
  max-width: 360px;
  height: var(--portal-input-h);
  padding: 0 0.9rem;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  font: inherit;
  font-size: 0.9rem;
  color: var(--portal-text);
  background: var(--portal-input-bg, var(--portal-surface));
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.portal-field input:focus-visible {
  border-color: #737373;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.portal-btn-primary {
  padding: 0.7rem 1.15rem;
  border: none;
  border-radius: var(--portal-radius);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--portal-seg-active-text);
  background: var(--portal-btn-primary-bg);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

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

[data-theme="dark"] .portal-btn-primary {
  color: #0a0a0a;
}

.portal-btn-primary:active {
  transform: translateY(1px);
}

.portal-msg {
  margin-top: 0.65rem;
  min-height: 1.15rem;
  font-size: 0.82rem;
  text-align: center;
  color: #dc2626;
}

.portal-msg.ok {
  color: #16a34a;
}

.portal-services {
  display: grid;
  gap: 0.65rem;
}

@media (min-width: 560px) {
  .portal-services {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .portal-services {
    grid-template-columns: repeat(2, 1fr);
  }
}

.portal-svc {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: var(--portal-svc-bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.portal-svc:hover {
  border-color: #d1d5db;
  background: var(--portal-svc-hover);
  box-shadow: var(--portal-shadow);
}

.portal-svc:focus-visible {
  outline: 2px solid var(--portal-link);
  outline-offset: 2px;
}

.portal-svc__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--portal-text);
}

.portal-svc__desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--portal-muted);
}

.portal-svc__host {
  margin-top: 0.15rem;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--portal-link);
}

.portal-footer {
  padding: 1rem clamp(1.25rem, 3vw, 2.25rem) 1.5rem;
  font-size: 0.76rem;
  color: var(--portal-muted);
  text-align: center;
  border-top: 1px solid var(--portal-border);
  background: var(--portal-surface);
}

@media (max-width: 960px) {
  .portal-shell {
    flex-direction: column;
  }

  .portal-sidebar {
    flex: none;
    max-width: none;
    min-height: auto;
    padding: 1.15rem 1.25rem 1.35rem;
  }

  .portal-hero {
    margin-top: 1.25rem;
    padding-top: 0;
  }

  .portal-hero h1 {
    text-align: center;
  }

  .portal-hero p {
    text-align: center;
  }

  .portal-brand-top {
    justify-content: center;
  }

  .portal-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-controls {
    justify-content: center;
  }

  .portal-topbar__date {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-sidebar::after {
    animation: none;
  }
}
