/* iPad client. Safari 12: no flexbox gap, no :is(), no aspect-ratio. */
[hidden] { display: none !important; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

body { position: fixed; top: 0; right: 0; bottom: 0; left: 0; }

#app, .screen { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }

button { font: inherit; color: inherit; }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* Pairing */
.pair {
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  padding: 24px;
}

.pair-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  -webkit-user-select: text; user-select: text;
}

.pair-card h1 { margin: 16px 0 8px; font-size: 26px; }
.pair-card .lead { margin: 0 0 20px; color: var(--text-muted); line-height: 1.45; }
.pair-card label { display: block; margin: 14px 0 6px; font-size: 14px; color: var(--text-muted); }

.pair-card input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  -webkit-appearance: none;
  -webkit-user-select: text; user-select: text;
}

#pair-code { font-family: var(--font-mono); font-size: 30px; letter-spacing: 10px; text-align: center; }
.pair-card input:focus { outline: none; border-color: var(--accent); }

.primary {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-strong);
  border: 0;
  border-radius: var(--radius-m);
  -webkit-appearance: none;
}
.primary:disabled { opacity: 0.5; }

.error { margin: 14px 0 0; color: var(--danger); line-height: 1.4; }

.logo {
  display: inline-block;
  width: 56px; height: 56px;
  padding: 11px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: 0;
}
.logo span { display: inline-block; width: 15px; height: 15px; margin: 0 1px 2px 0; border-radius: 4px; }
.logo span:nth-child(1) { background: #2563eb; }
.logo span:nth-child(2) { background: #14b8a6; }
.logo span:nth-child(3) { background: #8b5cf6; }
.logo span:nth-child(4) { background: #f59e0b; }

/* Deck */
.deck {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.grid {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 44px;
  display: -ms-grid;
  display: grid;
  -webkit-box-pack: center; justify-content: center;
  align-content: center;
}

.key, .slot {
  position: relative;
  overflow: hidden;
  border-radius: 14%;
}

.slot { background: rgba(255, 255, 255, 0.025); }

.key {
  background: var(--key-default);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-transition: -webkit-transform 70ms ease-out, filter 70ms ease-out;
  transition: transform 70ms ease-out, filter 70ms ease-out;
}

.key.pressed {
  -webkit-transform: scale(0.92);
  transform: scale(0.92);
  -webkit-filter: brightness(1.35);
  filter: brightness(1.35);
}

.key img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.key .title {
  position: absolute;
  left: 6%; right: 6%;
  text-align: center;
  font-weight: 600;
  line-height: 1.15;
  white-space: pre-line;
  word-wrap: break-word;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 1px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.key .title.top { top: 6%; }
.key .title.middle { top: 50%; -webkit-transform: translateY(-50%); transform: translateY(-50%); }
.key .title.bottom { bottom: 6%; }

.key .badge {
  position: absolute;
  top: 6%; right: 6%;
  width: 22%; height: 22%;
  min-width: 18px; min-height: 18px;
  border-radius: 50%;
  pointer-events: none;
}
.key .badge.folder { background: rgba(255, 255, 255, 0.18); }
.key.failed::after {
  content: "!";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  background: rgba(239, 68, 68, 0.72);
}

.key.back { background: #0f172a; border: 1px solid var(--border-strong); }
.key.back .arrow {
  position: absolute;
  top: 50%; left: 50%;
  width: 30%; height: 30%;
  margin: -15% 0 0 -9%;
  border-left: 4px solid var(--text-muted);
  border-bottom: 4px solid var(--text-muted);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

/* Bottom bar */
.bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 44px;
  padding: 0 12px;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  font-size: 14px;
  color: var(--text-muted);
}
.bar-title { -webkit-box-flex: 1; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-status { margin-right: 12px; }
.bar-status.offline { color: var(--warning); }

/* Page buttons: named after the pages, scrollable with the finger when there are many. */
.dots {
  -webkit-box-flex: 0; flex: 0 1 auto;
  max-width: 64%;
  margin: 0 10px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.dots::-webkit-scrollbar { display: none; }
.page-button {
  display: inline-block;
  max-width: 180px;
  height: 32px;
  margin: 0 3px;
  padding: 0 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  -webkit-appearance: none;
}
.page-button.current { color: #fff; background: var(--accent-strong); border-color: var(--accent-strong); }

.menu-button {
  width: 44px; height: 36px;
  padding: 0;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  -webkit-appearance: none;
}

/* Overlay, menu, toast */
.overlay, .sheet {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: -webkit-box; display: flex;
  -webkit-box-align: center; align-items: center;
  -webkit-box-pack: center; justify-content: center;
  background: rgba(3, 7, 18, 0.72);
  z-index: 10;
}

.overlay-card, .sheet-card {
  width: 90%;
  max-width: 380px;
  padding: 26px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  text-align: center;
}

.sheet-card { text-align: left; max-height: 86%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-card h2 { margin: 6px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }

.menu-list { list-style: none; margin: 0 0 18px; padding: 0; }
.menu-list li + li { margin-top: 6px; }
.menu-list button {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  -webkit-appearance: none;
}
.menu-list button.current { border-color: var(--accent); background: var(--accent-soft); }
.menu-list button.danger { color: var(--danger); }

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 14px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  -webkit-animation: spin 0.8s linear infinite;
  animation: spin 0.8s linear infinite;
}
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: absolute;
  left: 50%;
  bottom: 60px;
  max-width: 80%;
  padding: 11px 16px;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  font-size: 15px;
  color: #fff;
  background: rgba(127, 29, 29, 0.95);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  z-index: 20;
}

/* Simulated screen off while the PC is unreachable: above everything, swallows the waking touch. */
.sleep {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: #000;
  z-index: 100;
}

.install-hint {
  position: absolute;
  left: 12px; right: 12px; top: 12px;
  padding: 12px 44px 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  z-index: 15;
}
.install-hint button {
  position: absolute;
  top: 4px; right: 4px;
  width: 36px; height: 36px;
  font-size: 22px;
  background: transparent;
  border: 0;
  -webkit-appearance: none;
}

/* Page changes */
.grid.slide-from-right { -webkit-animation: slide-from-right 240ms ease-out; animation: slide-from-right 240ms ease-out; }
.grid.slide-from-left { -webkit-animation: slide-from-left 240ms ease-out; animation: slide-from-left 240ms ease-out; }
.grid.bounce-left { -webkit-animation: bounce-left 240ms ease-out; animation: bounce-left 240ms ease-out; }
.grid.bounce-right { -webkit-animation: bounce-right 240ms ease-out; animation: bounce-right 240ms ease-out; }

@-webkit-keyframes slide-from-right { from { opacity: 0.3; -webkit-transform: translateX(18%); } to { opacity: 1; -webkit-transform: none; } }
@keyframes slide-from-right { from { opacity: 0.3; transform: translateX(18%); } to { opacity: 1; transform: none; } }
@-webkit-keyframes slide-from-left { from { opacity: 0.3; -webkit-transform: translateX(-18%); } to { opacity: 1; -webkit-transform: none; } }
@keyframes slide-from-left { from { opacity: 0.3; transform: translateX(-18%); } to { opacity: 1; transform: none; } }
@-webkit-keyframes bounce-left { 40% { -webkit-transform: translateX(-3%); } to { -webkit-transform: none; } }
@keyframes bounce-left { 40% { transform: translateX(-3%); } to { transform: none; } }
@-webkit-keyframes bounce-right { 40% { -webkit-transform: translateX(3%); } to { -webkit-transform: none; } }
@keyframes bounce-right { 40% { transform: translateX(3%); } to { transform: none; } }

.overlay-actions { margin-top: 18px; }
.overlay-actions .primary { margin-top: 0; }
.secondary {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  -webkit-appearance: none;
}

/* Screens around the deck: account, PC list, address, trust (Safari 12: no flexbox gap). */
.screen.pair { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.link-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 10px;
  font-size: 15px;
  color: var(--accent);
  background: transparent;
  border: 0;
  -webkit-appearance: none;
}
.pc-list { margin-top: 6px; }
.pc-item { min-height: 56px; }
.pc-item .pc-name { display: block; font-weight: 600; }
.pc-item .pc-detail { display: block; margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.trust { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-m); background: var(--surface); }
.trust.warning { border-color: var(--warning); }
.trust-text { margin: 0; line-height: 1.45; }
.trust .secondary { min-height: 44px; }
button:focus, a:focus, input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
