@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;1,300;1,400&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100..900&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%;
}

:root {
  --accent: #dfc2ef;
  --accent-hot: #ffa3d7;
  --accent-glow: rgba(223, 194, 239, 0.35);
  --accent-glow-soft: rgba(223, 194, 239, 0.16);
  --accent-hot-glow: rgba(255, 163, 215, 0.4);
  --accent-hot-glow-soft: rgba(255, 163, 215, 0.18);
}

html[data-theme="moss"] {
  --accent: #8fe3b8;
  --accent-hot: #d8f79b;
  --accent-glow: rgba(143, 227, 184, 0.35);
  --accent-glow-soft: rgba(143, 227, 184, 0.16);
  --accent-hot-glow: rgba(216, 247, 155, 0.4);
  --accent-hot-glow-soft: rgba(216, 247, 155, 0.18);
}

html[data-theme="blue-lavender"] {
  --accent: #a9c9f5;
  --accent-hot: #8ab6ff;
  --accent-glow: rgba(169, 201, 245, 0.35);
  --accent-glow-soft: rgba(169, 201, 245, 0.16);
  --accent-hot-glow: rgba(138, 182, 255, 0.4);
  --accent-hot-glow-soft: rgba(138, 182, 255, 0.18);
}

html[data-theme="rose"] {
  --accent: #dfa0b4;
  --accent-hot: #f7b9cd;
  --accent-glow: rgba(223, 160, 180, 0.35);
  --accent-glow-soft: rgba(223, 160, 180, 0.16);
  --accent-hot-glow: rgba(247, 185, 205, 0.4);
  --accent-hot-glow-soft: rgba(247, 185, 205, 0.18);
}

html[data-theme="sand"] {
  --accent: #e0c193;
  --accent-hot: #f2d5a0;
  --accent-glow: rgba(224, 193, 147, 0.35);
  --accent-glow-soft: rgba(224, 193, 147, 0.16);
  --accent-hot-glow: rgba(242, 213, 160, 0.4);
  --accent-hot-glow-soft: rgba(242, 213, 160, 0.18);
}

::selection {
  background: var(--accent);
  color: #161616;
}

input::selection,
textarea::selection {
  background: var(--accent);
  color: #161616;
}

.logo-text {
  margin: 0 0 12px;
  padding: 0;
  color: var(--accent);
  font-family: "Inter", "Roboto", Arial, Helvetica, sans-serif;
  font-size: clamp(52px, 11vw, 82px);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.045em;
  text-transform: lowercase;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  text-shadow:
    0 0 18px var(--accent-glow),
    0 0 46px var(--accent-glow-soft);
}

.logo-text .logo-hot {
  color: var(--accent-hot);
  text-shadow:
    0 0 18px var(--accent-hot-glow),
    0 0 46px var(--accent-hot-glow-soft);
}

.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: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow-soft), 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-text {
    font-size: clamp(44px, 15vw, 60px);
  }
  .subtitle-wrapper {
    width: 94vw;
  }
}

@media (max-height: 500px) {
  .center-stack {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .logo-text {
    font-size: clamp(38px, 8.5vh, 52px);
  }
  .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));
}

.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: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-align: center;
}

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

.settings-list {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(26, 26, 30, 0.55);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px;
}

.setting-row + .setting-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-info {
  flex: 1;
  min-width: 0;
}

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

.setting-info p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.55;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .setting-row {
    flex-direction: column;
    align-items: stretch;
  }
  .setting-control {
    justify-content: flex-end;
  }
}

.select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
  padding: 10px 38px 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.05);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23aaa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  color: #fff;
  font: 400 14px "Roboto", Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.select:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.select:focus {
  outline: none;
  border-color: var(--accent);
}

.select option {
  background: #1a1a1e;
  color: #fff;
}

.ghost-btn {
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font: 400 13px "Roboto", Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.ghost-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 28px;
  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: 22px;
  height: 22px;
  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(22px);
  background: #fff;
}

.settings-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin: 22px auto 0;
  padding: 10px 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(26, 26, 30, 0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.settings-status.show {
  opacity: 1;
}