/* Shared viewport and touch adaptations. Tables and code scroll in their own regions. */
:root { color-scheme: dark; }
img, video, svg { max-width: 100%; }
input, select, textarea { min-width: 0; max-width: 100%; }
.quick-check-node-opt { min-width: 0; max-width: 100%; flex-wrap: wrap; overflow-wrap: anywhere; }
.net-node-location, .net-stat, .net-ip-details { overflow-wrap: anywhere; }
.net-ip-details dd { min-width: 0; }
main { overflow-wrap: anywhere; }
button, a, input, select, textarea { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid #93baff; outline-offset: 3px; }
.header-actions { justify-content: flex-end; position: relative; min-width: 0; }
.header-chips { flex-wrap: wrap; }
.header-search { display: flex; align-items: center; gap: 9px; flex: 1 1 230px; min-width: 200px; max-width: 340px; min-height: 40px; padding: 3px 5px 3px 12px; border: 1px solid #344258; border-radius: 10px; background: #121c2a; color: #91a6c3; }
.header-search:focus-within { border-color: #7eacf7; box-shadow: 0 0 0 3px #3b82f61a; }
.header-search svg { flex: none; }
.header-search input { width: 100%; min-width: 0; border: 0; background: none; color: #e6edf3; font: inherit; font-size: 13px; padding: 5px 0; }
.header-search input::placeholder { color: #91a0b6; }
.header-search input:focus-visible { outline: none; }
.header-search button { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 0; border-radius: 7px; background: #23344d; color: #c4daff; font-size: 18px; cursor: pointer; }
.header-search button:hover { background: #314c71; }
.tab-nav-bar { position: static; }
.modal-overlay { padding: 16px; }
.modal { max-height: calc(100dvh - 32px); overscroll-behavior: contain; }
body:has(.modal-overlay.open) { overflow: hidden; }
body:has(.modal-overlay.open) .toast-container { bottom: 90px; max-width: calc(100vw - 32px); }
.modal-body, .form-group, .form-row > *, .vless-group, .vless-card, .tester-health-card { min-width: 0; }
.form-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
.sub-actions { flex-wrap: wrap; }
.sub-name, .sub-error, .group-name, .qc-card-error-msg { overflow-wrap: anywhere; }
.tester-health-grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,260px),1fr)); }
.docs-container > *, .docs-grid > *, .code-block-wrapper { min-width: 0; }
.docs-content { overflow-wrap: anywhere; }
.params-table { display: block; max-width: 100%; overflow-x: auto; }
.docs-code { max-width: 100%; }
.docs-header { flex-wrap: wrap; }
.docs-header-actions { flex-wrap: wrap; }
.public-brand > div:last-child { min-width: 0; }
.public-logo { flex-shrink: 0; }
.public-brand-name, .public-eyebrow, .public-hero h1, .public-hero p, .public-footer { overflow-wrap: anywhere; }
.public-header { gap: 16px; }
.public-live-indicator { flex-shrink: 0; }
@media (max-width: 700px) {
  .main { padding: 16px 12px; }
  .v2ray-toolbar { flex-wrap: wrap; gap: 8px; }
  .v2ray-toolbar .btn { min-height: 40px; flex: 1 1 auto; justify-content: center; }
  .v2ray-view-tabs { display: flex; }
  .v2ray-view-tab { flex: 1; min-width: 0; min-height: 44px; padding: 8px; }
  .v2ray-view-heading { flex-wrap: wrap; gap: 4px; }
  .modal-overlay { padding: 8px; }
  .modal { max-height: calc(100dvh - 16px); border-radius: 12px; }
  .modal-header { padding: 16px; }
  .modal-title { min-width: 0; overflow-wrap: anywhere; }
  .modal-close { flex: none; display: grid; place-items: center; width: 36px; height: 36px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn { min-height: 42px; }
  .form-input { font-size: 16px; min-height: 42px; }
  .login-input { font-size: 16px; min-height: 44px; }
  .form-row { grid-template-columns: minmax(0,1fr); }
  .sub-actions, .sub-row-top .sub-actions { flex-wrap: wrap; }
  .sub-action, .group-action { min-height: 40px; }
  .vless-group-header { flex-wrap: wrap; gap: 8px; }
  .vless-grid { grid-template-columns: minmax(0,1fr); }
  .vless-header { flex-wrap: wrap; gap: 10px; }
  .vless-title-block { max-width: 100%; flex: 1 1 200px; }
  .vless-actions { margin-left: auto; }
  .vless-metrics { width: 100%; justify-content: space-between; gap: 8px; margin-left: 0; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.04); }
  .vless-node-strip { flex-direction: column; align-items: flex-start; gap: 8px; }
  .vless-node-assign-slot { width: 100%; margin-left: 0; }
  .vless-node-assign-pair { width: 100%; }
  .vless-node-assign-pair .vless-node-assign { flex: 1 1 50%; max-width: none; }
  .vless-route-meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .vless-route-verdicts { margin-left: 0; }
  .quick-check-grid { grid-template-columns: minmax(0,1fr); }
  .quick-check-config-editor .form-row { grid-template-columns: minmax(0,1fr); }
  .net-result-row { grid-template-columns: minmax(0,1fr); padding: 14px; }
  .net-result-body { min-width: 0; }
  .net-tools-modal { width: 100%; }
  .ip-search-form { flex-wrap: wrap; }
  .ip-search-form .form-input { flex: 1 1 100%; }
  .admin-header { position: static; }
  .admin-main { margin-top: 20px; }
  .admin-card { -webkit-overflow-scrolling: touch; }
  .admin-table th, .admin-table td { padding: 12px; }
  .admin-card { background: none; border: 0; overflow: visible; }
  .admin-table, .admin-table tbody { display: block; }
  .admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .admin-table tr { display: block; border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 14px; background: var(--bg-card); padding: 6px 0; }
  .admin-table td { display: flow-root; min-width: 0; padding: 9px 14px; overflow-wrap: anywhere; }
  .admin-table td[data-label]::before { content: attr(data-label); display: block; color: #91a0b6; font-size: 10px; font-weight: 600; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
  .admin-table tr:hover td { background: none; }
  .tester-actions { flex-wrap: wrap; }
  .admin-actions .btn, .tester-actions .btn { min-height: 40px; }
  .admin-slot-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .admin-config-assignment, .admin-slot-config-row { grid-template-columns: minmax(0,1fr); }
  .admin-slot-toolbar, .admin-header-actions { flex-wrap: wrap; }
  .admin-slot-modal { max-height: calc(100dvh - 16px); }
  .docs-header { padding: 14px 16px; gap: 12px; position: static; }
  .docs-title { flex-wrap: wrap; }
  .docs-header-actions { margin-left: 0; width: 100%; }
  .docs-container { padding: 20px 16px 48px; gap: 20px; }
  .docs-grid { grid-template-columns: minmax(0,1fr); }
  .docs-sidebar a { min-height: 38px; display: flex; align-items: center; }
  .endpoint-header { flex-wrap: wrap; }
  .public-header { flex-wrap: wrap; padding-bottom: 14px; }
  .public-updated { max-width: 100%; line-height: 1.6; }
  .public-telegram-link { min-height: 44px; }
}
@media (max-width: 700px) {
  /* Card header: status + name on top, metrics as tiles, full-width touch actions */
  .vless-card .drag-handle { display: none; }
  .vless-header { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px 12px; padding: 14px; }
  .vless-title-block { max-width: none; min-width: 0; flex: none; }
  .vless-name { font-size: 15px; }
  .vless-tags { justify-self: end; }
  .vless-metrics { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding: 10px 0 0; border-top: 1px solid rgba(255,255,255,.06); }
  .vless-metrics .vless-metric { text-align: center; }
  .vless-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin: 0; width: 100%; }
  .vless-actions .btn-icon { width: 100%; min-height: 44px; height: 44px; display: grid; place-items: center; }
  /* Node strip: pills wrap, selects side by side */
  .vless-nodes-row { flex-wrap: wrap; gap: 6px; width: 100%; }
  .vless-node-assign-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .vless-node-assign-pair select, .vless-node-assign select { min-height: 44px; font-size: 16px; width: 100%; }
  /* Route meta: column flex made the 280px basis a height => big blank gap */
  .vless-route-info { flex: 0 0 auto; width: 100%; }
  .vless-route-row { flex-wrap: nowrap; }
  .vless-route-ip, .vless-route-exit { overflow-wrap: anywhere; min-width: 0; }
  .vless-route-verdicts { align-self: stretch; justify-content: center; margin: 0; padding: 6px 12px; }
  /* Quality history: stacked, scrollable pickers, taller chart */
  .vless-controls-row { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px 8px; }
  .vless-node-tabs { display: flex; width: 100%; overflow-x: auto; }
  .vless-node-tabs > * { flex: 1 0 auto; min-height: 40px; }
  .vless-range-row { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
  .vless-range-btn { min-height: 40px; font-size: 13px; }
  .vless-chart-wrap { height: 190px; padding: 0 8px 14px; }
  .vless-chart-state { inset: 0 8px 14px; }
}
@media (pointer: coarse) and (max-width: 1100px) {
  .form-input { font-size: 16px !important; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .modal-overlay { padding: 6px; }
  .modal { max-height: calc(100dvh - 12px); }
  .header, .admin-header, .docs-header { position: static; }
}
@media (max-width: 580px) {
  .public-card-top { display: grid; grid-template-columns: 40px minmax(0,1fr); gap: 8px 12px; }
  .public-country-flag { grid-row: 1 / 3; }
  .public-status { grid-column: 2; justify-self: start; }
  .public-card-name, .public-card-location { white-space: normal; overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
