:root {
  font: 15px/1.45 system-ui, sans-serif;
  color: #f0f4f9;
  background: #0d121a;
  color-scheme: dark;
  --border: #303b4a;
  --page: #0d121a;
  --panel: #171f2b;
  --muted: #a7b4c5;
  --accent: #b5e2d5;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

button, input, select, summary { font: inherit; }
button, summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #202a38;
  color: inherit;
  padding: 0.58rem 0.83rem;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, summary:hover { background: #2b394a; }
button:disabled { cursor: wait; opacity: 0.68; }
button[aria-pressed="true"] { background: #29483f; border-color: #76a89b; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

input, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  color: inherit;
  padding: 0.64rem 0.78rem;
}
input::placeholder { color: var(--muted); }
.primary { border-color: transparent; background: var(--accent); color: #102822; font-weight: 650; }
.primary:hover { background: #ccefe5; }

.entrance {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: radial-gradient(ellipse at 55% 12%, #1b2d33 0, var(--page) 66%);
}
.signin {
  width: min(100%, 390px);
  padding: clamp(1.5rem, 6vw, 2.35rem);
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 20px 65px #03070c66;
}
.signin h1 { margin: 0 0 1.65rem; font-size: 2rem; font-weight: 680; letter-spacing: -0.055em; }
.signin label, dialog label { display: block; color: var(--muted); margin: 0 0 0.46rem; }
.signin input + label, .signin select + label { margin-top: 0.85rem; }
.signin button { width: 100%; margin-top: 0.9rem; }
.notice { margin: 0.8rem 0 0; color: #ffb3ab; }
.notice:empty { display: none; }

.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.toolbar {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.identity, .actions, .address { display: flex; align-items: center; gap: 0.5rem; }
.identity { white-space: nowrap; }
.identity strong { font-size: 1.25rem; letter-spacing: -0.04em; }
.server-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.server-picker::after {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-0.1rem) rotate(45deg);
}
.server-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.server-badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.server-badge[data-server-id] { color: var(--accent); }
.address { flex: 1; min-width: 0; margin: 0; }
.address input { min-width: 0; }
.actions { margin-left: auto; }
.actions details { position: relative; }
.actions summary { list-style: none; }
.actions summary::-webkit-details-marker { display: none; }
#files {
  position: absolute;
  z-index: 2;
  top: 100%;
  right: 0;
  width: min(270px, 76vw);
  padding: 0.8rem;
  margin: 0.35rem 0 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  list-style: none;
  color: var(--muted);
}
#files li + li { margin-top: 0.55rem; }
#files a { color: var(--accent); overflow-wrap: anywhere; }
.page-notice { color: #ffb3ab; background: var(--panel); margin: 0; padding: 0.5rem 0.85rem; }
.view { flex: 1; min-height: 0; position: relative; }
.display { width: 100%; height: 100%; overflow: hidden; }
.connection {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  background: #0d121aeb;
}
.connection p { margin: 0 0 0.85rem; color: var(--muted); }
dialog {
  max-width: min(95vw, 420px);
  width: 100%;
  padding: 1.25rem;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
dialog::backdrop { background: #060910a8; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.85rem; }
#server-title { margin: 0; font-size: 1.1rem; }
#server-hint { margin: 0.45rem 0 0.9rem; color: var(--muted); }
.server-options { display: grid; gap: 0.45rem; }
.server-options button { text-align: left; }
#history-dialog { max-width: min(94vw, 680px); }
#history-title { margin: 0; font-size: 1.1rem; }
.history-entries {
  max-height: 52dvh;
  overflow: auto;
  margin: 0.75rem 0;
  padding: 0;
  list-style: none;
}
.history-entries li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.history-url {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  overflow-wrap: anywhere;
}
.history-entries time, #history-status { color: var(--muted); font-size: 0.85rem; }
#history-status { margin: 0; }
#history-status:empty { display: none; }
#history-clear:disabled { cursor: default; }

#quick-sites { position: relative; }
#quick-sites summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  list-style: none;
}
#quick-sites summary::-webkit-details-marker { display: none; }
#quick-sites summary::after {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-0.1rem) rotate(45deg);
}
#quick-sites ul {
  position: absolute;
  z-index: 2;
  top: 100%;
  right: 0;
  width: min(220px, 75vw);
  max-height: 58dvh;
  margin: 0.35rem 0 0;
  padding: 0.35rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  list-style: none;
}
#quick-sites ul button {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
}
#quick-sites ul button:hover { background: #2b394a; }

@media (max-width: 1020px) {
  .toolbar { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.45rem; }
  .actions { grid-column: 1 / -1; flex-wrap: wrap; margin-left: 0; gap: 0.35rem; }
  .toolbar button, .toolbar summary { padding-inline: 0.55rem; }
  .actions details { position: static; }
  #files { right: 0.85rem; }
  input, select { font-size: 16px; }
}

@media (max-width: 540px) {
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .identity { flex-wrap: wrap; }
}
