/* Pyne route app. Palette and font are lifted verbatim from the pyne.gg
   landing page so a route feels like the same product as the site that
   issued it.

   One deliberate departure: Fredoka One is a display face, and the landing
   page applies it to everything. Here it dresses the chrome only -- tabs,
   headings, buttons. The request inspector is dense tabular data and raw
   headers, which that font makes genuinely hard to read, so those areas use
   a system UI and monospace stack instead. */

@font-face {
  font-family: "Fredoka One Cyrillic";
  src: url("/FredokaOneCyrillic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: "Fredoka One Cyrillic", "Fredoka One", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --bg: #14110d;
  --panel: #1a1510;
  --panel-soft: #211a13;
  --text: #eee9df;
  --muted: #9b9184;
  --dim: #6f6559;
  --accent: #e96d00;
  --accent-soft: #ff9538;
  --line: #2a2118;
  --line-strong: #3a2d20;

  --ok: #7fbf7f;
  --warn: #e96d00;
  --bad: #d98c7a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  overflow: hidden;
}

#app {
  height: 100%;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Shell ------------------------------------------------------------------ */

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 52px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--text);
  user-select: none;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.tab {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.3px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tab:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.tab.active {
  color: var(--accent);
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

.tab .count {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--dim);
  margin-left: 6px;
}

/* Views ------------------------------------------------------------------ */

.views {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
}

.view.active {
  display: flex;
}

/* Browser ---------------------------------------------------------------- */

.omnibar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.nav-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.nav-button:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

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

.nav-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.url-form {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.url-input {
  width: 100%;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease;
}

.url-input::placeholder {
  color: var(--dim);
}

.url-input:focus {
  border-color: var(--accent);
}

/* Tab strip ---------------------------------------------------------- */

.tabstrip {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 6px 10px 0;
  flex: 0 0 auto;
  background: var(--panel);
}

.tablist {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.browser-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 190px;
  min-width: 84px;
  padding: 7px 9px 7px 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, color 120ms ease;
}

.browser-tab:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.browser-tab.active {
  background: var(--bg);
  border-color: var(--line-strong);
  color: var(--accent);
}

.browser-tab-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browser-tab-close {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  opacity: 0.55;
  cursor: pointer;
}

.browser-tab-close:hover {
  opacity: 1;
  background: var(--line-strong);
  color: var(--text);
}

.tab-new {
  flex: 0 0 auto;
  align-self: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.tab-new:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Frames -------------------------------------------------------------- */

.browser-frames {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

/* Every tab keeps its own live frame; only the active one is shown.
   Hidden with visibility rather than display:none so a background tab is
   not torn down and re-laid-out every time it is switched away from. */
.browser-frame {
  position: absolute;
  inset: 0;
  visibility: hidden;
  background: var(--bg);
}

.browser-frame.active {
  visibility: visible;
}

/* Start page ---------------------------------------------------------- */

/* Rendered here, not proxied. Sits above the iframe so the frame keeps
   whatever it had loaded -- going Home is not a navigation and costs no
   tunnel round trip. */
.newtab {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 28px;
  background: var(--bg);
}

.browser-frame.at-start .newtab {
  display: flex;
}

.newtab-logo {
  width: 148px;
  height: 148px;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.newtab-search {
  width: min(520px, 100%);
}

.newtab-search input {
  width: 100%;
  padding: 13px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 120ms ease;
}

.newtab-search input::placeholder {
  color: var(--dim);
}

.newtab-search input:focus {
  border-color: var(--accent);
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

/* No visible chrome on purpose -- only the icon should read as clickable,
   not a card around it. Hover/press feedback comes from the icon itself
   (scale + a faint glow) rather than a border or background appearing. */
.shortcut {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: transform 120ms ease;
}

.shortcut:hover {
  transform: translateY(-2px) scale(1.04);
}

.shortcut:active {
  transform: translateY(0) scale(0.98);
}

.shortcut img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
  -webkit-user-drag: none;
  transition: filter 120ms ease;
}

.shortcut:hover img {
  filter: drop-shadow(0 0 10px rgba(233, 109, 0, 0.45));
}

.browser-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  /* Stays white on purpose. Pages that never declare a background depend on
     this being light, and the loading flash it causes is covered by
     .frame-loader rather than fixed by staining the canvas dark. */
  background: #fff;
}

/* Covers the iframe's white canvas during navigation. Vertical: amber at
   the top falling to grey at the bottom, so it reads as part of the app
   rather than as a blank page. */
.frame-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 200ms ease;
  background: linear-gradient(180deg, #4a290d 0%, #2f2a26 45%, #3a3a3c 100%);
}

.browser-frame.loading .frame-loader {
  opacity: 1;
}

/* Same widget as login.html's "Checking..." bar -- same markup, same
   sizing, same sweep timing -- so a route reads as one continuous piece of
   UI rather than switching styles between signing in and browsing.
   Deliberately NOT importing that page's redden-then-alert-and-reload
   timeout: reloading here would kill the tab's whole browsing session over
   one slow site, whereas the 15s failsafe in app.js already lowers this
   veil on its own if a navigation never settles. */
.frame-loader .progress {
  width: min(260px, 70%);
  height: 34px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
}

.frame-loader .progress-track {
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
}

.frame-loader .progress-bar {
  width: 38%;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  transform: translateX(-100%);
  animation: frame-sweep 1.4s linear infinite;
}

@keyframes frame-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(264%); }
}

@media (prefers-reduced-motion: reduce) {
  .frame-loader .progress-bar {
    animation: none;
    transform: none;
    width: 100%;
  }
}

/* Requests --------------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.toolbar input[type="search"] {
  flex: 0 1 280px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--bg);
  outline: none;
}

.toolbar input[type="search"]:focus {
  border-color: var(--accent);
}

.button {
  font-family: var(--font-display);
  font-size: 12px;
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  accent-color: var(--accent);
  cursor: pointer;
}

.toolbar-spacer {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}

.requests-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
}

.request-list {
  overflow: auto;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.request-row {
  display: grid;
  grid-template-columns: 52px 58px minmax(0, 1fr) 74px 66px;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 12.5px;
}

.request-row:hover {
  background: var(--panel);
}

.request-row.selected {
  background: var(--panel-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.request-row .method {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.request-row .status {
  font-family: var(--font-mono);
  font-size: 11px;
}

.request-row .url {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}

.request-row .destination,
.request-row .duration {
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-row .duration {
  text-align: right;
  font-family: var(--font-mono);
}

.status-2 { color: var(--ok); }
.status-3 { color: var(--accent); }
.status-4,
.status-5 { color: var(--bad); }
.status-pending { color: var(--dim); }

.request-detail {
  overflow: auto;
  padding: 14px;
  min-width: 0;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section h3 {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 5px 12px;
  font-size: 12.5px;
}

.detail-grid dt {
  color: var(--dim);
}

.detail-grid dd {
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-all;
}

pre.body {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}

.empty {
  padding: 34px 14px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

/* Flags ------------------------------------------------------------------ */

.flags-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.panel {
  max-width: 780px;
  margin: 0 auto 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}

.panel > h2 {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
}

.panel > p.note {
  color: var(--dim);
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.field {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.field > .label {
  color: var(--muted);
  font-size: 13px;
}

.field > .label small {
  display: block;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.5;
  margin-top: 2px;
}

.field input[type="text"],
.field input[type="number"],
.field select {
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--bg);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.field .readonly {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--dim);
  word-break: break-all;
}

.flag-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 11px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.flag-row input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  margin-top: 2px;
  cursor: pointer;
}

.flag-row .flag-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
}

.flag-row .flag-desc {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
  margin-top: 2px;
}

.panel-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.panel-actions .status {
  color: var(--dim);
  font-size: 12px;
}

/* Boot ------------------------------------------------------------------- */

/* A plain black sheet over everything until the app is genuinely ready,
   then a fade. Deliberately featureless -- service worker registration and
   wasm loading are not the user's problem, and narrating them mostly
   advertises that this page is doing something unusual.

   Pure #000 rather than --bg on purpose: this covers the whole viewport
   before any app chrome exists, so it should read as "screen off", not as
   a themed panel that failed to fill in.

   z-index sits above .frame-loader (2) and everything else in the shell. */
.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  opacity: 1;
  transition: opacity 400ms ease;
}

.boot.done {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .requests-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 250px);
  }

  .request-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .request-row {
    grid-template-columns: 46px 46px minmax(0, 1fr) 56px;
  }

  .request-row .destination {
    display: none;
  }
}
