:root {
  color-scheme: light;
  --ink: #15191f;
  --muted: #596473;
  --line: #d9dee6;
  --paper: #f5f7fa;
  --panel: #ffffff;
  --accent: #147a6c;
  --accent-strong: #0b5f56;
  --shadow: 0 18px 45px rgba(24, 32, 43, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.home-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e3e8ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view-button {
  min-width: 66px;
  height: 34px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.view-button.active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(20, 27, 35, 0.08);
}

.header-note {
  max-width: 310px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.home-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.problemset-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 190px) minmax(150px, 190px);
  gap: 12px;
  margin-bottom: 14px;
}

.search-box,
.select-box {
  display: grid;
  gap: 6px;
}

.search-box span,
.select-box span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input,
.select-box select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  outline: none;
}

.search-box input:focus,
.select-box select:focus {
  border-color: rgba(20, 122, 108, 0.62);
  box-shadow: 0 0 0 3px rgba(20, 122, 108, 0.13);
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tag-filters {
  display: flex;
  gap: 8px;
}

.tag-filter {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: #354253;
  background: #ffffff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

.tag-filter.active,
.tag-filter:hover,
.tag-filter:focus-visible {
  color: #063f39;
  background: #dcefeb;
  border-color: rgba(20, 122, 108, 0.42);
  outline: none;
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-bar strong {
  color: var(--ink);
}

.app-results.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.app-results.list-view {
  display: grid;
  gap: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.app-tile {
  display: block;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(20, 27, 35, 0.07);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.app-tile:hover,
.app-tile:focus-visible {
  border-color: rgba(20, 122, 108, 0.42);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
  outline: none;
}

.thumb-wrap {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #dfe6ee;
}

.thumb-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-id {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 6px 9px;
  color: #fff;
  background: rgba(10, 15, 20, 0.82);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
}

.tile-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.tile-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.tile-summary {
  min-height: 44px;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-row span {
  padding: 5px 8px;
  color: #22534e;
  background: #e2f1ee;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.problem-row {
  display: grid;
  grid-template-columns: 22px 72px minmax(240px, 1fr) minmax(260px, 0.7fr) 88px;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #edf1f5;
  transition: background 140ms ease;
}

.problem-row:last-child {
  border-bottom: 0;
}

.problem-row:hover,
.problem-row:focus-visible {
  background: #f3f8f7;
  outline: none;
}

.status-dot {
  width: 9px;
  height: 9px;
  border: 2px solid #95a2b3;
  border-radius: 50%;
}

.problem-id {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.problem-title {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.problem-title strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-title small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row.compact {
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.difficulty {
  justify-self: end;
  min-width: 74px;
  padding: 5px 9px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 850;
}

.difficulty.easy {
  color: #09705f;
  background: #dff4ef;
}

.difficulty.medium {
  color: #8a5a00;
  background: #fff2cc;
}

.difficulty.hard {
  color: #b4233c;
  background: #ffe2e7;
}

.empty-state {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.viewer-body {
  height: 100vh;
  overflow: hidden;
  background: #0d1117;
}

.viewer-body iframe {
  display: block;
  width: 100vw;
  height: 100vh;
  border: 0;
  background: #fff;
}

.viewer-body.with-top-panel iframe {
  height: calc(100vh - 40px);
  margin-top: 40px;
}

.top-panel {
  position: fixed;
  z-index: 22;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 4px 10px;
  background: #ff6500;
  border-bottom: 1px solid rgba(12, 16, 20, 0.18);
  box-shadow: 0 3px 10px rgba(10, 15, 20, 0.16);
}

.top-panel[hidden] {
  display: none;
}

.brand-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 194px;
  height: 22px;
  transform: translate(-50%, -50%);
}

.brand-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.about-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 30px;
  padding: 0 14px;
  color: #15191f;
  background: #fff;
  border: 1px solid rgba(12, 16, 20, 0.12);
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.about-button:hover,
.about-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.38);
}

.menu-button {
  position: fixed;
  z-index: 20;
  top: 16px;
  left: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
  background: #ff6500;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
  cursor: pointer;
}

.with-top-panel .menu-button {
  position: static;
  z-index: 23;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
}

.with-top-panel .about-button {
  position: relative;
  z-index: 23;
  flex: 0 0 auto;
}

.with-top-panel .menu-icon {
  width: 26px;
  height: 26px;
}

.menu-icon {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  pointer-events: none;
}

.menu-button.open {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(255, 101, 0, 0.35);
}

.app-menu {
  position: fixed;
  z-index: 19;
  top: 70px;
  left: 16px;
  width: min(330px, calc(100vw - 32px));
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding: 12px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.with-top-panel .app-menu {
  top: 56px;
}

@media (max-width: 680px) {
  .top-panel {
    height: 38px;
    padding: 3px 8px;
  }

  .viewer-body.with-top-panel iframe {
    height: calc(100vh - 38px);
    margin-top: 38px;
  }

  .brand-banner {
    width: 160px;
    height: 18px;
  }

  .about-button {
    min-width: 58px;
    height: 28px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .with-top-panel .app-menu {
    top: 54px;
  }
}

.app-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 7px;
}

.app-menu a:hover,
.app-menu a:focus-visible,
.menu-app.active {
  background: #e9f3f1;
  outline: none;
}

.home-link {
  font-weight: 800;
}

.menu-divider {
  height: 1px;
  margin: 10px 0;
  background: var(--line);
}

.menu-apps {
  display: grid;
  gap: 4px;
}

.menu-app strong {
  min-width: 52px;
  color: var(--accent-strong);
}

.menu-app span {
  line-height: 1.25;
}

@media (max-width: 680px) {
  .home-header {
    display: block;
    padding-top: 32px;
  }

  .view-switch {
    margin-top: 18px;
  }

  .problemset-toolbar {
    grid-template-columns: 1fr;
  }

  .header-note {
    margin-top: 12px;
  }

  .tile-grid,
  .app-results.grid-view {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .result-bar {
    display: grid;
    gap: 4px;
  }

  .problem-row {
    grid-template-columns: 18px 62px minmax(0, 1fr) auto;
    gap: 9px;
    min-height: 82px;
    padding: 12px;
  }

  .problem-row .tag-row {
    display: none;
  }

  .problem-title strong,
  .problem-title small {
    white-space: normal;
  }

  .difficulty {
    min-width: 66px;
    font-size: 0.75rem;
  }
}
