* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #007aff;
  --primary-dark: #0056b3;
  --success: #34c759;
  --danger: #ff3b30;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --border: #e5e5ea;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* VPN Gate Page */
.vpn-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.vpn-container {
  max-width: 400px;
  width: 100%;
  text-align: center;
  color: #fff;
}

.vpn-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.vpn-container h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.vpn-desc {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.6;
  margin-bottom: 28px;
}

.vpn-steps {
  list-style: none;
  text-align: left;
  margin-bottom: 28px;
}

.vpn-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.9);
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.vpn-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.vpn-note {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  flex: 1;
}

.btn-enter {
  width: 100%;
  padding: 14px;
  background: var(--success);
  color: #fff;
  font-size: 16px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  color: var(--text);
}

.modal-content h3 {
  margin-bottom: 16px;
}

.modal-content ol {
  padding-left: 20px;
  line-height: 1.8;
  font-size: 14px;
  margin-bottom: 12px;
}

.modal-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Main App */
.app-page {
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.status-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--border);
  color: var(--text-secondary);
  font-weight: 600;
}

.status-badge.active {
  background: rgba(52, 199, 89, 0.15);
  color: var(--success);
}

.search-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--primary);
}

.search-bar button {
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.search-results {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  max-height: 180px;
  overflow-y: auto;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.search-result-item:active {
  background: var(--bg);
}

#map {
  height: 45vh;
  min-height: 240px;
  z-index: 1;
}

.coord-panel {
  padding: 12px 16px;
  background: var(--card);
  display: grid;
  grid-template-columns: 1fr 1fr 80px;
  gap: 8px;
}

.coord-row label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.coord-row input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.action-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
}

.btn-locate {
  flex: 1;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-start {
  flex: 2;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-start.active {
  background: var(--danger);
}

.info-panel {
  padding: 0 16px 12px;
}

.info-panel p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.keepalive-hint {
  color: var(--success) !important;
  font-weight: 500;
}

.preset-section {
  padding: 0 16px 24px;
}

.preset-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  padding: 6px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

.preset-chip:active {
  background: var(--border);
}

.leaflet-container {
  font-family: inherit;
}
