* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #242424;
  --border: #333;
  --text: #e0e0e0;
  --text-secondary: #888;
  --primary: #4a9eff;
  --primary-hover: #3a8eef;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --radius: 8px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 22px; }
.brand-text { font-size: 16px; font-weight: 600; letter-spacing: -0.5px; }
.nav-actions { display: flex; align-items: center; gap: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-hover); border-color: var(--text-secondary); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  height: calc(100vh - 52px - 36px);
}

/* Editor Panel */
.editor-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.status-area { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-secondary);
  transition: background 0.3s;
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.saving { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.error { background: var(--error); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.status-text { font-size: 12px; color: var(--text-secondary); }
.ip-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', monospace;
  opacity: 0.7;
}
.last-updated { font-size: 11px; color: var(--text-secondary); }

.editor {
  flex: 1; width: 100%; padding: 14px;
  background: transparent; border: none;
  color: var(--text); font-size: 15px; line-height: 1.6;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  resize: none; outline: none;
}
.editor::placeholder { color: var(--text-secondary); opacity: 0.5; }

/* Links Panel */
.links-panel { border-top: 1px solid var(--border); max-height: 180px; overflow-y: auto; }
.links-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
}
.links-title { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.links-list { padding: 6px 14px; }
.link-item {
  display: block; padding: 4px 0; color: var(--primary);
  text-decoration: none; font-size: 12px; word-break: break-all;
  transition: color 0.15s;
}
.link-item:hover { color: var(--primary-hover); text-decoration: underline; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 90%; max-width: 440px; max-height: 80vh; overflow-y: auto;
}
.modal-sm { max-width: 340px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 22px; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; }

/* Form */
.settings-section { margin-bottom: 20px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.help-text { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 12px; margin-bottom: 3px; color: var(--text-secondary); }
.form-input {
  width: 100%; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary); }
.input-group { display: flex; gap: 6px; }
.input-group .form-input { flex: 1; }
.error-text { color: var(--error); font-size: 12px; margin-bottom: 6px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Linked IPs */
.linked-ips-list { margin-top: 8px; }
.linked-ip-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 5px;
}
.linked-ip-item span { font-family: 'SF Mono', monospace; font-size: 12px; }
.linked-ip-item .btn-view { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 11px; padding: 2px 5px; }
.linked-ip-item .btn-view:hover { text-decoration: underline; }
.linked-ip-item .btn-unlink { background: none; border: none; color: var(--error); cursor: pointer; font-size: 11px; padding: 2px 5px; margin-left: 3px; }
.linked-ip-item .btn-unlink:hover { text-decoration: underline; }

/* Footer */
.footer {
  text-align: center; padding: 8px; font-size: 11px;
  color: var(--text-secondary); border-top: 1px solid var(--border);
  opacity: 0.5;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 8px 18px; border-radius: var(--radius);
  font-size: 13px; z-index: 2000; transition: transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 640px) {
  .navbar { padding: 8px 10px; }
  .btn-text { display: none; }
  .btn { padding: 6px; }
  .container { padding: 10px; }
  .editor { font-size: 14px; padding: 10px; }
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
