:root {
  color-scheme: dark;
  --bg: #070d18;
  --panel: rgba(17, 29, 48, .86);
  --panel-soft: rgba(24, 40, 65, .7);
  --line: rgba(171, 198, 232, .17);
  --text: #edf5ff;
  --muted: #9aabc2;
  --accent: #64d7c4;
  --accent-strong: #32bca7;
  --blue: #78aaf5;
  --danger: #ff8e94;
  --server-status-height: 0px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 10%, #17304a 0, transparent 35%), radial-gradient(circle at 90% 80%, #12372f 0, transparent 32%), var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; }
.page-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 72px; }
.auth-card { width: min(440px, 100%); margin: 8vh auto 0; padding: 40px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 28px; border-radius: 14px; color: #061419; background: linear-gradient(135deg, var(--accent), var(--blue)); font-weight: 800; letter-spacing: -.08em; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.06em; }
h2 { margin-bottom: 8px; font-size: 1.12rem; letter-spacing: -.02em; }
.muted { color: var(--muted); line-height: 1.65; }
label { display: block; margin: 22px 0 8px; color: #cbd9eb; font-size: .86rem; font-weight: 650; }
.optional { color: var(--muted); font-weight: 400; }
input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--text); background: rgba(5, 12, 23, .7); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(100, 215, 196, .14); }
button { border: 0; border-radius: 11px; padding: 12px 16px; color: var(--text); transition: transform .15s ease, background .15s ease, border-color .15s ease; }
button:hover { transform: translateY(-1px); }
.primary { width: 100%; margin-top: 26px; color: #061419; background: var(--accent); font-weight: 800; }
.primary:hover { background: var(--accent-strong); }
.secondary { border: 1px solid var(--line); background: rgba(39, 63, 94, .45); }
.secondary:hover { border-color: rgba(100, 215, 196, .45); background: rgba(39, 73, 92, .6); }
.link-button { display: block; margin: 18px auto 0; padding: 5px; color: var(--accent); background: transparent; }
.message { min-height: 22px; margin: 16px 0 0; color: var(--danger); line-height: 1.45; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.topbar h1 { margin-bottom: 0; }
.account-area { display: flex; align-items: center; gap: 12px; }
.account-label { color: var(--muted); font-size: .9rem; }
.server-status-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 10px 12px;
  border: 1px solid rgba(100, 215, 196, .24);
  border-radius: 14px;
  background: rgba(13, 27, 46, .94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  backdrop-filter: blur(18px);
}
.server-status-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 10px;
  min-width: 190px;
}
.server-status-user {
  color: #cbd9eb;
  font-size: .78rem;
  font-weight: 700;
}
.server-status-host {
  color: var(--muted);
  font-size: .74rem;
}
.server-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.server-metric {
  min-width: 0;
  padding: 5px 10px;
  border-left: 1px solid var(--line);
}
.server-metric-label {
  display: block;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.server-metric strong {
  display: block;
  margin-top: 2px;
  font-size: .96rem;
}
.server-metric small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: .66rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intro { max-width: 720px; margin-bottom: 34px; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.module-card { min-height: 250px; padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: 0 16px 50px rgba(0,0,0,.2); }
.active-card { border-color: rgba(100, 215, 196, .35); }
.card-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 24px; border-radius: 12px; color: var(--accent); background: rgba(100, 215, 196, .11); font-size: 1.4rem; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.module-card p { min-height: 50px; color: var(--muted); line-height: 1.55; }
.status-dot { white-space: nowrap; font-size: .72rem; font-weight: 750; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 7px 1px 0; border-radius: 99px; background: currentColor; }
.status-dot.active { color: var(--accent); }
.status-dot.planned { color: #aab7cc; }
.status-dot.available { color: var(--blue); }
.module-status { min-height: 26px; margin-bottom: 18px; color: #cbd9eb; font-size: .84rem; }
.module-button { width: 100%; }
.detail-panel { margin-top: 18px; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-soft); }
.detail-panel h2 { margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric { padding: 14px; border-radius: 12px; background: rgba(2, 8, 17, .32); }
.metric-label { color: var(--muted); font-size: .73rem; }
.metric-value { margin-top: 5px; font-size: 1.05rem; font-weight: 750; }
@media (max-width: 900px) {
  .server-status-bar {
    display: block;
    margin-bottom: 14px;
    padding: 10px;
  }
  .server-metrics {
    display: flex;
    gap: 7px;
    margin-top: 8px;
    padding-bottom: 2px;
    overflow-x: auto;
  }
  .server-metric {
    flex: 1 0 104px;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding: 8px 9px 5px;
  }
}

@media (max-width: 720px) {
  .page-shell { width: min(100% - 24px, 560px); padding-top: 28px; }
  .auth-card { padding: 28px 22px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .account-area { width: 100%; justify-content: space-between; }
  .module-grid, .detail-grid { grid-template-columns: 1fr; }
}

.dashboard-view.evony-mode > .intro,
.dashboard-view.evony-mode > .module-grid { display: none; }
.dashboard-view.evony-mode > .detail-panel { display: block; margin-top: 8px; }
.evony-console { margin-top: 4px; }
.evony-console-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.evony-console-header h2 { margin-bottom: 6px; }
.evony-header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.evony-toolbar, .evony-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin: 18px 0; }
.evony-toolbar label, .evony-controls label { margin: 0; min-width: 220px; }
.evony-toolbar select, .evony-controls select { display: block; width: 100%; margin-top: 7px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: rgba(5, 12, 23, .7); }
.capture-label { color: var(--muted); font-size: .8rem; }
.evony-screen-shell { position: relative; display: grid; place-items: center; min-height: 300px; padding: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #03070d; }
.evony-screen { display: block; width: auto; max-width: min(100%, 1024px); max-height: min(70vh, 720px); border-radius: 8px; cursor: crosshair; object-fit: contain; box-shadow: 0 12px 38px rgba(0,0,0,.4); }
.evony-screen.manual-read-only { cursor: default; }
.evony-screen[data-orientation="portrait"] { max-width: min(100%, 405px); }
.evony-screen.template-area-mode {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  cursor: crosshair;
}
.evony-empty { color: var(--muted); text-align: center; }
.tap-marker-layer { position: absolute; inset: 18px; pointer-events: none; }
.template-click-layer {
  position: absolute;
  z-index: 7;
  pointer-events: none;
}
.template-click-marker {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .35);
}
.template-click-marker span {
  position: absolute;
  left: 14px;
  top: -8px;
  padding: 3px 6px;
  border-radius: 5px;
  color: #06230f;
  background: #86efac;
  font: 700 .72rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: nowrap;
}
.template-input-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(255, 255, 255, .001);
  pointer-events: none;
}
.template-input-layer.active {
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}
.template-required { color: var(--muted); font-size: .78rem; font-weight: 500; }
.template-field-error { margin: 4px 0 10px; color: var(--danger); font-size: .8rem; }
.template-workshop [aria-invalid="true"] { border-color: var(--danger); }
.template-save-message.error { color: var(--danger); }
.template-save-message.good { color: var(--accent); }
#evony-save-template:disabled { opacity: .6; cursor: wait; }
.template-coordinate-readout {
  display: grid;
  gap: 6px;
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(74, 222, 128, .42);
  border-radius: 9px;
  background: rgba(15, 45, 28, .34);
  color: #c9f8d5;
  font-size: .8rem;
}
.template-coordinate-readout strong {
  color: #86efac;
  font-size: .82rem;
}
.template-coordinate-readout div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.template-coordinate-readout code {
  color: #f0fff4;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.template-mode-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 8px 0 12px; }
.template-selection {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  border: 3px solid #4ade80;
  border-radius: 5px;
  background: rgba(74, 222, 128, .30);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .14);
}
.tap-marker { position: absolute; width: 22px; height: 22px; transform: translate(-50%, -50%); border: 3px solid #fff; border-radius: 50%; background: rgba(100, 215, 196, .72); box-shadow: 0 0 0 5px rgba(100, 215, 196, .22); }
.tap-marker.stale { background: rgba(255, 186, 94, .76); box-shadow: 0 0 0 5px rgba(255, 186, 94, .2); }
.small-button { padding: 9px 12px; font-size: .82rem; }
.danger-button { border: 1px solid rgba(255, 142, 148, .45); color: #ffd7d9; background: rgba(124, 36, 49, .55); }
.danger-button:hover { border-color: var(--danger); background: rgba(145, 43, 58, .72); }
.evony-console-message { min-height: 24px; margin: 12px 0; color: var(--danger); line-height: 1.45; }
.evony-console-message.good { color: var(--accent); }
.event-timeline { display: grid; gap: 7px; margin-bottom: 22px; }
.console-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 8, 17, .2);
  overflow: hidden;
}
.console-section summary {
  cursor: pointer;
  padding: 11px 13px;
  color: #cbd9eb;
  font-size: .82rem;
  font-weight: 750;
  list-style: none;
}
.console-section summary::-webkit-details-marker { display: none; }
.console-section summary::before { content: "＋"; color: var(--accent); margin-right: 8px; }
.console-section[open] summary::before { content: "−"; }
.console-section > .event-timeline,
.console-section > .debug-log,
.console-section > .discovered-list {
  padding: 0 11px 11px;
  margin-bottom: 0;
}

.event-row { display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: center; padding: 9px 11px; border-radius: 9px; color: #cbd9eb; background: rgba(2, 8, 17, .32); font-size: .8rem; }
.event-result { font-weight: 750; }
.event-result.sent, .event-result.armed, .event-result.dry-run { color: var(--accent); }
.event-result.failed { color: var(--danger); }
.event-result.stopped { color: #ffca85; }
.event-coords { color: var(--muted); }
.observation-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(255, 202, 133, .22);
  border-radius: 12px;
  background: rgba(42, 32, 20, .26);
}
.observation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.observation-state {
  font-size: .82rem;
  font-weight: 800;
}
.observation-state.unknown { color: #ffca85; }
.observation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.observation-grid > div {
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(2, 8, 17, .28);
}
.observation-grid span {
  display: block;
  color: var(--muted);
  font-size: .68rem;
}
.observation-grid strong {
  display: block;
  margin-top: 3px;
  color: #dce8f7;
  font-size: .82rem;
}
.observation-learning {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 8, 17, .2);
}
.observation-learning label { margin: 0; }
.observation-learning select { width: 100%; margin-top: 6px; }
.observation-learning button { width: 100%; }
.observation-learning p { margin: 0; }
.template-workshop-body {
  display: grid;
  gap: 8px;
  padding: 0 11px 11px;
}
.template-workshop-body > p { margin: 0 0 3px; }
.template-workshop-body label { margin: 6px 0 0; }
.template-workshop-body input,
.template-workshop-body textarea,
.template-workshop-body select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(5, 12, 23, .7);
}
.template-workshop-body textarea {
  resize: vertical;
  line-height: 1.4;
}
.template-workshop-body input:focus,
.template-workshop-body textarea:focus,
.template-workshop-body select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(100, 215, 196, .14);
}
.template-list { display: grid; gap: 8px; margin-top: 5px; }
.template-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(2, 8, 17, .28);
}
.template-item img {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 7px;
  background: #03070d;
}
.template-item strong,
.template-item span,
.template-item p {
  display: block;
}
.template-item strong { font-size: .8rem; }
.template-item p {
  margin: 3px 0;
  color: #cbd9eb;
  font-size: .75rem;
  line-height: 1.35;
}
.observation-reason {
  margin: 0;
  color: #cbd9eb;
  font-size: .78rem;
  line-height: 1.45;
}
.discovered-list { display: grid; gap: 8px; }
.discovered-device { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(2, 8, 17, .22); font-size: .82rem; }
.evony-console h3 { margin: 24px 0 10px; font-size: .9rem; color: #cbd9eb; }
@media (max-width: 720px) {
  .evony-console-header { flex-direction: column; }
  .evony-console-header button { width: 100%; }
  .evony-screen-shell { min-height: 240px; padding: 10px; }
  .tap-marker-layer { inset: 10px; }
  .event-row { grid-template-columns: 1fr auto; }
  .event-row .event-result { grid-column: 1 / -1; }
}


/* Evony workstation: the module owns the available workspace. */
.page-shell.evony-workspace {
  width: min(1600px, calc(100% - 32px));
  padding-top: 24px;
}
.page-shell.evony-workspace #dashboard-view > .intro,
.page-shell.evony-workspace #dashboard-view > .module-grid {
  display: none;
}
.page-shell.evony-workspace #dashboard-view > .detail-panel {
  display: block;
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.page-shell.evony-workspace .topbar {
  margin-bottom: 14px;
}
.page-shell.evony-workspace .evony-console {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px 24px;
  align-items: start;
}
.page-shell.evony-workspace .evony-console-header {
  grid-column: 1 / -1;
}
.page-shell.evony-workspace .evony-toolbar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}
.page-shell.evony-workspace .evony-toolbar label {
  min-width: 0;
}
.page-shell.evony-workspace .evony-screen-shell {
  grid-column: 2;
  grid-row: 2 / span 10;
  justify-self: start;
  align-self: start;
  width: fit-content;
  min-width: 260px;
  max-width: 100%;
  min-height: 0;
  position: sticky;
  top: calc(var(--server-status-height, 0px) + 12px);
  z-index: 5;
  padding: 18px;
}
.page-shell.evony-workspace .evony-controls,
.page-shell.evony-workspace .evony-console > #evony-control-state,
.page-shell.evony-workspace .evony-console > #evony-console-message,
.page-shell.evony-workspace .evony-console > h3,
.page-shell.evony-workspace .evony-console > .console-section,
.page-shell.evony-workspace .evony-console > .observation-learning,
.page-shell.evony-workspace .evony-console > .event-timeline,
.page-shell.evony-workspace .evony-console > .discovered-list,
.page-shell.evony-workspace .evony-console > .observation-card,
.page-shell.evony-workspace .evony-console > .debug-log {
  grid-column: 1;
}
.page-shell.evony-workspace .evony-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}
.page-shell.evony-workspace .evony-controls label {
  min-width: 0;
}
.page-shell.evony-workspace .evony-controls button {
  width: 100%;
}
.page-shell.evony-workspace .evony-console-message {
  margin: 0;
}
.page-shell.evony-workspace .event-timeline,
.page-shell.evony-workspace .discovered-list,
.page-shell.evony-workspace .observation-card,
.page-shell.evony-workspace .observation-learning,
.page-shell.evony-workspace .console-section {
  width: 100%;
}
.page-shell.evony-workspace .evony-screen {
  max-height: min(76vh, calc(100vh - var(--server-status-height, 0px) - 56px), 720px);
}
.page-shell.evony-workspace .evony-screen-shell:has(.evony-screen[hidden]) {
  min-height: 220px;
}

@media (max-width: 900px) {
  .page-shell.evony-workspace {
    width: min(100% - 24px, 720px);
    padding-top: 28px;
  }
  .page-shell.evony-workspace .evony-console {
    grid-template-columns: 1fr;
  }
  .page-shell.evony-workspace .evony-console-header,
  .page-shell.evony-workspace .evony-toolbar,
  .page-shell.evony-workspace .evony-screen-shell,
  .page-shell.evony-workspace .evony-controls,
  .page-shell.evony-workspace .evony-console > #evony-control-state,
  .page-shell.evony-workspace .evony-console > #evony-console-message,
  .page-shell.evony-workspace .evony-console > h3,
  .page-shell.evony-workspace .evony-console > .console-section,
  .page-shell.evony-workspace .evony-console > .observation-learning,
  .page-shell.evony-workspace .evony-console > .event-timeline,
  .page-shell.evony-workspace .evony-console > .discovered-list,
  .page-shell.evony-workspace .evony-console > .observation-card,
  .page-shell.evony-workspace .evony-console > .debug-log {
    grid-column: 1;
  }
  .page-shell.evony-workspace .evony-screen-shell {
    grid-row: auto;
    justify-self: stretch;
    width: 100%;
    position: static;
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .page-shell.evony-workspace {
    width: min(100% - 24px, 560px);
  }
}

.location-monitor { padding: 12px 14px; }
.location-monitor p { margin: 8px 0; }
.location-result.known { color: var(--accent); }
.location-result.unknown { color: var(--muted); }
.template-resolution-group, .template-category { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.template-resolution-group > summary, .template-category > summary { cursor: pointer; font-size: .85rem; font-weight: 650; padding: 6px 0; }
.template-category { margin-top: 9px; }
.template-category .template-list { margin-top: 10px; }
.template-item > div { min-width: 0; overflow-wrap: anywhere; }
.template-use-label { display: block; color: var(--accent); font-size: .72rem; margin: 4px 0; }


/* AutoJoin controls use the same collapsible left-column workspace. */
.autojoin-body { display: grid; gap: 12px; padding-top: 12px; }
.autojoin-body p { margin: 0; }
.autojoin-filter { display: grid; gap: 8px; padding-top: 12px; }
.autojoin-exclusion { display: flex; gap: 10px; align-items: center; font-size: .85rem; }
.autojoin-exclusion input { width: auto; min-height: 20px; accent-color: var(--accent); }
.autojoin-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.autojoin-buttons button { flex: 1; }
.autojoin-card { padding: 10px; margin-top: 8px; border: 1px solid var(--line); border-left: 3px solid #60d7c2; border-radius: 8px; font-size: .85rem; }
.autojoin-card.excluded { border-left-color: #fbbf24; }
.autojoin-card p { margin: 6px 0; }
#evony-autojoin-status p { margin: 8px 0; }


.pin-dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #0c192b; color: var(--text); }
.pin-dialog::backdrop { background: rgba(0,0,0,.72); }
.pin-form, .account-security form { display: grid; gap: 14px; }
.pin-form h2 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.pin-form input, .account-security input[type=password] { display: block; width: 100%; margin-top: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #06101e; color: var(--text); }
.pin-actions, .settings-header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pin-actions button { flex: 1; }
.account-security { max-width: 660px; padding: 18px; margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-soft); }
.permission-user { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.permission-user input { width: auto; min-height: 20px; }
.account-security input::-ms-reveal, .pin-form input::-ms-reveal { display: none; }

.account-area { flex-wrap: wrap; max-width: 100%; }
.account-label, .permission-user span { overflow-wrap: anywhere; }
.pin-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* Account settings is a dedicated full-page view, not a module accordion. */
#dashboard-view.settings-mode > .intro,
#dashboard-view.settings-mode > .module-grid,
#dashboard-view.settings-mode > #detail-panel { display: none; }
.settings-page { padding: 20px 0 40px; min-height: 60vh; }
.settings-page .settings-header { justify-content: space-between; }
.settings-page .account-security { max-width: 760px; }
.input-effect { color: var(--accent); font-weight: 750; margin: 0; }

/* Debug evidence stays compact; never changes the screenshot/left-panel grid. */
.evony-console-header { flex-wrap: wrap; }
.snap-message { flex-basis: 100%; overflow-wrap: anywhere; margin: 0; }
.debug-snap { display: grid; gap: .35rem; padding: .75rem 0; border-bottom: 1px solid var(--border, #26384a); }
.debug-snap code { overflow-wrap: anywhere; color: #61d6c3; }
.debug-snap a { color: #61d6c3; }
.snap-note { display: grid; gap: .4rem; margin: .75rem 0; }

/* Transport status is always visible, independent of Live input or collapsed menus. */
.adb-connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 750;
  line-height: 1.3;
  color: #aab7cc;
  background: rgba(148,163,184,.08);
}
.adb-connection::before {
  content: "";
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.adb-connection.active, #server-adb[data-state=active] { color: #64d7c4; }
.adb-connection.inactive, #server-adb[data-state=inactive] { color: #fda4af; }
.adb-connection.unknown, .adb-connection.checking { color: #cbd5e1; }
#server-adb-connection { flex-basis: auto; }
.evony-link-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.evony-link-status small { overflow-wrap: anywhere; }

/* Low-bandwidth preview age stays visible beside the sticky native-coordinate image. */
.preview-status { position: absolute; bottom: 1px; left: 18px; right: 18px; font-size: 10px; line-height: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.preview-status.delayed { color: #ffba5e; }
@media (max-width: 900px) { .preview-status { left: 10px; right: 10px; font-size: 9px; } }

/* One shared input-mode badge; the existing desktop appearance is unchanged. */
.evony-mode-chip { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: transparent; font-weight: 800; font-size: 10px; color: #b7c9df; white-space: nowrap; }
.evony-mode-chip.live { border-color: rgba(100,215,196,.5); background: rgba(100,215,196,.1); color: var(--accent); }
.evony-mode-chip.locked { border-color: #b88d45; background: rgba(184,141,69,.1); color: #f3cd8a; }
.evony-mode-chip:hover { transform: none; }
.evony-mode-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 1099px) { .evony-mode-chip { min-height: 36px; font-size: 11px; } }

/* Wide/tall desktop cockpit; narrower or shorter viewports use the compact rail. */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.evony-ui-icon { width: 19px; height: 19px; flex: 0 0 19px; }
@media (min-width: 1100px) and (min-height: 600px) {
  html:has(.page-shell.evony-desktop) { overflow: clip; contain: paint; height: 100dvh; }
  body:has(.page-shell.evony-desktop) { overflow: hidden; }
  .page-shell.evony-workspace.evony-desktop { width: 100%; height: 100dvh; padding: 12px 16px; margin: 0; overflow: hidden; }
  .evony-desktop #dashboard-view { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
  .evony-desktop .topbar { display: none; }
  .evony-desktop #server-status-bar { flex: 0 0 auto; grid-template-columns: auto minmax(0,1fr) auto; gap: 10px; margin: 0; padding: 7px 12px; border-radius: 12px; }
  .evony-desktop .server-status-identity { min-width: 138px; max-width: 200px; gap: 2px 7px; }
  .evony-desktop .server-status-host, .evony-desktop #server-adb-connection { display: none; }
  .evony-desktop .server-metric { padding: 3px 10px; }
  .evony-desktop .server-metric-label { font-size: 9px; letter-spacing: .02em; }
  .evony-desktop .server-metric strong { font-size: 13px; }
  .evony-desktop .server-metric small { font-size: 9px; }
  .evony-desktop .evony-desktop-top-actions { display: flex; align-items: center; gap: 6px; }
  .evony-desktop-top-actions button { padding: 8px 10px; border-radius: 9px; font-size: 11px; white-space: nowrap; }
  .page-shell.evony-desktop #dashboard-view > #detail-panel { flex: 1 1 auto; min-height: 0; }
  .page-shell.evony-desktop .evony-console { display: flex; flex-direction: column; align-items: stretch; gap: 10px; height: 100%; min-height: 0; }
  .evony-desktop .evony-console > .evony-console-header { display: none; }
  .evony-desktop .evony-desktop-account { flex: 0 0 auto; display: grid; grid-template-columns: 150px minmax(260px,340px) minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
  .evony-workspace-brand { display: grid; gap: 2px; }
  .evony-workspace-brand .eyebrow { margin: 0; font-size: 10px; }
  .evony-workspace-brand strong { font-size: 16px; letter-spacing: -.03em; }
  .evony-desktop-account label { margin: 0; display: grid; gap: 4px; font-size: 10px; }
  .evony-desktop-account select { min-height: 34px; width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #06111f; font-size: 12px; }
  .evony-desktop-account-state { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 11px; color: var(--muted); }
  .evony-mode-chip { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-weight: 800; font-size: 10px; color: #b7c9df; white-space: nowrap; }
  .evony-mode-chip.live { border-color: rgba(100,215,196,.5); background: rgba(100,215,196,.1); color: var(--accent); }
  .evony-desktop-account-meta { display: grid; justify-items: end; gap: 4px; min-width: 0; }
  .evony-desktop-account-meta .capture-label { margin: 0; max-width: 260px; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .evony-desktop-account-meta .adb-connection { font-size: 10px; padding: 3px 7px; }
  .evony-desktop-account-meta #evony-adb-connection-detail { display: none; }
  .evony-desktop-stage { display: grid; grid-template-columns: clamp(160px,13vw,196px) clamp(320px,29vw,420px) minmax(0,1fr) 52px; gap: 12px; flex: 1 1 auto; min-height: 180px; }
  .evony-desktop-nav { display: flex; flex-direction: column; gap: 10px; min-height: 0; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--panel); }
  .evony-desktop-tabs { display: grid; align-content: start; gap: 5px; min-height: 0; overflow-y: auto; flex: 1 1 auto; }
  .evony-desktop-nav-footer { display: grid; flex: 0 0 auto; gap: 5px; margin-top: auto; border-top: 1px solid var(--line); padding-top: 8px; }
  .evony-nav-button, .evony-nav-settings { display: flex; gap: 9px; align-items: center; width: 100%; min-height: 43px; padding: 10px; text-align: left; font-size: 13px; font-weight: 650; background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 9px; }
  .evony-nav-button[aria-expanded=true] { color: var(--text); border-color: rgba(100,215,196,.35); background: rgba(100,215,196,.11); }
  .evony-nav-button[aria-expanded=true] .evony-ui-icon { color: var(--accent); }
  .evony-nav-button:hover, .evony-nav-settings:hover { background: rgba(39,63,94,.45); }
  .evony-desktop-options-shell { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
  .evony-desktop-options-shell > header { flex: 0 0 auto; padding: 13px 16px; border-bottom: 1px solid var(--line); }
  .evony-desktop-options-shell .eyebrow { margin-bottom: 3px; font-size: 9px; }
  .evony-desktop-options-shell h2 { margin: 0 !important; font-size: 15px; }
  .evony-desktop-options { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: 14px; }
  .evony-desktop-pane { min-width: 0; }
  .evony-desktop-pane[hidden] { display: none !important; }
  .evony-desktop-pane > .console-section { padding: 0; border: 0; border-radius: 0; background: transparent; margin: 0 0 12px; min-width: 0; width: 100%; }
  .evony-desktop-pane > .console-section > summary { display: none; }
  .evony-desktop-pane .evony-controls, .evony-desktop-pane .evony-toolbar { padding: 0; border: 0; background: transparent; gap: 10px; border-radius: 0; }
  .evony-desktop-pane label { margin: 12px 0 5px; font-size: 12px; }
  .evony-desktop-pane label:first-child { margin-top: 0; }
  .evony-desktop-pane input, .evony-desktop-pane select, .evony-desktop-pane textarea { font-size: 13px; padding: 9px 10px; border-radius: 8px; }
  .evony-desktop-pane button { font-size: 13px; min-height: 36px; padding: 9px 12px; border-radius: 9px; }
  .evony-desktop-pane .primary { margin-top: 6px; }
  .evony-desktop-pane p, .evony-desktop-pane .capture-label { font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
  .evony-desktop-pane .autojoin-body { gap: 10px; padding-top: 0; }
  .evony-desktop-pane .autojoin-exclusion { display: flex; margin: 0; font-size: 11px; padding: 3px 0; }
  .evony-desktop-pane .autojoin-exclusion input { padding: 0; flex: 0 0 18px; }
  .evony-desktop-pane #evony-autojoin-status, .evony-desktop-pane .input-effect { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(5,12,23,.35); }
  .evony-desktop-pane #evony-autojoin-status strong { font-size: 13px; }
  .evony-desktop-pane .location-monitor { padding: 0; }
  .evony-desktop-pane .observation-card { margin: 0; padding: 10px; }
  .evony-desktop-pane .template-workshop-body { padding-top: 0; gap: 10px; }
  .evony-desktop-pane .template-coordinate-readout { margin-top: 0; padding: 10px; font-size: 11px; }
  .evony-desktop-pane .template-coordinate-readout code { font-size: 10px; }
  .evony-desktop-pane .template-mode-actions { gap: 6px; }
  .evony-desktop-pane .template-mode-actions span { font-size: 10px; }
  .evony-desktop-pane .template-list { gap: 8px; }
  .evony-desktop-pane .template-item { padding: 8px; gap: 9px; }
  .evony-desktop-pane .template-item img { width: 48px; height: 48px; }
  .evony-desktop-pane .template-item strong { font-size: 11px; }
  .evony-desktop-pane #evony-account-settings { display: none; }
  .evony-desktop-help { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); }
  .evony-desktop-help > summary { font-size: 11px; cursor: pointer; }
  .evony-desktop-help p { margin: 10px 0 0; }
  .evony-desktop-preview { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; overflow: hidden; border-radius: 12px; background: rgba(5,12,23,.2); }
  .page-shell.evony-desktop .evony-screen-shell { display: grid; flex: 0 1 auto; position: relative; top: auto; z-index: 1; min-width: 0; width: fit-content; max-width: 100%; min-height: 0; padding: 12px 12px 30px; border-radius: 12px; background: #03070d; overflow: hidden; align-self: center; }
  .page-shell.evony-desktop .evony-screen, .page-shell.evony-desktop .evony-screen[data-orientation=portrait] { max-width: 100%; max-height: calc(var(--evony-stage-height, 500px) - 44px); width: auto; height: auto; border-radius: 7px; }
  .page-shell.evony-desktop .evony-screen-shell:has(.evony-screen[hidden]) { min-height: min(220px,calc(var(--evony-stage-height, 500px) - 30px)); }
  .evony-desktop .preview-status { bottom: 6px; left: 12px; right: 12px; font-size: 10px; }
  .evony-desktop-tools { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 2px; min-height: 0; overflow: hidden; }
  .evony-desktop-tool-stack { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 2px; }
  .evony-desktop-tools button:focus-visible { outline-offset: -3px; }
  .evony-desktop .evony-quick-button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 10px; border-radius: 10px; }
  .evony-desktop #evony-emergency { margin-top: auto; }
  .evony-desktop .evony-desktop-information { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; flex: 0 0 auto; min-height: 40px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
  .evony-run-stat { display: flex; align-items: center; gap: 9px; font-size: 10px; color: var(--muted); white-space: nowrap; }
  .evony-run-stat strong { color: var(--text); font-size: 13px; }
  #evony-desktop-notice { flex: 1; min-width: 200px; margin: 0; font-size: 11px; line-height: 1.35; color: var(--muted); }
  #evony-desktop-selection-note { color: var(--accent); font-size: 11px; }
  .evony-desktop-information .snap-message:empty { display: none; }
  .evony-desktop-information .snap-message { font-size: 11px; line-height: 1.4; }
  .evony-desktop-debug { flex: 0 0 auto; min-height: 36px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
  .evony-desktop-debug > summary { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 8px 12px; cursor: pointer; font-size: 11px; font-weight: 700; }
  .evony-desktop-debug > summary::after { content: "+"; margin-left: auto; color: var(--accent); font-size: 18px; }
  .evony-desktop-debug[open] > summary::after { content: "−"; }
  .evony-desktop-debug > summary small { color: var(--muted); font-size: 10px; font-weight: 400; }
  #evony-desktop-debug-content { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; max-height: min(26vh,230px,max(60px,calc(100dvh - 560px))); overflow-y: auto; padding: 0 12px 12px; }
  #evony-desktop-debug-content > details { padding: 10px; min-width: 0; border-radius: 9px; font-size: 11px; }
  #evony-desktop-debug-content p, #evony-desktop-debug-content .capture-label { font-size: 10px; }
  #evony-desktop-debug-content .event-row { font-size: 10px; }
  #evony-desktop-debug-content .debug-log { max-height: 180px; overflow-y: auto; }
  .evony-desktop button:focus-visible, .evony-desktop summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
}
@media (min-width: 1100px) and (max-width: 1399px) and (min-height: 600px) {
  .evony-desktop .server-metric small { display: none; }
  .evony-desktop .server-status-identity { max-width: 160px; }
  .evony-desktop .evony-desktop-account { grid-template-columns: 130px minmax(220px,300px) minmax(0,1fr) auto; gap: 10px; }
  .evony-desktop-account-meta .capture-label { max-width: 185px; font-size: 9px; }
  .evony-desktop-stage { grid-template-columns: 160px 320px minmax(0,1fr) 48px; gap: 10px; }
}

@media (min-width:1100px) and (min-height:600px) {
  .evony-desktop-pane .console-section details:not([open]) > summary::before { content: "＋"; }
  .evony-desktop-pane .console-section details[open] > summary::before { content: "−"; }
}

/* Device onboarding/access dialogs: independent of desktop panel reparenting. */
.evony-device-dialog{width:min(720px,calc(100vw - 24px));max-height:calc(100dvh - 32px);margin:auto;padding:24px;border:1px solid #315261;border-radius:18px;color:#e5eef8;background:#101e30;box-shadow:0 20px 80px #0008;overflow:auto}
.evony-device-dialog::backdrop{background:#030b16bb}
.evony-device-dialog header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}
.evony-device-dialog h2{font-size:1.25rem;margin:0}
.evony-device-dialog label{display:flex;flex-direction:column;gap:8px;margin:16px 0}
.evony-device-dialog input,.evony-device-dialog select{box-sizing:border-box;width:100%;min-width:0}
.evony-device-dialog input[type=radio],.evony-device-dialog input[type=checkbox]{width:20px;height:20px;flex:none}
.evony-device-dialog p{line-height:1.45}
.device-step{color:#65d5c5;font-size:.85rem;font-weight:700;letter-spacing:.06em}
.device-methods{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.device-methods label{margin:0;padding:16px;border:1px solid #294257;border-radius:12px;cursor:pointer}
.device-methods label:has(input:checked){border-color:#65d5c5;background:#15373b}
.device-methods small{display:block;margin-top:7px;color:#a1b4cb;line-height:1.35}
.device-address{display:grid;grid-template-columns:minmax(0,2fr) minmax(110px,1fr);gap:14px}
.device-dialog-actions{display:flex;gap:12px;flex-wrap:wrap;margin:20px 0}
.device-test-result{display:flex;align-items:flex-start;gap:20px}
.device-test-result img{max-width:45%;max-height:38dvh;object-fit:contain;border-radius:10px;background:#05090f}
.evony-device-dialog .device-stop-confirm{display:flex;flex-direction:row;align-items:flex-start;gap:10px;line-height:1.4}
.device-shares>div,.device-removed>div{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-bottom:1px solid #294257}
.evony-desktop-nav-footer>#evony-add-device,.evony-desktop-nav-footer>#evony-manage-device{width:100%;margin-top:8px}
@media(max-width:560px){.evony-device-dialog{padding:16px}.device-methods{grid-template-columns:1fr}.device-methods label{flex-direction:row;align-items:center}.device-address{grid-template-columns:1fr}.device-test-result{gap:12px}}

/* An empty workspace is not an active ADB connection. Never show a broken image. */
.evony-screen[hidden], #evony-no-device-note[hidden], #evony-connection-route[hidden] { display: none !important; }
.evony-no-device .evony-device-section .evony-toolbar > :not(label):not(#evony-no-device-note),
.evony-no-device .evony-desktop-pane > details:not(.evony-device-section),
.evony-no-device .evony-desktop-help,
.evony-no-device .console-section:not(.evony-device-section),
.evony-no-device #evony-preview-status { display: none !important; }
.evony-no-device button:disabled { opacity: .4; cursor: not-allowed; }
.evony-no-device .evony-empty { max-width: 260px; padding: 20px; text-align: center; }

/* AutoGather keeps the existing compact control language. */
.gather-section label { display: flex; flex-direction: column; gap: .35rem; }
.gather-fields, .gather-readout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.gather-fields > label, .gather-readout > span { min-width: 0; }
.gather-readout { font-size: .85rem; color: var(--muted); }
.gather-readout strong { display: block; color: var(--text); }

.gather-fields > label { margin: 0; }
.gather-section select { width: 100%; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: #070f1b; color: var(--text); }

.gather-section .message.good { color: var(--accent); }

/* Mobile Evony cockpit: the preview and rail do not scroll with the controls.
   Existing native-coordinate image and guarded action nodes are reparented. */
@media (max-width: 1099px), (max-height: 599px) {
  body:has(.page-shell.evony-mobile) { overflow: hidden; }
  .page-shell.evony-workspace.evony-mobile { width: 100%; height: 100dvh; margin: 0; padding: 4px; }
  .evony-mobile #dashboard-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .evony-mobile .topbar, .evony-mobile #server-status-bar { display: none; }
  .page-shell.evony-mobile #detail-panel { flex: 1 1 auto; min-height: 0; margin: 0; padding: 0; }
  .page-shell.evony-mobile .evony-console { display: flex; flex-direction: column; align-items: stretch; width: 100%; height: 100%; min-height: 0; gap: 4px; }
  .evony-mobile .evony-console > .evony-console-header,
  .evony-mobile .evony-desktop-account, .evony-mobile .evony-desktop-tools { display: none !important; }
  .evony-mobile-bar { display: grid; grid-template-columns: minmax(20px,.6fr) 44px 40px 64px 44px minmax(72px,1.4fr); align-items: center; gap: 4px; flex: 0 0 44px; min-height: 44px; padding: 0 4px; border-bottom: 1px solid var(--line); }
  .evony-mobile-bar .server-status-user { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
  .evony-mobile-bar > button { min-width: 0; min-height: 44px; height: 44px; padding: 5px; margin: 0; }
  .evony-mobile-bar #evony-desktop-mode { font-size: 0; }
  .evony-mobile-bar #evony-desktop-mode::after { content: attr(data-input-label); font-size: 10px; }
  .evony-mobile-bar #evony-back { display: grid; place-items: center; width: 44px; border-radius: 8px; }
  .evony-mobile-bar #evony-save-image { display: grid; place-items: center; width: 44px; border-radius: 8px; }
  .evony-mobile-bar .evony-mode-chip { font-size: 10px; line-height: 1.15; }
  .evony-mobile-account { min-width: 0; margin: 0; font-size: 0; line-height: 0; }
  .evony-mobile-account select { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 8px 4px; margin: 0; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--text); background: #07111f; }
  .evony-mobile .evony-desktop-stage { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 48px; gap: 4px; flex: 1 1 auto; min-height: 0; }
  .evony-mobile .evony-desktop-preview { grid-column: 1; grid-row: 1; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; background: #03070d; border-radius: 8px; }
  .page-shell.evony-mobile #evony-screen-shell { position: relative; top: auto; grid-column: auto; grid-row: auto; display: grid; place-items: center; align-self: stretch; justify-self: stretch; width: 100%; max-width: 100%; min-width: 0; height: 100%; min-height: 0; padding: 0 0 18px; border-radius: 8px; z-index: 1; }
  .page-shell.evony-mobile #evony-screen { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(var(--evony-stage-height,500px) - 20px); object-fit: contain; border-radius: 3px; }
  .evony-mobile .tap-marker-layer { inset: 0; }
  .evony-mobile .preview-status { left: 4px; right: 4px; bottom: 1px; line-height: 16px; font-size: 9px; }
  .evony-mobile .evony-desktop-nav { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-height: 0; padding: 2px; gap: 3px; border-left: 1px solid var(--line); }
  .evony-mobile .evony-desktop-tabs { display: grid; grid-template-rows: repeat(9,minmax(44px,1fr)); gap: 3px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
  .evony-mobile .evony-desktop-nav-footer { flex: 0 0 44px; display: grid; margin: 0; }
  .evony-mobile .evony-nav-button, .evony-mobile .evony-nav-settings, .evony-mobile #evony-emergency { display: grid; place-items: center; width: 44px; min-height: 44px; margin: 0; padding: 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--panel); }
  .evony-mobile .evony-nav-button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .evony-mobile .evony-nav-button[aria-expanded=true] { border-color: var(--accent); color: var(--accent); background: #173c40; }
  .evony-mobile #evony-emergency { color: #ffb1b7; border-color: #8b3e49; background: #46232b; }
  .evony-mobile .evony-desktop-information { display: block; flex: 0 0 72px; min-height: 0; padding: 5px 8px; border-top: 1px solid var(--line); overflow: auto; font-size: 11px; line-height: 1.35; }
  .evony-mobile-state { display: flex; flex-wrap: wrap; gap: 3px 10px; color: var(--accent); }
  .evony-mobile .evony-run-stat { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; color: var(--muted); font-size: 10px; }
  .evony-mobile #evony-desktop-notice { margin: 2px 0; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
  .evony-mobile #evony-snap-message { margin: 2px 0; min-height: 0; font-size: 10px; }
  .evony-mobile #evony-desktop-selection-note { color: var(--accent); font-size: 10px; }
  .evony-mobile-popup:not([open]) { display: none; }
  .evony-mobile-popup[open] { display: flex; flex-direction: column; width: min(520px,calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 72px); margin: auto; padding: 0; border: 1px solid #46777d; border-radius: 14px; color: var(--text); background: #0e1c2d; box-shadow: 0 20px 80px #000b; overflow: hidden; }
  .evony-mobile-popup::backdrop { background: #020813a6; }
  .evony-mobile-popup > header { position: relative; flex: 0 0 auto; min-height: 54px; padding: 10px 58px 10px 14px; border-bottom: 1px solid var(--line); }
  .evony-mobile-popup > header .eyebrow { margin-bottom: 3px; font-size: 9px; }
  .evony-mobile-popup > header h2 { margin: 0; font-size: 15px; }
  .evony-mobile-close { position: absolute; top: 4px; right: 5px; width: 44px; min-height: 44px; padding: 0; font-size: 26px; background: transparent; }
  .evony-mobile-popup .evony-desktop-options { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; overscroll-behavior: contain; }
  .evony-mobile-popup .evony-desktop-pane { min-width: 0; }
  .evony-mobile-popup .evony-desktop-pane[hidden] { display: none !important; }
  .evony-mobile-popup .evony-desktop-pane > .console-section { width: 100%; min-width: 0; margin: 0 0 10px; padding: 0; border: 0; background: transparent; }
  .evony-mobile-popup .evony-desktop-pane > .console-section > summary,
  .evony-mobile-popup #evony-desktop-debug > summary { display: none; }
  .evony-mobile-popup .evony-toolbar, .evony-mobile-popup .evony-controls { display: flex; flex-direction: column; width: 100%; padding: 0; margin: 0; border: 0; gap: 10px; background: transparent; }
  .evony-mobile-popup label { min-width: 0; margin: 8px 0 4px; font-size: 12px; }
  .evony-mobile-popup input, .evony-mobile-popup select, .evony-mobile-popup textarea { max-width: 100%; min-width: 0; font-size: 16px; }
  .evony-mobile-popup button { min-height: 44px; font-size: 12px; }
  .evony-mobile-popup .evony-mobile-close { font-size: 26px; }
  .evony-mobile-popup .primary { margin-top: 6px; }
  .evony-mobile-popup p, .evony-mobile-popup .capture-label { font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
  .evony-mobile-popup .autojoin-body { padding: 0; gap: 8px; }
  .evony-mobile-popup .autojoin-exclusion { display: flex; margin: 0; font-size: 12px; }
  .evony-mobile-popup .autojoin-exclusion input { flex: 0 0 20px; }
  .evony-mobile-popup #evony-account-settings { display: block; }
  .evony-mobile-popup .evony-desktop-help { margin-top: 12px; color: var(--muted); }
  .evony-mobile-preview-actions { display: flex; gap: 8px; margin-bottom: 12px; }
  .evony-mobile-preview-actions .evony-quick-button { display: flex; align-items: center; justify-content: center; gap: 6px; flex: 1; padding: 8px; font-size: 11px; }
  .evony-mobile-metrics { margin-top: 12px; font-size: 12px; }
  .evony-mobile-metrics .server-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); overflow: visible; }
  .evony-mobile-metrics .server-metric { min-width: 0; }
  .evony-mobile-popup .settings-header { gap: 8px; flex-wrap: wrap; }
  .evony-mobile-popup #bot-settings-back { font-size: 11px; }
  .evony-mobile-popup #evony-pane-devices > button { width: 100%; margin: 0 0 10px; }
  .evony-mobile button:focus-visible, .evony-mobile select:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}

/* Anchor icon-only labels inside their buttons: unanchored absolute spans used
   to escape the scrollable rail and enlarge the page after zoom/rotation. */
.evony-nav-button, .evony-quick-button { position: relative; }
.evony-nav-button.manual-active, .evony-quick-button.manual-active { border-color: var(--accent); color: var(--accent); background: #173c40; }
.evony-nav-button.manual-blocked, .evony-quick-button.manual-blocked { border-color: #b88d45; color: #f3cd8a; background: #382e20; }
.evony-mobile #evony-tab-input::after, #evony-manual-toggle::after { content: attr(data-manual-state); position: absolute; right: 2px; bottom: 2px; font-size: 7px; font-weight: 800; line-height: 9px; }

/* Server screenshot library stays inside the existing scrollable workshop. */
.saved-screenshot-library { margin: 0 0 16px; }
.saved-screenshot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.saved-screenshot-row > span { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; font-size: .8rem; }
.saved-screenshot-row > button { min-height: 44px; flex: 0 0 auto; }

/* AutoHunt UI shell: source and live execution deliberately remain unavailable. */
.hunt-body { display: grid; gap: 10px; min-width: 0; }
.hunt-unavailable { border: 1px solid #89703d; border-radius: 12px; background: #302b21; padding: 12px; color: #ffe1a1; }
.hunt-unavailable p, .hunt-note { margin: 7px 0; font-size: .8rem; line-height: 1.5; overflow-wrap: anywhere; }
.hunt-note { color: var(--muted); }
.hunt-readiness { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 0; }
.hunt-readiness dt { font-size: .75rem; color: var(--muted); }
.hunt-readiness dd { margin: 3px 0 0; font-size: .85rem; overflow-wrap: anywhere; }
.hunt-monsters, .hunt-settings { min-width: 0; }
.hunt-monsters h3 { font-size: .95rem; margin: 0; }
.hunt-body details > summary { font-size: .85rem; }
.hunt-body fieldset { min-width: 0; margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.hunt-body legend { font-size: .8rem; color: var(--muted); }
.hunt-body label { margin: 0; font-size: .78rem; min-width: 0; }
.hunt-body input, .hunt-body select { min-width: 0; width: 100%; font-size: .8rem; }
.hunt-body :disabled { cursor: not-allowed; opacity: .65; }
.hunt-body button:disabled { background: #203044; border-color: var(--line); color: var(--muted); }
.hunt-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.hunt-wide { grid-column: 1 / -1; }
.hunt-table-scroll { width: 100%; overflow-x: auto; margin-top: 12px; }
#evony-hunt-monsters { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .75rem; }
#evony-hunt-monsters th { color: var(--muted); text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#evony-hunt-monsters th:first-child { width: 29%; }
#evony-hunt-monsters .hunt-empty { text-align: center; padding: 24px 10px; border-bottom: 1px solid var(--line); line-height: 1.5; }
.hunt-empty strong, .hunt-empty span { display: block; }
.hunt-empty span { margin-top: 8px; color: var(--muted); }
@media (max-width: 360px) {
  .hunt-fields { grid-template-columns: minmax(0,1fr); }
}

.hunt-table-scroll { max-height: min(46dvh, 480px); overflow: auto; overscroll-behavior: contain; }
#evony-hunt-monsters td { padding: 9px 4px; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#evony-hunt-monsters td small { display: block; color: var(--muted); margin-top: 4px; font-size: .65rem; }
#evony-hunt-monsters th { position: sticky; top: 0; background: #101f30; z-index: 1; }
#evony-hunt-monsters th:nth-child(2) { width: 10%; }
#evony-hunt-monsters th:nth-child(3) { width: 25%; }
#evony-hunt-monsters th:nth-child(4) { width: 16%; }
#evony-hunt-monsters th:nth-child(5) { width: 20%; }
.hunt-jump.small-button { padding: 7px 5px; min-width: 0; width: 100%; font-size: .7rem; }
.hunt-freshness { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; }
.hunt-freshness[data-state="fresh"] { color: #68ded0; border-color: #348c83; }
.hunt-freshness[data-state="stale"] { color: #f5ce83; border-color: #826c3a; }
.hunt-freshness[data-state="refreshing"] { color: #a3ccff; }
.hunt-keep { margin-top: 10px; }
.hunt-readiness { margin: 0; }
.hunt-monsters > .hunt-note { margin: 6px 0; }
.hunt-monsters > h3 { margin: 4px 0 8px; }
.hunt-unavailable { padding: 10px 12px; }
.hunt-unavailable p { margin-bottom: 0; }
.hunt-monsters .hunt-freshness { margin: 8px 0; }
.hunt-monsters .hunt-jump.small-button { font-size: .68rem; padding: 6px 3px; }

/* Account execution and browser control approval are independent. */
#evony-desktop-mode-slot { display: inline-flex; align-items: center; gap: 5px; }
#evony-account-mode { white-space: nowrap; }
.evony-mobile-bar #evony-account-mode { font-size: 9px; padding: 3px; }




/* Selectable picture source; no extra viewport scrolling. */
.evony-preview-choice { position: absolute; right: 8px; bottom: 4px; margin: 0; z-index: 5; }
.evony-preview-choice select { width: 158px; height: 25px; min-height: 0; margin: 0; padding: 2px 5px; font-size: 12px; border-radius: 5px; }
#evony-video-canvas { object-fit: contain; }
#evony-screen[data-manual-active="true"], #evony-video-canvas[data-manual-active="true"] {
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#evony-screen.manual-dragging, #evony-video-canvas.manual-dragging { cursor: grabbing; }
.evony-screen-shell.has-scrcpy { min-height: 0 !important; }
.evony-screen-shell:has(.evony-preview-choice) { padding-bottom: 36px; }
.evony-screen-shell:has(.evony-preview-choice) .preview-status { right: 174px; }
@media (min-width: 1100px) and (min-height: 600px) {
  .page-shell.evony-desktop .evony-screen-shell:has(.evony-preview-choice) { padding-bottom: 36px; }
  .page-shell.evony-desktop .evony-screen { max-height: calc(var(--evony-stage-height, 500px) - 52px); }
}
@media (max-width: 1099px), (max-height: 599px) {
  .page-shell.evony-mobile #evony-screen-shell:has(.evony-preview-choice) { padding-bottom: 34px; }
  .page-shell.evony-mobile #evony-video-canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(var(--evony-stage-height,500px) - 36px); border-radius: 3px; }
  .page-shell.evony-mobile #evony-video-canvas[hidden] { display: none !important; }
  .page-shell.evony-mobile #evony-screen { max-height: calc(var(--evony-stage-height,500px) - 36px); }
  .page-shell.evony-mobile .evony-preview-choice select { font-size: 16px; width: 164px; }
  .page-shell.evony-mobile .preview-status { right: 176px; }
}
