@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;1,300;1,400&display=swap");

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Roboto", Arial, Helvetica, sans-serif;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.center-stack {
  flex: 1;
  width: 100%;
  min-height: 0;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.center-stack > :first-child {
  margin-top: auto;
}

.center-stack > :last-child {
  margin-bottom: auto;
}

.logo-wrapper {
  flex-shrink: 0;
}

#background-frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border: none;
  z-index: -1;
  pointer-events: none;
}

.lesson-page {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

#browserframe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  border: none;
  z-index: 99999;
  display: block;
  touch-action: auto;
}

#browser-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 52px;
  box-sizing: border-box;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 99999999;
  background: rgba(17, 17, 17, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-family: "Roboto", Arial, Helvetica, sans-serif;
  transform: translateY(-52px);
  transition: transform 0.35s cubic-bezier(.16, 1, .3, 1);
}

#browser-toolbar.toolbar-expanded {
  transform: translateY(0);
}

#toolbar-toggle {
  position: fixed;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 58px;
  height: 17px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-top: none;
  border-radius: 0 0 9px 9px;
  background: rgba(17, 17, 17, 0.92);
  color: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: pointer;
  z-index: 100000000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 0.35s cubic-bezier(.16, 1, .3, 1), color 0.2s ease, background 0.2s ease, width 0.2s ease;
}

#browser-toolbar.toolbar-expanded ~ #toolbar-toggle {
  top: 52px;
}

#toolbar-toggle:hover {
  width: 64px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(25, 25, 25, 0.96);
}

#toolbar-toggle:active {
  width: 60px;
}

.toolbar-toggle-icon {
  display: block;
  width: 28px;
  height: 12px;
  flex-shrink: 0;
  color: currentColor;
  transform: rotate(0deg);
  transform-origin: center;
  transition: transform 0.35s cubic-bezier(.16, 1, .3, 1);
}

#toolbar-toggle.expanded .toolbar-toggle-icon {
  transform: rotate(180deg);
}

.nav-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-buttons button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.nav-buttons button svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.nav-buttons button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-buttons button:active {
  background: rgba(255, 255, 255, 0.12);
}

.nav-buttons button:disabled {
  opacity: 0.3;
  cursor: default;
}

.url-bar {
  position: relative;
  flex: 1;
  height: 34px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: #666;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.url-bar:focus-within {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.15);
}

#menu-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  margin-right: -10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#menu-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

#menu-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.08);
}

#menu-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

#menu-btn[aria-expanded="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.1);
}

#toolbar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 172px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 100000001;
}

#toolbar-menu[hidden] {
  display: none;
}

.toolbar-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #ddd;
  font: 400 13px "Roboto", Arial, Helvetica, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.toolbar-menu-item svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
  color: #999;
}

.toolbar-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.toolbar-menu-item:hover svg {
  color: #fff;
}

.toolbar-menu-item:active {
  background: rgba(255, 255, 255, 0.12);
}

#browser-url {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #ddd;
  font: 400 13px "Roboto", Arial, Helvetica, sans-serif;
}

#browser-url::placeholder {
  color: #666;
}

.flex-center {
  display: flex;
  justify-content: center;
}

.header-center {
  align-items: center;
  flex-direction: column;
  margin-top: 0;
  width: 100%;
}

.logo {
  width: min(46vw, 260px);
  height: auto;
  max-height: 24vh;
  max-height: 24dvh;
  object-fit: contain;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.subtitle-wrapper {
  width: min(560px, 92vw);
  margin: 14px auto 0;
  text-align: center;
}

#nebula-subtitle {
  margin: 0;
  color: rgba(240, 240, 240, 0.8);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  user-select: none;
  white-space: pre-line;
}

#form {
  width: min(560px, 92vw);
  margin: 0 auto;
}

#form .search-box {
  position: relative;
  width: 100%;
}

#address {
  position: relative;
  z-index: 51;
  width: 100%;
  height: 48px;
  padding: 0 58px 0 46px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  outline: none;
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  font: 400 14px "Roboto", Arial, Helvetica, sans-serif;
  letter-spacing: 0.005em;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  transition: border-color 0.25s cubic-bezier(.16, 1, .3, 1), background 0.25s cubic-bezier(.16, 1, .3, 1), box-shadow 0.25s cubic-bezier(.16, 1, .3, 1);
}

#address:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

#address:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.025), 0 14px 50px rgba(0, 0, 0, 0.18);
}

#address::placeholder {
  color: #5c5c65;
}

#form .search-icon {
  position: absolute;
  left: 17px;
  top: 50%;
  z-index: 52;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: #5c5c65;
  pointer-events: none;
}

#form .search-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 52;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.07);
  color: #9a9aa3;
  cursor: pointer;
  transition: background 0.25s cubic-bezier(.16, 1, .3, 1), border-color 0.25s cubic-bezier(.16, 1, .3, 1), color 0.25s cubic-bezier(.16, 1, .3, 1), transform 0.25s cubic-bezier(.16, 1, .3, 1);
}

#form .search-btn:hover {
  color: #f4f4f5;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.11);
  transform: translateX(1px);
}

#form .search-btn:active {
  transform: translateX(0);
}

.desc {
  width: min(560px, 92vw);
  margin: 12px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.desc p {
  width: 100%;
  max-width: 100%;
  margin: 0;
  color: rgba(253, 253, 253, 0.514);
}

#sj-error {
  color: #ff6666 !important;
  white-space: pre-wrap;
}

#sj-error-code {
  font-size: 12px;
  color: #fff;
  font-family: "Courier New", Courier, monospace;
}

@media (max-width: 480px) {
  #browser-toolbar {
    height: 52px;
    padding: 8px;
    gap: 6px;
    transform: translateY(-52px);
  }
  #browser-toolbar.toolbar-expanded {
    transform: translateY(0);
  }
  #toolbar-toggle {
    width: 54px;
    height: 17px;
  }
  #toolbar-toggle:hover {
    width: 58px;
  }
  .toolbar-toggle-icon {
    width: 26px;
    height: 11px;
  }
  .nav-buttons {
    gap: 2px;
  }
  .nav-buttons button {
    width: 32px;
    height: 32px;
  }
  .url-bar {
    height: 32px;
    padding: 0 9px;
  }
  #form {
    width: 94vw;
  }
  #address {
    height: 46px;
    padding-left: 42px;
    font-size: 13px;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.07);
  }
  #form .search-btn {
    top: 6px;
    right: 6px;
  }
  .header-center {
    margin-top: 0;
  }
  .logo {
    width: min(66vw, 240px);
    height: auto;
    max-height: 22vh;
    max-height: 22dvh;
  }
  .subtitle-wrapper {
    width: 94vw;
  }
}

@media (max-height: 500px) {
  .center-stack {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .logo {
    width: min(36vw, 180px);
    height: auto;
    max-height: 20vh;
    max-height: 20dvh;
    margin-bottom: 12px;
  }
  .subtitle-wrapper {
    margin-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #browser-toolbar,
  #toolbar-toggle,
  .toolbar-toggle-icon,
  .nav-buttons button,
  .url-bar,
  #menu-btn,
  .toolbar-menu-item,
  #address,
  #form .search-btn,
  #nebula-subtitle {
    transition: none;
  }
}

#topbar {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, calc(100% - 28px));
  box-sizing: border-box;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
  background: rgba(26, 26, 30, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.topbar-brand img {
  width: 21px;
  height: 21px;
  object-fit: contain;
  border-radius: 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.topbar-btn:hover {
  opacity: 0.75;
}

.topbar-btn svg {
  width: 19px;
  height: 19px;
  display: block;
}

.center-stack {
  padding-top: calc(110px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}

#banner {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%) scale(0.75);
  transform-origin: bottom center;
  width: 728px;
  max-width: calc(100vw - 16px);
  height: 90px;
  max-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 15;
  pointer-events: auto;
}

#banner iframe {
  max-width: 100%;
}

.whoami-link {
  position: fixed;
  left: 18px;
  bottom: 16px;
  z-index: 10;
  color: rgba(210, 210, 210, 0.85);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  user-select: none;
}

@media (max-width: 640px) {
  #topbar {
    padding: 6px 14px;
  }
  .topbar-brand {
    font-size: 16px;
  }
  .topbar-actions {
    gap: 14px;
  }
}

.settings-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(84px + 24px) 16px 32px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.settings-page::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.settings-wrap {
  width: min(880px, 94vw);
}

.settings-title {
  margin: 0;
  color: #fff;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
}

.settings-sub {
  margin: 8px 0 22px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-weight: 300;
  text-align: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.setting-card {
  display: flex;
  flex-direction: column;
  padding: 26px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(26, 26, 30, 0.6);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.setting-card h2 {
  margin: 0;
  color: #fff;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.setting-card p {
  margin: 14px 0 0;
  flex: 1;
  color: rgba(255, 255, 255, 0.62);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.65;
}

.card-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.pill {
  padding: 9px 16px;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font: 400 13px "Roboto", Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pill:hover {
  border-color: #fff;
}

.pill.active {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
  color: #161616;
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #888;
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch.on {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.25);
}

.switch.on .knob {
  transform: translateX(18px);
  background: #fff;
}

.settings-status {
  display: block;
  margin-top: 18px;
  min-height: 16px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  text-align: center;
}