:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #171a1f;
  --panel-strong: #1f242b;
  --text: #f4f7fb;
  --muted: #9da8b8;
  --line: #2a3038;
  --green: #48d597;
  --yellow: #f2c76b;
  --red: #f36f6f;
  --cyan: #66d4e8;
  --violet: #b78cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(72, 213, 151, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(102, 212, 232, 0.1), transparent 34%),
    var(--bg);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.page {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: rgba(23, 26, 31, 0.94);
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.profile-form {
  display: flex;
  gap: 8px;
  margin: 0 0 8px;
}

.profile-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101318;
  font-size: 16px;
  font-weight: 750;
  text-align: center;
  outline: none;
}

.profile-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.profile-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(72, 213, 151, 0.18);
}

.profile-submit {
  flex: 0 0 auto;
  min-width: 92px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(72, 213, 151, 0.62);
  border-radius: 8px;
  color: #08110d;
  background: var(--green);
  font-size: 16px;
  font-weight: 850;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.profile-submit:hover {
  border-color: rgba(102, 212, 232, 0.88);
  background: #66e4aa;
  transform: translateY(-1px);
}

.profile-submit:focus-visible {
  outline: 3px solid rgba(72, 213, 151, 0.28);
  outline-offset: 2px;
}

.profile-history {
  position: relative;
  min-width: 0;
  margin: 0 0 8px;
  overflow: visible;
}

.history-list {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 52px;
  padding: 2px 2px 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.history-avatar {
  position: relative;
  display: block;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151a;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  outline: none;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.history-clear {
  position: sticky;
  left: 2px;
  z-index: 2;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(243, 111, 111, 0.34);
  border-radius: 8px;
  color: var(--red);
  background: #161216;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  outline: none;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.history-clear svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.history-avatar:hover,
.history-avatar:focus-visible {
  border-color: rgba(102, 212, 232, 0.86);
  transform: translateY(-1px);
}

.history-clear:hover,
.history-clear:focus-visible {
  border-color: rgba(243, 111, 111, 0.88);
  color: #ff8d8d;
  transform: translateY(-1px);
}

.history-avatar img,
.history-fallback {
  width: 100%;
  height: 100%;
  border-radius: 7px;
}

.history-avatar img {
  display: none;
  object-fit: cover;
}

.history-avatar.has-image img {
  display: block;
}

.history-avatar.has-image .history-fallback {
  display: none;
}

.history-fallback {
  display: grid;
  place-items: center;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(72, 213, 151, 0.8), rgba(102, 212, 232, 0.62)),
    #151b21;
  font-size: 0.92rem;
  font-weight: 850;
}

.history-tooltip {
  position: fixed;
  z-index: 20;
  display: grid;
  gap: 3px;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(42, 48, 56, 0.92);
  border-radius: 8px;
  color: var(--text);
  background: rgba(8, 10, 13, 0.96);
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translate(-50%, -100%);
}

.history-tooltip[hidden] {
  display: none;
}

.history-name {
  min-width: 0;
  max-width: 300px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-link {
  min-width: 0;
  max-width: 300px;
  overflow: hidden;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  justify-content: stretch;
  align-items: start;
  gap: 8px;
  margin: 0 0 8px;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tab::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
}

.tab[data-site="csrep"]::before {
  background: var(--green);
}

.tab[data-site="leetify"]::before {
  background: var(--yellow);
}

.tab[data-site="csst"]::before {
  background: var(--red);
}

.tab[data-site="fastgg"]::before {
  background: var(--violet);
}

.tab:hover {
  border-color: rgba(72, 213, 151, 0.72);
  transform: translateY(-1px);
}

.tab:focus-visible {
  outline: 3px solid rgba(72, 213, 151, 0.28);
  outline-offset: 2px;
}

.tab.is-active {
  border-color: rgba(72, 213, 151, 0.72);
  background: #242b31;
}

.site-panel {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d10;
}

.frame-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: #080a0d;
  font-size: 34px;
  font-weight: 750;
  text-align: center;
}

.site-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.site-frame[hidden],
.frame-placeholder[hidden] {
  display: none;
}

.status {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100% - 28px));
  min-height: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(42, 48, 56, 0.9);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(16, 19, 24, 0.92);
  font-size: 0.9rem;
  pointer-events: none;
}

.status.is-error {
  color: var(--red);
}

.status.is-ok {
  color: var(--green);
}

@media (max-width: 860px) {
  .tabs {
    gap: 8px;
  }
}

@media (max-width: 560px) {
  .page {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 6px;
  }

  .profile-input {
    height: 38px;
  }

  .profile-submit {
    min-width: 76px;
    height: 38px;
    padding: 0 12px;
    font-size: 0.88rem;
  }

  .profile-history {
    margin-bottom: 6px;
  }

  .history-list {
    gap: 6px;
    min-height: 46px;
    padding-bottom: 3px;
  }

  .history-avatar,
  .history-clear {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
  }

  .history-clear svg {
    width: 20px;
    height: 20px;
  }

  .history-name,
  .history-link {
    max-width: 240px;
  }

  .tabs {
    gap: 6px;
    margin-bottom: 6px;
  }

  .tab {
    height: 40px;
    padding: 0 6px;
    font-size: 0.84rem;
  }

  .tab::before {
    width: 7px;
    height: 7px;
    margin-right: 5px;
  }

  .site-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
  }

  .frame-placeholder {
    font-size: 26px;
  }

  .status {
    right: 10px;
    bottom: 10px;
    font-size: 0.82rem;
  }
}
