:root {
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #3b82f6;
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Noto Sans",
    sans-serif;
}
html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  position: fixed;
  inset: 0;
}
#app-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}
[hidden] {
  display: none !important;
}

/* Boot view: a plain white cover over the canvas until the engine's own
   opaque cover has been presented. */
.boot {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: #fff;
}
.boot-inner {
  width: min(22rem, 80vw);
  display: grid;
  gap: 0.75rem;
  text-align: center;
}
.boot-message {
  margin: 0;
  font-size: 0.95rem;
}
.boot-line {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
#boot-line-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.boot[data-state="failed"] #boot-line-fill {
  background: #dc2626;
}
.boot-detail,
.boot-note {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.boot-enter {
  justify-self: center;
  margin-top: 0.5rem;
  padding: 0.8rem 2.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}
.boot[data-state="ready"] {
  cursor: pointer;
}
.boot-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.boot-actions button {
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.boot-transfer button {
  border: 0;
  color: var(--muted);
  text-decoration: underline;
}

/* Portrait on a touch screen: ask for landscape. */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 1.25rem;
  background: #fff;
  text-align: center;
}
.rotate p {
  margin: 0;
  font-size: 0.95rem;
}
.rotate-device {
  width: 3rem;
  height: 5rem;
  border: 3px solid var(--ink);
  border-radius: 0.6rem;
  animation: rotate-hint 2.4s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%,
  30% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}
@media (orientation: portrait) and (pointer: coarse) {
  .rotate {
    display: grid;
  }
}
#panel-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}
#panel-root > * {
  pointer-events: auto;
}

/* Server mock panel: a toggle in the lower-left corner and a drawer on the
   right, offered only when asked for (?panel=server). */
.server-toggle {
  position: fixed;
  left: calc(env(safe-area-inset-left) + 0.5rem);
  bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.server-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(28rem, 92vw);
  box-sizing: border-box;
  padding: calc(env(safe-area-inset-top) + 0.75rem) calc(env(safe-area-inset-right) + 0.75rem)
    calc(env(safe-area-inset-bottom) + 0.75rem) 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
  background: rgba(255, 255, 255, 0.97);
  border-left: 1px solid var(--line);
  font-size: 0.8rem;
}
.server-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.server-head h2 {
  margin: 0;
  font-size: 0.95rem;
}
.server-clock {
  flex: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.server-panel h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
}
.server-status {
  min-height: 1.2em;
  margin: 0.5rem 0;
  color: var(--muted);
}
.server-status.error,
.server-field-error {
  color: #b91c1c;
  font-weight: 600;
}
.server-notes {
  margin: 0;
  padding-left: 1.1rem;
  color: #92400e;
}
.server-pending {
  margin: 0.25rem 0 0.5rem;
  color: var(--muted);
}
.server-section {
  margin: 0 0 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
}
.server-section legend {
  font-weight: 600;
}
.server-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.3rem 0;
}
.server-field-name {
  flex: 1 1 100%;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.server-field input,
.server-field select,
.server-field textarea {
  flex: 1 1 10rem;
  min-width: 0;
  font: inherit;
}
.server-field textarea {
  flex-basis: 100%;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.server-panel button {
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.server-field-facts {
  flex: 1 1 100%;
  color: var(--muted);
}
.server-policies {
  padding-left: 1.1rem;
}
.server-client {
  max-height: 16rem;
  overflow: auto;
  font-size: 0.7rem;
  white-space: pre-wrap;
}
