:root {
  color-scheme: light;
  --bg: #f3f7f8;
  --bg-soft: #edf3f5;
  --surface: rgba(252, 253, 249, 0.86);
  --surface-strong: #fffffb;
  --text: #172026;
  --muted: #6f7b84;
  --muted-strong: #40505a;
  --line: rgba(58, 77, 88, 0.14);
  --accent: #5c8fa8;
  --accent-strong: #2f647f;
  --accent-soft: rgba(92, 143, 168, 0.16);
  --green: #4f7d68;
  --shadow: 0 24px 70px rgba(55, 76, 88, 0.13);
  --radius-lg: 26px;
  --radius-md: 18px;
  --font: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #020305;
  --bg-soft: #080a0d;
  --surface: rgba(12, 14, 18, 0.88);
  --surface-strong: #101319;
  --text: #f5f7fa;
  --muted: #89929d;
  --muted-strong: #c8d0d8;
  --line: rgba(245, 247, 250, 0.13);
  --accent: #7db8d6;
  --accent-strong: #a8d8ef;
  --accent-soft: rgba(125, 184, 214, 0.16);
  --green: #95d1b4;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(92, 143, 168, 0.12) 0 18%, transparent 18% 100%),
    linear-gradient(300deg, rgba(82, 113, 128, 0.1) 0 16%, transparent 16% 100%),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(120deg, rgba(125, 184, 214, 0.08) 0 18%, transparent 18% 100%),
    linear-gradient(300deg, rgba(255, 255, 255, 0.035) 0 16%, transparent 16% 100%),
    linear-gradient(135deg, #020305, #07090c 55%, #010101);
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent 46%),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

:root[data-theme="dark"] .hero {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 46%),
    var(--surface);
}

.hero::before {
  position: absolute;
  content: "";
  pointer-events: none;
}

.hero::before {
  right: -72px;
  bottom: -120px;
  width: 420px;
  height: 260px;
  transform: rotate(-12deg);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%);
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--accent-strong);
  background: var(--surface-strong);
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: 0 12px 28px rgba(55, 76, 88, 0.1);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 6px 7px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34)),
    var(--surface);
  box-shadow: 0 14px 34px rgba(55, 76, 88, 0.12);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(92, 143, 168, 0.42);
  box-shadow: 0 18px 42px rgba(55, 76, 88, 0.16);
}

.theme-toggle:focus-visible {
  outline: 0;
}

:root[data-theme="dark"] .theme-toggle {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    var(--surface);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
}

.theme-toggle__text {
  color: var(--muted-strong);
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.theme-toggle__track {
  position: relative;
  width: 60px;
  height: 34px;
  border: 1px solid rgba(92, 143, 168, 0.24);
  border-radius: 999px;
  background:
    radial-gradient(circle at 78% 34%, rgba(255, 255, 255, 0.8) 0 2px, transparent 3px),
    linear-gradient(135deg, #d9edf6, #f8fbfd);
  transition: background 220ms ease, border-color 220ms ease;
}

.theme-toggle__icon {
  position: absolute;
  top: 4px;
  left: 4px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd76f, #ff9d42);
  box-shadow: 0 6px 14px rgba(255, 157, 66, 0.32);
  transition: transform 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.theme-toggle__icon::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  content: "";
}

:root[data-theme="dark"] .theme-toggle__track {
  border-color: rgba(168, 216, 239, 0.24);
  background:
    radial-gradient(circle at 24% 30%, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 62%, rgba(255, 255, 255, 0.6) 0 1px, transparent 2px),
    linear-gradient(135deg, #111827, #020305);
}

:root[data-theme="dark"] .theme-toggle__icon {
  transform: translateX(26px);
  background: linear-gradient(135deg, #f5f7fa, #a8d8ef);
  box-shadow: 0 6px 16px rgba(168, 216, 239, 0.24);
}

:root[data-theme="dark"] .theme-toggle__icon::before {
  width: 9px;
  height: 14px;
  transform: translateX(4px);
  background: #111827;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: end;
  min-height: 300px;
  padding: 50px 18px 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: none;
  margin-bottom: 20px;
  font-size: clamp(1.9rem, 4.8vw, 4.2rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.hero-text {
  max-width: 680px;
  margin-bottom: 30px;
  color: var(--muted-strong);
  font-size: clamp(1rem, 2vw, 1.14rem);
  line-height: 1.85;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button--primary {
  color: #fbfdff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(47, 100, 127, 0.22);
}

.button--secondary {
  color: var(--accent-strong);
  background: var(--surface-strong);
  box-shadow: 0 14px 28px rgba(55, 76, 88, 0.1);
}

main {
  padding: 34px 0 0;
}

.tool-panel {
  margin-top: 42px;
}

.tool-panel__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.tool-panel__header h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.05em;
}

.tool-panel__header > p {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--muted-strong);
  line-height: 1.7;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.toolbar h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.05em;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.search-box,
.sort-box {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
}

.search-box {
  width: min(320px, 100%);
  padding: 0 16px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-box input::placeholder {
  color: var(--muted);
}

.sort-box {
  position: relative;
  overflow: visible;
  padding: 0 10px 0 16px;
  font-weight: 700;
}

.sort-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 132px;
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.sort-trigger::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 180ms ease;
  content: "";
}

.sort-trigger[aria-expanded="true"]::after {
  transform: translateY(2px) rotate(225deg);
}

.sort-box > span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.sort-box:focus-within {
  border-color: rgba(92, 143, 168, 0.44);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.sort-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 178px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.sort-menu[hidden] {
  display: none;
}

.sort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.sort-option:hover,
.sort-option:focus-visible {
  color: var(--accent-strong);
  background: var(--accent-soft);
  outline: 0;
}

.sort-option.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.sort-option.is-active::after {
  content: "✓";
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.portal-card {
  position: relative;
  overflow: hidden;
  grid-column: span 6;
  min-height: 260px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(55, 76, 88, 0.08);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.portal-card--tool {
  grid-column: span 4;
  min-height: 250px;
}

.portal-card--tool .portal-card__top {
  margin-bottom: 34px;
}

.portal-card--tool::after {
  right: -50px;
  bottom: -68px;
  width: 190px;
  height: 118px;
  opacity: 0.58;
}

.portal-card--tool .portal-icon {
  color: var(--green);
}

.portal-card--tool .portal-badge {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.portal-card:hover,
.portal-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(92, 143, 168, 0.44);
  box-shadow: var(--shadow);
}

.portal-card:focus-visible {
  outline: 0;
}

.portal-card::after {
  position: absolute;
  right: -36px;
  bottom: -60px;
  width: 210px;
  height: 130px;
  transform: rotate(-12deg);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%);
  opacity: 0.72;
  content: "";
}

.portal-card__top,
.portal-card__body {
  position: relative;
  z-index: 1;
}

.portal-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 42px;
}

.portal-card__identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.portal-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 14px;
  color: var(--accent-strong);
  background: var(--surface-strong);
  font-size: 1.6rem;
  font-weight: 800;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--green);
  background: rgba(79, 125, 104, 0.08);
  font-size: 0.82rem;
  font-weight: 800;
}

.portal-badge::before {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.portal-card h3 {
  display: flex;
  align-items: center;
  height: 52px;
  margin-bottom: 10px;
  overflow: hidden;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.05em;
}

.portal-card p {
  display: -webkit-box;
  min-height: calc(1.7em * 2);
  overflow: hidden;
  color: var(--muted-strong);
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.portal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 24px;
  padding: 0;
  list-style: none;
}

.portal-meta li {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.86rem;
  font-weight: 700;
}

:root[data-theme="dark"] .portal-meta li {
  background: rgba(255, 255, 255, 0.04);
}

.portal-copy {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--accent-strong);
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.portal-copy::before {
  font-size: 1rem;
  content: "⧉";
}

.portal-card:hover .portal-copy,
.portal-card:focus-within .portal-copy {
  opacity: 1;
  transform: translateX(0);
}

.portal-copy:hover,
.portal-copy:focus-visible {
  border-color: rgba(92, 143, 168, 0.44);
  background: var(--accent-soft);
  outline: 0;
}

.empty-state {
  padding: 38px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  background: var(--surface);
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 34px;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer code {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted-strong);
  background: var(--surface);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translate(-50%, 16px);
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 1024px) {
  .site-shell {
    width: min(100% - 28px, 1180px);
  }

  .hero {
    min-height: 400px;
  }

  .hero-grid {
    padding: 46px 12px 14px;
  }

  h1 {
    font-size: clamp(1.7rem, 5.4vw, 3.4rem);
    letter-spacing: -0.05em;
  }
}

@media (max-width: 920px) {
  h1 {
    font-size: clamp(1.5rem, 6.2vw, 3rem);
  }
}

@media (max-width: 860px) {
  .hero-grid {
    min-height: auto;
  }

  .toolbar,
  .tool-panel__header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-controls,
  .search-box,
  .sort-box {
    width: 100%;
  }

  .portal-card {
    grid-column: span 12;
  }
}

@media (max-width: 560px) {
  .site-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero {
    min-height: auto;
    padding: 16px;
    border-radius: 20px;
  }

  .hero::before {
    width: 260px;
    height: 150px;
    right: -120px;
    bottom: -92px;
  }

  .hero::after {
    display: none;
  }

  .topbar {
    align-items: center;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand strong {
    font-size: 0.94rem;
  }

  .brand small {
    font-size: 0.72rem;
  }

  .theme-toggle {
    min-height: 42px;
    padding: 5px 6px;
  }

  .theme-toggle__track {
    width: 54px;
    height: 30px;
  }

  .theme-toggle__icon {
    width: 22px;
    height: 22px;
    top: 3px;
    left: 3px;
  }

  :root[data-theme="dark"] .theme-toggle__icon {
    transform: translateX(24px);
  }

  .theme-toggle__text {
    display: none;
  }

  .hero-grid {
    gap: 22px;
    padding: 34px 0 0;
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(1.12rem, 5.4vw, 1.72rem);
    letter-spacing: -0.04em;
    white-space: nowrap;
  }

  .hero-text {
    margin-bottom: 22px;
    font-size: 0.95rem;
    line-height: 1.75;
  }

  .button {
    width: 100%;
  }

  .portal-card {
    min-height: auto;
    padding: 20px;
  }

  .portal-copy {
    opacity: 1;
    transform: none;
  }

  .portal-card h3 {
    font-size: 1.65rem;
  }
}
